/* ===== Fluent 2 Layout ===== */

.app-layout {
    display: grid;
    grid-template-rows: 1fr;
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-areas:
        "sidebar main";
    min-height: 100vh;
}

/* --- Header (mobile only — hidden on desktop) --- */
.app-header {
    grid-area: header;
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: var(--acrylic-bg);
    backdrop-filter: var(--acrylic-blur);
    -webkit-backdrop-filter: var(--acrylic-blur);
    border-bottom: 1px solid var(--color-highlight-border);
    z-index: 100;
    height: var(--header-height);
}
.app-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.sidebar-toggle {
    display: none;
    padding: 6px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 20px;
    border-radius: var(--radius-sm);
    color: var(--color-text-secondary);
}
.sidebar-toggle:hover { background: rgba(0, 0, 0, 0.05); }
.app-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* --- Profile dropdown --- */
.profile-menu {
    position: relative;
}
.profile-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: var(--radius);
    transition: background var(--transition-fast);
}
.profile-trigger:hover { background: rgba(0, 0, 0, 0.05); }
.profile-trigger .name { font-size: 13px; font-weight: 500; }
.profile-trigger .role { font-size: 11px; color: var(--color-text-secondary); }
.profile-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 200px;
    background: var(--acrylic-bg);
    backdrop-filter: var(--acrylic-blur);
    -webkit-backdrop-filter: var(--acrylic-blur);
    border: 1px solid var(--color-highlight-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    padding: 4px;
    z-index: 200;
    display: none;
    animation: flyoutIn 200ms cubic-bezier(0.33, 0, 0.67, 1);
}
.profile-dropdown.open { display: block; }
.profile-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: transparent;
    text-align: left;
    font-size: 13px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    color: var(--color-text);
    transition: background var(--transition-fast);
}
.profile-dropdown-item:hover { background: rgba(0, 0, 0, 0.05); }
.profile-dropdown-item.danger { color: var(--color-danger); }
.profile-dropdown-item i { font-size: 16px; }

@keyframes flyoutIn {
    from { transform: translateY(-4px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* --- Notification bell --- */
.notification-bell {
    position: relative;
}
.notification-bell .btn-icon {
    position: relative;
    color: var(--color-text-secondary);
    font-size: 18px;
}
.notification-bell .btn-icon:hover { color: var(--color-text); }
.notif-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--color-danger);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    line-height: 16px;
    text-align: center;
}
.notif-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    width: 340px;
    max-height: 420px;
    background: var(--color-surface);
    border: 1px solid var(--color-highlight-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: 200;
    display: none;
    overflow: hidden;
    animation: flyoutIn 200ms cubic-bezier(0.33, 0, 0.67, 1);
}
.notif-dropdown.open { display: flex; flex-direction: column; }
.notif-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    border-bottom: 1px solid var(--color-border);
    font-size: 13px;
}
.notif-list {
    overflow-y: auto;
    flex: 1;
}
.notif-item {
    padding: 10px 12px;
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
    font-size: 13px;
    transition: background var(--transition-fast);
}
.notif-item:hover { background: rgba(0, 0, 0, 0.04); }
.notif-item.unread { background: var(--color-primary-light); }
.notif-item.unread:hover { background: #cfe0f4; }
.notif-title { font-weight: 500; margin-bottom: 2px; }
.notif-msg { color: var(--color-text-secondary); font-size: 12px; }
.notif-time { color: var(--color-text-secondary); font-size: 11px; margin-top: 4px; }

/* --- Sidebar (acrylic navigation) --- */
.app-sidebar {
    grid-area: sidebar;
    display: flex;
    flex-direction: column;
    background: var(--acrylic-bg);
    backdrop-filter: var(--acrylic-blur);
    -webkit-backdrop-filter: var(--acrylic-blur);
    border-right: 1px solid var(--color-highlight-border);
    padding: 0;
    /* NO overflow-y here — would clip the app launcher menu (position: absolute) */
}

/* --- Sidebar brand (top) --- */
.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}
.sidebar-brand-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.sidebar-brand-name i {
    font-size: 20px;
}

/* --- App launcher --- */
.app-launcher {
    position: relative;
    margin-left: auto;
    flex-shrink: 0;
}
.app-launcher-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    color: var(--color-text-secondary);
    font-size: 1.2rem;
    transition: background var(--transition-fast), color var(--transition-fast);
}
.app-launcher-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--color-text);
}
.app-launcher-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: auto;
    margin-top: 4px;
    background: var(--color-surface-solid);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    z-index: 1100;
    padding: 12px;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 4px;
    width: 340px;
    max-height: 400px;
    overflow-y: auto;
}
.app-launcher-menu.open {
    display: grid;
}
.app-launcher-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px 6px;
    border-radius: var(--radius-sm);
    text-align: center;
    text-decoration: none;
    color: var(--color-text);
    transition: background var(--transition-fast);
}
.app-launcher-item:hover {
    background: rgba(0, 120, 212, 0.06);
    text-decoration: none;
}
.app-launcher-icon {
    width: 48px;
    height: 48px;
    background: var(--color-primary-light);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.app-launcher-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.app-launcher-icon i {
    font-size: 24px;
    color: var(--color-primary);
}
.app-launcher-label {
    font-size: .7rem;
    font-weight: 500;
    line-height: 1.2;
    max-width: 72px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- Sidebar footer (user profile) --- */
.sidebar-footer {
    flex-shrink: 0;
    border-top: 1px solid var(--color-border);
    padding: 8px 12px;
    position: relative;
    margin-top: auto;
}
.sidebar-user-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--color-text);
    font-size: 13px;
    cursor: pointer;
    transition: background var(--transition-fast);
    text-align: left;
}
.sidebar-user-btn:hover {
    background: rgba(0, 120, 212, 0.06);
}
.sidebar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    background: var(--color-primary-light);
    color: var(--color-primary);
    flex-shrink: 0;
    object-fit: cover;
}
img.sidebar-user-avatar {
    background: none;
}
.sidebar-user-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.sidebar-user-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user-role {
    font-size: 11px;
    color: var(--color-text-secondary);
}
.sidebar-user-dropdown {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 8px;
    right: 8px;
    margin-bottom: 4px;
    background: var(--color-surface-solid);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.1);
    padding: 4px;
    z-index: 210;
}
.sidebar-user-dropdown.open {
    display: block;
}
.sidebar-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: transparent;
    text-align: left;
    font-size: 13px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    color: var(--color-text);
    transition: background var(--transition-fast);
}
.sidebar-dropdown-item:hover {
    background: rgba(0, 0, 0, 0.05);
}
.sidebar-dropdown-item i {
    font-size: 16px;
}
.nav-section {
    padding: 16px 12px;
    margin-bottom: 0;
    flex: 1;
    overflow-y: auto;
}
.nav-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--color-text-secondary);
    padding: 0 8px;
    margin-bottom: 4px;
    letter-spacing: 0.04em;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--color-text);
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    position: relative;
    transition: background var(--transition-fast);
}
.nav-item i {
    font-size: 18px;
    width: 20px;
    text-align: center;
    color: var(--color-text-secondary);
}
.nav-item:hover {
    background: rgba(0, 0, 0, 0.04);
    text-decoration: none;
}
.nav-item.active {
    background: var(--color-primary-light);
    color: var(--color-primary);
    font-weight: 500;
}
.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 6px;
    bottom: 6px;
    width: 3px;
    border-radius: 2px;
    background: var(--color-primary);
}
.nav-item.active i {
    color: var(--color-primary);
}

/* --- Main content --- */
.app-main {
    grid-area: main;
    padding: 24px;
    overflow-y: auto;
}
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-filters {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.page-filters input, .page-filters select {
    max-width: 200px;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .app-layout {
        grid-template-rows: var(--header-height) 1fr;
        grid-template-columns: 1fr;
        grid-template-areas:
            "header"
            "main";
    }

    .app-header { display: flex; }
    .sidebar-toggle { display: flex; align-items: center; }

    .app-sidebar {
        position: fixed;
        top: var(--header-height);
        left: 0;
        bottom: 0;
        width: var(--sidebar-width);
        transform: translateX(-100%);
        transition: transform var(--transition);
        z-index: 90;
    }
    .app-sidebar.open {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        top: var(--header-height);
        background: rgba(0, 0, 0, 0.3);
        z-index: 80;
    }
    .sidebar-backdrop.open { display: block; }

    .app-main { padding: 16px; }
    .page-header { flex-direction: column; align-items: flex-start; }
}

/* ===== Login page (Fluent 2 welcome) ===== */
.login-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #d6e4ff 0%, #e8edf5 40%, #f0f4ff 100%);
    position: relative;
    overflow: hidden;
}
.login-layout::before {
    content: '';
    position: absolute;
    top: -30%;
    right: -20%;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 120, 212, 0.08) 0%, transparent 70%);
    pointer-events: none;
}
.login-card {
    background: var(--acrylic-bg);
    backdrop-filter: var(--acrylic-blur);
    -webkit-backdrop-filter: var(--acrylic-blur);
    border: 1px solid var(--color-highlight-border);
    border-radius: var(--radius-xl);
    padding: 48px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-xl);
    text-align: center;
    animation: modalSlideIn 400ms cubic-bezier(0.33, 0, 0.67, 1);
}
.login-card .login-icon {
    font-size: 48px;
    color: var(--color-primary);
    margin-bottom: 12px;
}
.login-card .logo {
    font-size: 28px;
    font-weight: 600;
    color: var(--color-primary);
    margin-bottom: 4px;
    letter-spacing: -0.02em;
}
.login-card .subtitle {
    color: var(--color-text-secondary);
    margin-bottom: 12px;
    font-size: 14px;
}
.login-card .welcome-text {
    color: var(--color-text-secondary);
    margin-bottom: 32px;
    font-size: 13px;
}
.login-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 4px 0 16px;
    color: var(--color-text-secondary);
    font-size: 12px;
}
.login-divider::before,
.login-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--color-border-strong);
}
.login-card .btn {
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 14px;
    margin-bottom: 12px;
    border-radius: var(--radius);
}
.login-card .btn svg, .login-card .btn img {
    width: 20px;
    height: 20px;
}
