/* ====================================================
   ProjectHub — Premium Design System v2
   Light/Dark themes, full-width fluid layouts
   ==================================================== */

/* ---------- CSS Custom Properties: DARK (default) ---------- */
:root {
    /* Accent colours */
    --primary: #4F8CFF;
    --primary-hover: #3A75E6;
    --primary-light: rgba(79, 140, 255, .12);
    --primary-glow: rgba(79, 140, 255, .25);
    --accent-green: #34D399;
    --accent-orange: #FBBF24;
    --accent-red: #F87171;
    --accent-purple: #A78BFA;

    /* Surfaces */
    --bg-app: #0B1120;
    --bg-sidebar: #0F172A;
    --bg-card: #151D2E;
    --bg-card-hover: #1A2540;
    --bg-input: #151D2E;
    --bg-topbar: rgba(15, 23, 42, .82);
    --bg-overlay: rgba(0, 0, 0, .55);
    --bg-surface-raised: #1E293B;

    /* Borders */
    --border: rgba(255, 255, 255, .06);
    --border-strong: rgba(255, 255, 255, .12);
    --border-accent: var(--primary);

    /* Text */
    --text-primary: #F1F5F9;
    --text-secondary: #94A3B8;
    --text-tertiary: #64748B;
    --text-inverse: #0B1120;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, .35);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, .45);
    --shadow-glow: 0 0 24px var(--primary-glow);

    /* Radii */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Typography */
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    --font-xs: .7rem;
    --font-sm: .8rem;
    --font-base: .9rem;
    --font-lg: 1.1rem;
    --font-xl: 1.35rem;
    --font-2xl: 1.8rem;
    --font-3xl: 2.4rem;

    /* Transitions */
    --transition-fast: .15s cubic-bezier(.4, 0, .2, 1);
    --transition-base: .25s cubic-bezier(.4, 0, .2, 1);
    --transition-slow: .4s cubic-bezier(.4, 0, .2, 1);

    /* Layout */
    --sidebar-width: 240px;
    --sidebar-collapsed: 72px;
    --topbar-height: 56px;
}

/* ---------- LIGHT theme ---------- */
[data-theme="light"] {
    --bg-app: #F1F5F9;
    --bg-sidebar: #FFFFFF;
    --bg-card: #FFFFFF;
    --bg-card-hover: #F8FAFC;
    --bg-input: #F1F5F9;
    --bg-topbar: rgba(255, 255, 255, .88);
    --bg-overlay: rgba(0, 0, 0, .25);
    --bg-surface-raised: #F8FAFC;

    --border: rgba(0, 0, 0, .08);
    --border-strong: rgba(0, 0, 0, .14);

    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-tertiary: #94A3B8;
    --text-inverse: #F1F5F9;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .06);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, .08);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, .1);
    --shadow-glow: 0 0 24px rgba(79, 140, 255, .12);
}

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background: var(--bg-app);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
    height: 100vh;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    color: var(--primary-hover);
}

hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: var(--space-lg) 0;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

::selection {
    background: var(--primary-light);
    color: var(--primary);
}

/* ---------- App layout ---------- */
.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: width var(--transition-base), min-width var(--transition-base);
    z-index: 200;
    position: relative;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
    min-width: var(--sidebar-collapsed);
}

.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .user-details,
.sidebar.collapsed .user-info>span:last-child {
    display: none;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: var(--space-sm) 0;
}

.sidebar.collapsed .user-info {
    justify-content: center;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    height: var(--topbar-height);
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.logo-icon {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, var(--primary), var(--accent-purple));
    color: #fff;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: var(--font-lg);
}

.logo-text {
    font-size: var(--font-lg);
    font-weight: 700;
    color: var(--text-primary);
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--space-xs);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.sidebar-toggle:hover {
    color: var(--text-primary);
    background: var(--bg-card-hover);
}

.sidebar-nav {
    flex: 1;
    padding: var(--space-md) var(--space-sm);
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 10px var(--space-md);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: var(--font-sm);
    font-weight: 500;
    transition: all var(--transition-fast);
    cursor: pointer;
    text-decoration: none;
}

.nav-item:hover {
    background: var(--primary-light);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.nav-item .material-icons-outlined {
    font-size: 20px;
}

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding: var(--space-sm);
    position: relative;
}

.user-info {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.user-info:hover {
    background: var(--bg-card-hover);
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary), var(--accent-purple));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-xs);
    font-weight: 700;
    flex-shrink: 0;
}

.user-details {
    flex: 1;
    min-width: 0;
}

.user-name {
    display: block;
    font-size: var(--font-sm);
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.user-role {
    display: block;
    font-size: var(--font-xs);
    color: var(--text-tertiary);
    text-transform: capitalize;
}

.user-menu {
    position: absolute;
    bottom: 100%;
    left: var(--space-sm);
    right: var(--space-sm);
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: var(--space-xs);
    z-index: 300;
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: var(--font-sm);
    background: none;
    border: none;
    width: 100%;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.user-menu-item:hover {
    background: var(--primary-light);
    color: var(--text-primary);
}

.user-menu-item .material-icons-outlined {
    font-size: 18px;
}

/* ---------- Main Content ---------- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* ---------- Topbar ---------- */
.topbar {
    height: var(--topbar-height);
    min-height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-xl);
    background: var(--bg-topbar);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    z-index: 50;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.page-title {
    font-size: var(--font-lg);
    font-weight: 700;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.topbar-search {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: 6px var(--space-md);
    transition: border-color var(--transition-fast);
    width: 220px;
}

.topbar-search:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.topbar-search input {
    border: none;
    outline: none;
    background: transparent;
    color: var(--text-primary);
    font-size: var(--font-sm);
    width: 100%;
}

.topbar-search input::placeholder {
    color: var(--text-tertiary);
}

.topbar-search .material-icons-outlined {
    font-size: 18px;
    color: var(--text-tertiary);
}

.topbar-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

.topbar-btn:hover {
    background: var(--primary-light);
    color: var(--text-primary);
}

.topbar-btn .material-icons-outlined {
    font-size: 20px;
}

/* Theme toggle */
.theme-toggle {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.theme-toggle:hover {
    background: var(--primary-light);
    color: var(--accent-orange);
}

.notification-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--accent-red);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

.topbar-timer {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    background: rgba(52, 211, 153, .12);
    color: var(--accent-green);
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: var(--font-sm);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    animation: pulse-green 2s infinite;
}

@keyframes pulse-green {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(52, 211, 153, .3)
    }

    50% {
        box-shadow: 0 0 0 6px rgba(52, 211, 153, 0)
    }
}

.timer-stop-btn {
    background: none;
    border: none;
    color: var(--accent-red);
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 2px;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.timer-stop-btn:hover {
    background: rgba(248, 113, 113, .15);
}

.timer-stop-btn .material-icons-outlined {
    font-size: 16px;
}

.topbar-timer .material-icons-outlined {
    font-size: 16px;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--space-xs);
}

/* ---------- Page Content ---------- */
.page-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-xl);
}

/* ---------- Page Header ---------- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
    flex-wrap: wrap;
}

.page-header-left {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.page-header-left h2 {
    font-size: var(--font-xl);
    font-weight: 700;
}

.page-header-left .subtitle {
    font-size: var(--font-sm);
    color: var(--text-tertiary);
    margin-left: var(--space-sm);
}

/* ---------- Notification Panel ---------- */
.notification-panel {
    position: absolute;
    top: var(--topbar-height);
    right: var(--space-xl);
    width: 380px;
    max-height: 500px;
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    z-index: 400;
    overflow: hidden;
}

.notification-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border);
}

.notification-header h3 {
    font-size: var(--font-base);
    font-weight: 600;
}

.notification-header button {
    background: none;
    border: none;
    color: var(--primary);
    font-size: var(--font-sm);
    cursor: pointer;
}

.notification-list {
    overflow-y: auto;
    flex: 1;
}

.notification-item {
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.notification-item:hover {
    background: var(--bg-card-hover);
}

.notification-item.unread {
    border-left: 3px solid var(--primary);
}

.notif-title {
    font-size: var(--font-sm);
    font-weight: 600;
}

.notif-message {
    font-size: var(--font-xs);
    color: var(--text-secondary);
    margin-top: 2px;
}

.notif-time {
    font-size: var(--font-xs);
    color: var(--text-tertiary);
    margin-top: 4px;
}

/* ---------- Auth Pages ---------- */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-app);
    padding: var(--space-xl);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: var(--space-2xl);
    box-shadow: var(--shadow-lg);
}

.auth-logo {
    text-align: center;
    margin-bottom: var(--space-xl);
}

.auth-logo h1 {
    font-size: var(--font-2xl);
    font-weight: 800;
    margin-top: var(--space-sm);
}

.auth-logo p {
    color: var(--text-tertiary);
    font-size: var(--font-sm);
    margin-top: var(--space-xs);
}

.auth-logo .logo-icon {
    width: 52px;
    height: 52px;
    font-size: var(--font-xl);
    margin: 0 auto;
    border-radius: var(--radius-md);
}

/* ---------- Modal ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    padding: var(--space-xl);
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    animation: modalIn .2s ease-out;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(.96) translateY(8px);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-lg) var(--space-xl);
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: var(--font-lg);
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: var(--space-xs);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-card-hover);
}

.modal-body {
    padding: var(--space-xl);
    overflow-y: auto;
}

/* ---------- Slide Panel ---------- */
.slide-panel-overlay {
    position: fixed;
    inset: 0;
    z-index: 400;
}

.slide-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(580px, 90vw);
    background: var(--bg-card);
    border-left: 1px solid var(--border-strong);
    box-shadow: var(--shadow-lg);
    overflow-y: auto;
    z-index: 401;
    animation: slideIn .25s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
    }
}

.slide-panel-content {
    padding: var(--space-xl);
}

/* ---------- Toast ---------- */
.toast-container {
    position: fixed;
    top: var(--space-lg);
    right: var(--space-lg);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: var(--font-sm);
    min-width: 280px;
    animation: toastIn .3s ease-out;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(24px);
    }
}

.toast.success {
    border-left: 3px solid var(--accent-green);
}

.toast.error {
    border-left: 3px solid var(--accent-red);
}

.toast.info {
    border-left: 3px solid var(--primary);
}

/* ---------- Empty / Loading States ---------- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-2xl);
    text-align: center;
    color: var(--text-tertiary);
    min-height: 200px;
}

.empty-state .material-icons-outlined {
    font-size: 48px;
    margin-bottom: var(--space-md);
    opacity: .4;
}

.empty-state p {
    font-size: var(--font-sm);
}

.loading-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        left: -260px;
        transition: left var(--transition-base);
        box-shadow: none;
    }

    .sidebar.mobile-open {
        left: 0;
        box-shadow: var(--shadow-lg);
    }

    .mobile-menu-btn {
        display: flex;
        align-items: center;
    }

    .page-content {
        padding: var(--space-lg);
    }

    .topbar {
        padding: 0 var(--space-lg);
    }

    .topbar-search {
        display: none;
    }
}

@media (max-width: 640px) {
    .page-content {
        padding: var(--space-md);
    }

    .notification-panel {
        width: calc(100vw - 32px);
        right: var(--space-md);
    }
}