/* ============================================
   DESIGN TOKENS - Dark Theme (Default)
   ============================================ */
:root {
    /* Backgrounds */
    --bg: oklch(0.18 0.01 60);
    --bg-elev: oklch(0.22 0.012 60);
    --bg-card: oklch(0.25 0.014 60);
    --bg-card-hi: oklch(0.28 0.016 60);
    --bg-input: oklch(0.21 0.012 60);
    
    /* Borders */
    --border: oklch(0.32 0.016 60);
    --border-hi: oklch(0.42 0.02 60);
    --line: oklch(0.28 0.014 60);
    
    /* Text */
    --fg: oklch(0.96 0.008 80);
    --fg-dim: oklch(0.78 0.012 70);
    --fg-muted: oklch(0.60 0.012 70);
    --fg-faint: oklch(0.45 0.012 70);
    
    /* State Colors */
    --ok: oklch(0.72 0.15 230);
    --warn: oklch(0.82 0.17 85);
    --over: oklch(0.68 0.22 25);
    --pause: oklch(0.62 0.01 70);
    --success: oklch(0.74 0.15 155);
    
    /* UI Colors */
    --blue: oklch(0.72 0.15 230);
    --amber: oklch(0.82 0.17 85);
    --red: oklch(0.68 0.22 25);
    --violet: oklch(0.68 0.18 290);
    --green: oklch(0.74 0.15 155);
    
    /* Shadows */
    --shadow-card: 0 1px 0 oklch(1 0 0 / 0.05) inset, 0 4px 14px oklch(0 0 0 / 0.25);
    --shadow-pop: 0 1px 0 oklch(1 0 0 / 0.06) inset, 0 20px 50px oklch(0 0 0 / 0.45);
    
    /* Radii */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    
    /* Density (Regular default) */
    --density-gap: 14px;
    --density-pad: 18px;
    --timer-size: 44px;
    
    /* Accent Color (default blue) */
    --accent: var(--blue);
}

/* Light Theme */
[data-theme="light"] {
    --bg: oklch(0.96 0.006 80);
    --bg-elev: oklch(0.98 0.004 80);
    --bg-card: oklch(1 0 0 0);
    --bg-card-hi: oklch(0.96 0.008 80);
    --bg-input: oklch(0.96 0.008 80);
    --border: oklch(0.85 0.012 80);
    --border-hi: oklch(0.70 0.02 80);
    --line: oklch(0.90 0.008 80);
    --fg: oklch(0.18 0.01 60);
    --fg-dim: oklch(0.32 0.012 60);
    --fg-muted: oklch(0.50 0.012 70);
    --fg-faint: oklch(0.65 0.012 70);
    --shadow-card: 0 1px 0 oklch(0 0 0 / 0.05) inset, 0 4px 12px oklch(0 0 0 / 0.08);
}

/* Accent Variations */
[data-accent="teal"] { --accent: oklch(0.65 0.12 190); }
[data-accent="violet"] { --accent: oklch(0.68 0.18 290); }
[data-accent="rose"] { --accent: oklch(0.72 0.16 20); }

/* Density Variations */
[data-density="compact"] {
    --density-gap: 10px;
    --density-pad: 14px;
    --timer-size: 38px;
}
[data-density="comfy"] {
    --density-gap: 18px;
    --density-pad: 22px;
    --timer-size: 52px;
}

/* ============================================
   GLOBAL RESET & TYPOGRAPHY
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'IBM Plex Sans Arabic', sans-serif;
    background: var(--bg);
    color: var(--fg);
    font-size: 15px;
    line-height: 1.5;
}

/* Font for numbers & timers */
.tabular-nums, .stat-value, .timer-digits, .session-number {
    font-family: 'JetBrains Mono', monospace;
    font-variant-numeric: tabular-nums;
}

/* ============================================
   APP CONTAINER
   ============================================ */
.app-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

/* ============================================
   TOPBAR
   ============================================ */
.topbar {
    background: var(--bg-elev);
    border-radius: var(--radius-xl);
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--accent), oklch(0.55 0.18 280));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-icon span {
    color: white;
    font-size: 24px;
    font-weight: 700;
}

.brand-text h1 {
    font-size: 20px;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
}

.brand-text span {
    font-size: 12px;
    color: var(--fg-muted);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.datetime {
    text-align: left;
}

.clock {
    font-family: 'JetBrains Mono', monospace;
    font-size: 22px;
    font-weight: 600;
    letter-spacing: 2px;
}

.date {
    font-size: 12px;
    color: var(--fg-muted);
}

.sound-toggle {
    width: 40px;
    height: 40px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--fg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.sound-toggle:hover {
    background: var(--bg-card-hi);
    border-color: var(--border-hi);
}

/* ============================================
   STATS STRIP
   ============================================ */
.stats {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: var(--density-gap);
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-elev);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    border: 1px solid var(--border);
}

.stat-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.stat-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.stat-dot.blue { background: var(--blue); }
.stat-dot.amber { background: var(--amber); }
.stat-dot.red { background: var(--red); }
.stat-dot.violet { background: var(--violet); }
.stat-dot.green { background: var(--green); }

.stat-dot.pulse {
    animation: pulse-dot 1.5s infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.2); }
}

.stat-label {
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--fg-muted);
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
}

/* Responsive Stats */
@media (max-width: 900px) {
    .stats {
        grid-template-columns: repeat(3, 1fr);
    }
}
@media (max-width: 560px) {
    .stats {
        grid-template-columns: repeat(2, 1fr);
    }
    .stat-card:last-child {
        grid-column: span 2;
    }
}

/* ============================================
   MAIN LAYOUT
   ============================================ */
.main-layout {
    display: flex;
    gap: 20px;
}

/* Sidebar */
.sidebar {
    width: 320px;
    flex-shrink: 0;
    background: var(--bg-elev);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    padding: 20px;
    height: fit-content;
}

.form-section h3, .queue-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--fg-dim);
}

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 12px;
    color: var(--fg-muted);
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    color: var(--fg);
    font-family: inherit;
    font-size: 14px;
    transition: all 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent);
}

.form-row.two-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.duration-display {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--fg-dim);
}

.error-message {
    color: var(--red);
    font-size: 12px;
    margin: 8px 0;
    min-height: 32px;
}

.btn-primary, .btn-secondary {
    width: 100%;
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius);
    font-family: inherit;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    filter: brightness(1.1);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--fg);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-card-hi);
}

.form-hint {
    font-size: 12px;
    color: var(--fg-muted);
    text-align: center;
    margin-top: 12px;
}

/* Queue List */
.queue-list {
    margin-top: 20px;
    max-height: 400px;
    overflow-y: auto;
}

.queue-item {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 10px;
    border: 1px solid var(--border);
}

.queue-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.queue-index {
    background: var(--violet);
    color: white;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
}

.queue-actions {
    display: flex;
    gap: 8px;
}

.queue-actions button {
    background: none;
    border: none;
    color: var(--fg-muted);
    cursor: pointer;
    padding: 4px;
}

.queue-actions button:hover {
    color: var(--accent);
}

.queue-name {
    font-weight: 600;
    margin-bottom: 4px;
}

.queue-meta {
    font-size: 12px;
    color: var(--fg-muted);
    display: flex;
    gap: 12px;
}

.queue-wait {
    color: var(--violet);
    font-family: 'JetBrains Mono', monospace;
}

.queue-wait.amber {
    color: var(--amber);
}

.empty-queue {
    text-align: center;
    padding: 40px 20px;
    color: var(--fg-muted);
}

/* Content Area */
.content {
    flex: 1;
    min-width: 0;
}

/* Cards Grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--density-gap);
    margin-bottom: 30px;
}

.session-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: var(--density-pad);
    transition: all 0.3s ease-out;
    animation: cardEnter 0.3s ease-out;
}

@keyframes cardEnter {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.session-card[data-state="over"] {
    animation: over-flash 1.8s infinite;
    position: relative;
}

@keyframes over-flash {
    0%, 100% {
        box-shadow: 0 0 0 0 var(--over);
    }
    50% {
        box-shadow: 0 0 0 4px var(--over);
    }
}

.session-card[data-state="pause"] {
    opacity: 0.75;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.session-number {
    font-size: 40px;
    font-weight: 700;
    line-height: 1;
}

.session-number::before {
    content: '#';
    font-size: 18px;
    font-weight: 400;
    opacity: 0.5;
    margin-left: 4px;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 4px 8px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.card-body {
    margin-bottom: 16px;
}

.customer-name {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 6px;
}

.customer-meta {
    font-size: 12px;
    font-family: 'JetBrains Mono', monospace;
    color: var(--fg-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.timer-block {
    background: var(--bg-input);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 16px;
}

.timer-digits {
    font-size: var(--timer-size);
    font-weight: 700;
    text-align: center;
    letter-spacing: 2px;
    font-family: 'JetBrains Mono', monospace;
}

.timer-progress {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 8px 0;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    transition: width 0.3s linear;
}

.timer-sub {
    font-size: 11px;
    color: var(--fg-muted);
    text-align: center;
}

.card-actions {
    display: flex;
    gap: 8px;
}

.card-actions button {
    flex: 1;
    padding: 8px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
    font-weight: 500;
    font-size: 12px;
    transition: all 0.2s;
}

.btn-pause {
    background: var(--bg-card-hi);
    color: var(--fg);
}

.btn-finish {
    background: var(--success);
    color: white;
}

.btn-delete {
    background: var(--red);
    color: white;
}

/* Finished Log */
.log-wrap {
    background: var(--bg-elev);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    padding: 20px;
}

.log-wrap h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
}

.finished-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.finished-table th,
.finished-table td {
    padding: 10px 8px;
    text-align: right;
    border-bottom: 1px solid var(--line);
}

.finished-table th {
    color: var(--fg-muted);
    font-weight: 500;
}

.actual-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    font-size: 11px;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: oklch(0 0 0 / 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-elev);
    border-radius: var(--radius-xl);
    width: 400px;
    max-width: 90%;
    border: 1px solid var(--border);
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--fg-muted);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--line);
    display: flex;
    gap: 12px;
}

/* Tweaks Panel */
.tweaks-panel {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 100;
}

.tweaks-toggle {
    width: 48px;
    height: 48px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--shadow-pop);
}

.tweaks-content {
    position: absolute;
    bottom: 60px;
    left: 0;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    width: 240px;
    backdrop-filter: blur(10px);
}

.tweak-group {
    margin-bottom: 14px;
}

.tweak-group label {
    display: block;
    font-size: 12px;
    margin-bottom: 6px;
    color: var(--fg-dim);
}

.tweak-group select,
.tweak-group input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 8px;
    color: var(--fg);
}

/* Responsive */
@media (max-width: 900px) {
    .main-layout {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
    }
    
    .cards-grid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    }
}

@media (max-width: 560px) {
    .cards-grid {
        grid-template-columns: 1fr;
    }
    
    .table-responsive {
        overflow-x: auto;
    }
    
    .finished-table {
        min-width: 600px;
    }
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--fg-muted);
    background: var(--bg-elev);
    border-radius: var(--radius-lg);
}

/* Additional styles for finished log pills */
.actual-pill.over-pill {
    background: var(--over);
    color: white;
}

.actual-pill.short-pill {
    background: var(--amber);
    color: white;
}

/* Icons styling */
.card-actions button i,
.queue-actions button i,
.btn-pause i,
.btn-finish i,
.btn-delete i {
    margin-left: 6px;
}

/* Better scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-input);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border-hi);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--fg-muted);
}

/* Loading state */
body.loading {
    opacity: 0.5;
    pointer-events: none;
}

/* Focus visible for accessibility */
button:focus-visible,
input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
/* Duration input group */
.duration-input-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.duration-input-group input {
    flex: 2;
}

.duration-input-group select {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 8px;
    color: var(--fg);
    font-family: inherit;
    cursor: pointer;
}

.duration-input-group select:focus {
    outline: none;
    border-color: var(--accent);
}

/* ============================================
   User Menu Styles - ссм Top Bar
   ============================================ */

.user-menu {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--bg-card);
    padding: 6px 16px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.user-name {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--fg-dim);
    font-size: 14px;
    font-weight: 500;
}

    .user-name i {
        font-size: 18px;
        color: var(--accent);
    }

.menu-link {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--fg-dim);
    text-decoration: none;
    font-size: 13px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

    .menu-link:hover {
        background: var(--bg-card-hi);
        color: var(--fg);
        text-decoration: none;
    }

.logout-form {
    margin: 0;
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--over);
    font-size: 13px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

    .logout-btn:hover {
        background: var(--bg-card-hi);
    }

.login-link {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--accent);
    color: white;
    padding: 8px 20px;
    border-radius: var(--radius-lg);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
}

    .login-link:hover {
        filter: brightness(1.1);
        color: white;
        text-decoration: none;
    }

/* ============================================
   Responsive for Top Bar
   ============================================ */

@media (max-width: 768px) {
    .topbar {
        flex-direction: column;
        gap: 12px;
    }

    .user-menu {
        width: 100%;
        justify-content: space-between;
    }

    .topbar-left {
        width: 100%;
        justify-content: space-between;
    }

    .login-link {
        width: 100%;
        text-align: center;
        justify-content: center;
    }
}

@media (max-width: 560px) {
    .user-menu {
        flex-wrap: wrap;
        justify-content: center;
    }

    .menu-link, .logout-btn {
        padding: 6px 12px;
    }
}

