/* ═══════════════════════════════════════════════════════════
   LAYOUT — sidebar + top bar + main
   ═══════════════════════════════════════════════════════════ */

body {
    background: var(--bg);
    color: var(--text);
    transition: background 0.2s, color 0.2s;
    overflow: hidden;
}

.app {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* ─── SIDEBAR ─── */
.sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--bg-elevated);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.sidebar-header {
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 600;
    flex-shrink: 0;
}

.sidebar-header-logo { font-size: 22px; line-height: 1; }

.sidebar-nav {
    flex: 1;
    padding: 10px 8px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
    position: relative;
    border: none;
    background: none;
    text-align: left;
    width: 100%;
    font-family: inherit;
}

.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--accent); color: var(--accent-text); }

.nav-item-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.nav-item-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-item-badge {
    background: rgba(255,255,255,0.15);
    color: var(--text);
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
}

.nav-item.active .nav-item-badge {
    background: rgba(255,255,255,0.25);
    color: var(--accent-text);
}

.nav-item-badge.warn {
    background: rgba(210,153,34,0.3);
    color: var(--status-waiting-fg);
}

.nav-divider { height: 1px; background: var(--border); margin: 8px 4px; }

.sidebar-footer {
    padding: 10px 8px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-shrink: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 6px;
    background: var(--bg);
    border: 1px solid var(--border);
    margin: 4px 0;
}

.sidebar-user-avatar { font-size: 18px; flex-shrink: 0; }
.sidebar-user-info { flex: 1; min-width: 0; }

.sidebar-user-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-user-role { font-size: 11px; color: var(--text-dim); }

/* ─── CONTENT ─── */
.content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    height: 60px;
}

.topbar-search { position: relative; flex: 1; max-width: 400px; }

.topbar-search input {
    width: 100%;
    padding: 8px 12px 8px 34px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 13px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.topbar-search input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(31,111,235,0.15);
}

.topbar-search::before {
    content: "🔍";
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
    opacity: 0.5;
    pointer-events: none;
}

.topbar-spacer { flex: 1; }

.status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
    padding: 4px 12px;
    border-radius: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--danger);
    box-shadow: 0 0 8px currentColor;
    color: var(--danger);
    transition: background 0.2s, color 0.2s;
}

.status.online .status-dot {
    background: var(--success);
    color: var(--success);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.counters { display: flex; gap: 6px; flex-shrink: 0; }

.counter {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.counter b { color: var(--text); font-weight: 600; }
.counter.waiting b { color: var(--status-waiting-fg); }
.counter.active b  { color: var(--status-active-fg); }
.counter.done b    { color: var(--status-done-fg); }

.main {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    scroll-behavior: smooth;
}

.main-inner { max-width: 1100px; margin: 0 auto; width: 100%; }

.empty {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-muted);
    font-size: 14px;
}

.empty-icon { font-size: 48px; opacity: 0.4; margin-bottom: 16px; }

/* ─── MODAL ─── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    backdrop-filter: blur(2px);
}

.modal-overlay.show { display: flex; animation: fadeIn 0.15s; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    max-width: 720px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.2s ease-out;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

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

.modal-title { font-size: 16px; font-weight: 600; }

.modal-close {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 18px;
    transition: all 0.15s;
}

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

.modal-body { padding: 20px; overflow-y: auto; flex: 1; }

.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 2000;
    pointer-events: none;
}

.toast {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 16px;
    box-shadow: var(--shadow);
    min-width: 280px;
    max-width: 400px;
    pointer-events: auto;
    animation: slideIn 0.25s ease-out;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(100px); }
    to { opacity: 1; transform: translateX(0); }
}

.toast-title { font-weight: 600; font-size: 13px; margin-bottom: 3px; }
.toast-body { font-size: 12px; color: var(--text-muted); }
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--info); }
.toast.warning { border-left: 3px solid var(--warning); }
