/* --- Layout --- */
#app {
    min-height: 100vh;
}

.app-layout {
    display: flex;
    min-height: calc(100vh - var(--navbar-height));
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 32px;
    min-height: calc(100vh - var(--navbar-height));
    max-width: calc(100% - var(--sidebar-width));
}

/* --- Navbar --- */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--navbar-height);
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px 0 0;
    box-shadow: var(--shadow-sm);
}

.navbar-brand {
    display: flex;
    align-items: center;
    width: var(--sidebar-width);
    height: 100%;
    padding: 0 24px;
    background: var(--sidebar-bg);
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.025em;
}
.navbar-brand span {
    color: #A5B4FC;
}

/* Navbar Plan */
.navbar-plan {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 20px;
    background: linear-gradient(135deg, #EEF2FF, #E0E7FF);
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid #C7D2FE;
}
.navbar-plan-icon {
    width: 22px;
    height: 22px;
}
.navbar-plan-label {
    color: #6B7280;
    font-size: 0.75rem;
    font-weight: 500;
}
.navbar-plan-name {
    font-weight: 700;
    font-size: 0.85rem;
    color: #4F46E5;
}
.navbar-plan-upgrade {
    color: #4F46E5;
    font-size: 0.7rem;
    font-weight: 600;
    margin-left: 2px;
    padding: 2px 8px;
    background: rgba(79, 70, 229, 0.1);
    border-radius: 10px;
    transition: background 0.2s;
    text-decoration: none;
}
.navbar-plan-upgrade:hover {
    background: rgba(79, 70, 229, 0.2);
}

/* Navbar Notifications Bell */
.navbar-bell {
    position: relative;
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 8px;
    margin-right: 4px;
    line-height: 1;
    border-radius: 50%;
    transition: background 0.2s;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.navbar-bell:hover {
    background: #F3F4F6;
}
.navbar-chat-badge {
    position: relative;
    cursor: pointer;
    font-size: 1.1rem;
    text-decoration: none;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}
.navbar-chat-badge:hover {
    background: #F3F4F6;
}
.navbar-bell-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--error);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* Notifications Dropdown */
.navbar-notifications-dropdown {
    position: absolute;
    top: var(--navbar-height);
    right: 80px;
    width: 340px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    overflow: hidden;
}
.navbar-notif-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}
.navbar-notif-mark {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.75rem;
    cursor: pointer;
}
.navbar-notif-list {
    max-height: 300px;
    overflow-y: auto;
}
.navbar-notif-empty {
    padding: 24px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
}
.navbar-notif-item {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: background 0.15s;
}
.navbar-notif-item:hover { background: var(--bg); }
.navbar-notif-item.unread { background: #FEFCE8; }
.navbar-notif-title { font-size: 0.85rem; color: var(--text); }
.navbar-notif-time { font-size: 0.7rem; color: var(--text-secondary); margin-top: 2px; }
.navbar-notif-all {
    display: block;
    text-align: center;
    padding: 10px;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--primary);
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.navbar-hamburger {
    display: none;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-left: 16px;
}
.navbar-hamburger:hover {
    background: var(--border-light);
}

.user-menu {
    position: relative;
}

.user-menu-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    border-radius: var(--radius);
    transition: background var(--transition);
    cursor: pointer;
}
.user-menu-trigger:hover {
    background: var(--border-light);
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-full);
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
}

/* Profile avatar upload overlay */
.profile-avatar-overlay {
    opacity: 0 !important;
    transition: opacity 0.2s;
}
label:hover .profile-avatar-overlay {
    opacity: 1 !important;
}

.user-menu-info {
    text-align: left;
}
.user-menu-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
}
.user-menu-email {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.user-menu-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    z-index: 200;
}
.user-menu-dropdown a,
.user-menu-dropdown button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 12px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    text-align: left;
}
.user-menu-dropdown a:hover,
.user-menu-dropdown button:hover {
    background: var(--border-light);
    color: var(--text);
}
.user-menu-dropdown .divider {
    height: 1px;
    background: var(--border);
    margin: 6px 0;
}
.user-menu-dropdown .logout-btn {
    color: var(--error);
}
.user-menu-dropdown .logout-btn:hover {
    background: var(--error-bg);
    color: var(--error);
}

/* --- Sidebar --- */
.sidebar {
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    overflow-y: auto;
    z-index: 90;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
}

.sidebar-section {
    margin-bottom: 8px;
}

.sidebar-section-title {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(255,255,255,0.35);
    padding: 8px 12px 6px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: var(--sidebar-text);
    font-size: 0.875rem;
    font-weight: 400;
    transition: all var(--transition);
    margin-bottom: 2px;
}
.sidebar-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
}
.sidebar-link.active {
    background: var(--sidebar-active);
    color: #fff;
    font-weight: 500;
}
.sidebar-link .icon {
    width: 20px;
    text-align: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.sidebar-badge {
    margin-left: auto;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 10px;
    line-height: 1.4;
}
.sidebar-link-locked {
    opacity: 0.5;
}
.sidebar-lock {
    margin-left: auto;
    font-size: 11px;
}

.sidebar-submenu {
    padding-left: 20px;
}
.sidebar-submenu .sidebar-link {
    font-size: 0.8125rem;
    padding: 7px 12px;
}

.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    cursor: pointer;
}
.sidebar-toggle .chevron {
    font-size: 0.625rem;
    transition: transform var(--transition);
    color: rgba(255,255,255,0.35);
}
.sidebar-toggle.expanded .chevron {
    transform: rotate(90deg);
}

.sidebar-plan {
    padding: 16px;
    margin: 12px;
    border-radius: var(--radius);
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
}
.sidebar-plan-label {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(255,255,255,0.4);
    margin-bottom: 4px;
}
.sidebar-plan-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: #fff;
}
.sidebar-plan a {
    font-size: 0.75rem;
    color: #A5B4FC;
    margin-top: 8px;
    display: inline-block;
}

.sidebar-legal {
    padding: 12px 24px;
    display: flex;
    gap: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-legal a {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.35);
    text-decoration: none;
    transition: color 0.2s;
}

.sidebar-legal a:hover {
    color: rgba(255, 255, 255, 0.6);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .navbar-brand {
        width: auto;
        padding: 0 16px;
    }
    .navbar-hamburger {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }
    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 80;
    }

    .main-content {
        margin-left: 0;
        max-width: 100%;
        padding: 20px 16px;
    }
    .navbar-plan {
        display: none;
    }
    .navbar-right {
        gap: 8px;
    }
    .table-container {
        overflow-x: auto;
    }
}
