/* ============================================================
   layout.css – Sidebar, Navbar, Main Layout, Responsive
   ============================================================ */

/* ─── App Shell ─── */
.app-view {
    display: flex;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

/* ═══ SIDEBAR (Desktop) ═══ */
.sidebar {
    width: var(--sidebar-w);
    position: fixed;
    top: var(--sp-4);
    left: var(--sp-4);
    bottom: var(--sp-4);
    background: var(--surface-0);
    border: 1px solid var(--surface-200);
    border-radius: var(--r-3xl);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    padding: var(--sp-5);
    z-index: 40;
    transition: transform var(--t-smooth);
}

/* Brand Header */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-2) var(--sp-2) var(--sp-6);
}
.brand-icon {
    width: 36px; height: 36px;
    background: var(--brand-800);
    border-radius: var(--r-xl);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: var(--text-base); font-weight: 900;
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}
.brand-name {
    display: block;
    font-size: var(--text-sm); font-weight: 800;
    color: var(--brand-800); letter-spacing: -0.02em; line-height: 1;
}
.brand-sub {
    display: block;
    font-size: 9px; font-weight: 700;
    color: var(--surface-400); letter-spacing: 0.08em;
    text-transform: uppercase; margin-top: 2px;
}

/* Sidebar User Card */
.sidebar-user {
    background: var(--surface-50);
    border: 1px solid var(--surface-100);
    border-radius: var(--r-2xl);
    padding: var(--sp-3);
    display: flex; align-items: center; gap: var(--sp-3);
    margin-bottom: var(--sp-5);
}
.user-avatar {
    width: 36px; height: 36px; border-radius: var(--r-lg);
    background: var(--surface-200); color: var(--surface-600);
    display: flex; align-items: center; justify-content: center;
    font-size: var(--text-sm); font-weight: 700; text-transform: uppercase;
    flex-shrink: 0;
}
.user-info { min-width: 0; flex: 1; }
.user-email { font-size: var(--text-xs); font-weight: 700; color: var(--surface-800); truncate; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role  { font-size: 10px; font-weight: 600; color: var(--surface-400); margin-top: 2px; }

/* Sidebar Nav */
.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: var(--sp-1); }
.nav-item {
    width: 100%; display: flex; align-items: center; gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--r-xl); font-size: var(--text-sm); font-weight: 600;
    color: var(--surface-500); cursor: pointer;
    transition: all var(--t-base); text-align: left; position: relative;
}
.nav-item:hover { background: var(--surface-50); color: var(--surface-800); }
.nav-item.active { background: var(--surface-100); color: var(--brand-800); }
.nav-item.active::before {
    content: ''; position: absolute;
    left: 0; top: 50%; transform: translateY(-50%);
    width: 3px; height: 20px;
    background: var(--brand-800); border-radius: 0 var(--r-full) var(--r-full) 0;
}
.nav-item .nav-icon { font-size: var(--text-lg); flex-shrink: 0; }

/* Sidebar Footer */
.sidebar-footer {
    padding-top: var(--sp-4);
    border-top: 1px solid var(--surface-100);
    display: flex; flex-direction: column; gap: var(--sp-3);
}
.cloud-status {
    display: flex; align-items: center; justify-content: space-between;
    padding: var(--sp-2) var(--sp-3);
    background: var(--color-success-bg); border: 1px solid var(--color-success-border);
    border-radius: var(--r-xl);
}
.cloud-status-text { font-size: 9px; font-weight: 700; color: #16a34a; text-transform: uppercase; letter-spacing: 0.06em; }
.status-dot {
    width: 6px; height: 6px; border-radius: 50%; position: relative;
}
.status-dot--success { background: var(--color-success); color: var(--color-success); }
.status-dot--success::after {
    content: ''; position: absolute; inset: -2px; border-radius: 50%;
    border: 1.5px solid currentColor; opacity: 0.3;
    animation: pulseSoft 2s ease-in-out infinite;
}
.btn-logout {
    width: 100%; padding: var(--sp-2) var(--sp-4);
    background: var(--surface-50); border: 1px solid var(--surface-100);
    color: var(--surface-600); font-size: var(--text-sm); font-weight: 700;
    border-radius: var(--r-xl); display: flex; align-items: center; justify-content: center; gap: var(--sp-2);
    transition: all var(--t-base);
}
.btn-logout:hover { background: var(--color-danger-bg); border-color: var(--color-danger-border); color: var(--color-danger); }

/* ═══ MAIN WRAPPER ═══ */
.main-wrapper {
    flex: 1;
    margin-left: calc(var(--sidebar-w) + var(--sp-4) * 2);
    display: flex; flex-direction: column; min-width: 0;
}

/* ─── Top Navbar (hidden on desktop, shown on mobile) ─── */
.navbar {
    display: none;
    align-items: center; justify-content: space-between;
    height: var(--navbar-h); padding: 0 var(--sp-4);
    background: var(--surface-0); border-bottom: 1px solid var(--surface-200);
    position: sticky; top: 0; z-index: 30;
}
.navbar-brand { display: flex; align-items: center; gap: var(--sp-3); }
.brand-icon-sm {
    width: 32px; height: 32px; background: var(--brand-800);
    border-radius: var(--r-lg); display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: var(--text-sm); font-weight: 900;
}
.navbar-title { font-size: var(--text-sm); font-weight: 800; color: var(--brand-800); }

/* Hamburger */
.hamburger {
    width: 36px; height: 36px; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 5px;
    background: var(--surface-50); border-radius: var(--r-lg); border: 1px solid var(--surface-200);
}
.hamburger span {
    display: block; width: 16px; height: 2px;
    background: var(--surface-600); border-radius: 2px;
    transition: all var(--t-base);
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Mobile Overlay + Drawer */
.mobile-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.3);
    z-index: 45; backdrop-filter: blur(2px);
    animation: fadeIn 0.2s ease;
}
.mobile-drawer {
    position: fixed; top: 0; left: 0; bottom: 0; width: 280px;
    background: var(--surface-0); z-index: 50;
    padding: var(--sp-6) var(--sp-5);
    display: flex; flex-direction: column; gap: var(--sp-4);
    box-shadow: var(--shadow-xl);
    animation: slideInLeft var(--t-smooth) both;
}
.mobile-drawer-user {
    padding-bottom: var(--sp-4); border-bottom: 1px solid var(--surface-100);
}
.mobile-nav { display: flex; flex-direction: column; gap: var(--sp-1); flex: 1; }

/* ─── Main Content ─── */
.main-content {
    flex: 1; padding: var(--sp-8);
    max-width: 960px; position: relative; z-index: 1;
}

/* ─── Page Sections ─── */
.page-section { animation: slideUp 0.35s cubic-bezier(0.16,1,0.3,1) both; }

/* ─── Bottom Nav (Mobile only) ─── */
.bottom-nav {
    display: none;
    height: var(--bottom-nav-h);
    background: var(--surface-0); border-top: 1px solid var(--surface-200);
    position: sticky; bottom: 0; z-index: 30;
    padding: 0 var(--sp-4); align-items: center; justify-content: space-around;
}
.bottom-nav-item {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: var(--sp-2) var(--sp-3); border-radius: var(--r-xl);
    cursor: pointer; font-size: 10px; font-weight: 600;
    color: var(--surface-400); transition: all var(--t-base); min-width: 60px;
}
.bottom-nav-item .nav-icon { font-size: 20px; }
.bottom-nav-item:hover  { color: var(--brand-600); }
.bottom-nav-item.active { color: var(--brand-500); }
.bottom-nav-item.active .nav-icon { transform: scale(1.1); }

/* ─── Auth View ─── */
.auth-view {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: var(--sp-4); position: relative; z-index: 1;
    background: var(--surface-100);
}
.auth-container { width: 100%; max-width: 400px; }
.auth-card {
    background: var(--surface-0);
    border: 1px solid var(--surface-200);
    border-radius: var(--r-2xl);
    box-shadow: var(--shadow-lg);
    padding: var(--sp-8) var(--sp-10);
    animation: slideUp 0.4s cubic-bezier(0.16,1,0.3,1) both;
}

/* ─── Loading Overlay ─── */
.loading-overlay {
    position: fixed; inset: 0; background: rgba(255,255,255,0.8);
    backdrop-filter: blur(4px); z-index: 9999;
    display: flex; align-items: center; justify-content: center;
}
.loading-spinner {
    width: 36px; height: 36px; border: 3px solid var(--surface-200);
    border-top-color: var(--brand-500); border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

/* ─── Toast Container ─── */
.toast-container {
    position: fixed; top: var(--sp-4); right: var(--sp-4);
    display: flex; flex-direction: column; gap: var(--sp-2);
    z-index: 9999; max-width: 320px; width: 100%;
}

/* ═══ RESPONSIVE ═══ */
@media (max-width: 1024px) {
    .sidebar { display: none; }
    .main-wrapper { margin-left: 0; }
    .navbar { display: flex; }
    .bottom-nav { display: flex; }
    .main-content { padding: var(--sp-4); padding-bottom: calc(var(--bottom-nav-h) + var(--sp-4)); }
}

@media (max-width: 480px) {
    .auth-card { padding: var(--sp-6); }
    .main-content { padding: var(--sp-3); padding-bottom: calc(var(--bottom-nav-h) + var(--sp-3)); }
}
