/* ========================================
   🎨 SMARTCRM MODERN LAYOUT SYSTEM
   Professional Sidebar & Header
   ======================================== */

/* === MAIN LAYOUT === */
#app {
    display: flex;
    min-height: 100vh;
    background: var(--gray-50);
}

/* === MODERN SIDEBAR === */
#sidebar {
    width: 280px;
    background: linear-gradient(180deg, #1F2937 0%, #111827 100%);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 1000;
    transition: transform 0.3s ease;
}

#sidebar.collapsed {
    transform: translateX(-280px);
}

/* Sidebar Header */
.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.2);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 1rem;
    text-decoration: none;
    color: white;
    transition: all 0.3s ease;
}

.sidebar-logo:hover {
    transform: translateX(4px);
}

.sidebar-logo-icon {
    width: 48px;
    height: 48px;
    background: var(--primary-gradient);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.sidebar-logo-text {
    display: flex;
    flex-direction: column;
}

.sidebar-logo-title {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1;
}

.sidebar-logo-subtitle {
    font-size: 0.75rem;
    color: var(--gray-400);
    margin-top: 0.25rem;
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.sidebar-section {
    margin-bottom: 1.5rem;
}

.sidebar-section-title {
    padding: 0.5rem 1.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--gray-500);
}

.sidebar-menu {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sidebar-menu-item {
    margin: 0.25rem 0.75rem;
}

.sidebar-menu-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--gray-300);
    text-decoration: none;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
    font-size: 0.875rem;
    font-weight: 500;
    position: relative;
}

.sidebar-menu-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transform: translateX(4px);
}

.sidebar-menu-link.active {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.sidebar-menu-link.active::before {
    content: '';
    position: absolute;
    left: -0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 24px;
    background: white;
    border-radius: 0 2px 2px 0;
}

.sidebar-menu-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
}

.sidebar-menu-text {
    flex: 1;
}

.sidebar-menu-badge {
    background: var(--danger-500);
    color: white;
    font-size: 0.625rem;
    font-weight: 700;
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    min-width: 20px;
    text-align: center;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.2);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
    cursor: pointer;
}

.sidebar-user:hover {
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-user-avatar {
    width: 40px;
    height: 40px;
    background: var(--primary-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    color: white;
    font-weight: 600;
}

.sidebar-user-info {
    flex: 1;
}

.sidebar-user-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: white;
    line-height: 1.2;
}

.sidebar-user-role {
    font-size: 0.75rem;
    color: var(--gray-400);
}

/* === MODERN HEADER === */
#header {
    margin-left: 280px;
    background: white;
    border-bottom: 1px solid var(--gray-200);
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    position: sticky;
    top: 0;
    z-index: 999;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: margin-left 0.3s ease;
}

#sidebar.collapsed ~ #header {
    margin-left: 0;
}

/* Header Left */
.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-toggle {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-100);
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1.25rem;
    color: var(--gray-700);
}

.header-toggle:hover {
    background: var(--primary-600);
    color: white;
}

.header-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.header-breadcrumb-item {
    color: var(--gray-600);
}

.header-breadcrumb-item.active {
    color: var(--gray-900);
    font-weight: 600;
}

.header-breadcrumb-separator {
    color: var(--gray-400);
}

/* Header Center */
.header-center {
    flex: 1;
    max-width: 600px;
}

.header-search {
    position: relative;
    width: 100%;
}

.header-search-input {
    width: 100%;
    padding: 0.625rem 1rem 0.625rem 2.75rem;
    font-size: 0.875rem;
    border: 2px solid var(--gray-300);
    border-radius: 0.5rem;
    transition: all 0.2s ease;
    background: var(--gray-50);
}

.header-search-input:focus {
    outline: none;
    border-color: var(--primary-600);
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.header-search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    pointer-events: none;
}

/* Header Right */
.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-action {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-100);
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    color: var(--gray-700);
}

.header-action:hover {
    background: var(--primary-600);
    color: white;
}

.header-action-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--danger-500);
    color: white;
    font-size: 0.625rem;
    font-weight: 700;
    padding: 0.125rem 0.375rem;
    border-radius: 999px;
    min-width: 18px;
    text-align: center;
    border: 2px solid white;
}

/* === MAIN CONTENT === */
#main {
    margin-left: 280px;
    flex: 1;
    transition: margin-left 0.3s ease;
}

#sidebar.collapsed ~ #main {
    margin-left: 0;
}

#content {
    padding: 2rem;
    max-width: 1600px;
    margin: 0 auto;
}

/* Page Header */
.page-header {
    margin-bottom: 2rem;
}

.page-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.page-title-icon {
    width: 48px;
    height: 48px;
    background: var(--primary-gradient);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
}

.page-description {
    font-size: 1rem;
    color: var(--gray-600);
}

.page-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

/* === RESPONSIVE === */
@media (max-width: 1024px) {
    #sidebar {
        transform: translateX(-280px);
    }
    
    #sidebar.mobile-open {
        transform: translateX(0);
    }
    
    #header,
    #main {
        margin-left: 0;
    }
    
    .header-center {
        display: none;
    }
}

@media (max-width: 768px) {
    /* Sidebar hidden by default on mobile */
    #sidebar {
        transform: translateX(-280px);
    }
    
    /* Show sidebar when active */
    #sidebar.active {
        transform: translateX(0);
    }
    
    /* Adjust header and main content */
    #header {
        margin-left: 0;
        padding: 1rem;
    }
    
    #main {
        margin-left: 0;
    }
    
    #content {
        padding: 1rem;
    }
    
    .page-title {
        font-size: 1.5rem;
    }
    
    .header-breadcrumb {
        display: none;
    }
    
    /* Hide search on mobile */
    .header-center {
        display: none;
    }
}

/* Mobile Overlay */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

@media (max-width: 1024px) {
    .mobile-overlay.active {
        display: block;
    }
}

/* === LOADING STATES === */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary-600);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-skeleton {
    background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100) 50%, var(--gray-200) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 0.5rem;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
