/* eMind Cockpit - Modern Flat Dark Theme */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg-dark: #0d0e11;        /* page background (neutral near-black) */
    --bg-card: #15171c;        /* cards / surfaces */
    --bg-elev: #1b1e25;        /* inputs, hover, table head */
    --border: #23262e;         /* hairline borders */
    --accent: #4fc3f7;         /* blue accent */
    --accent-2: #81d4fa;       /* accent hover */
    --text-primary: #e6e8ec;
    --text-secondary: #9298a3;
    --text-muted: #5c616b;
    --ok: #4caf50;
    --warning: #ffc107;
    --error: #ff5252;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--bg-dark);
    background-image:
        radial-gradient(1100px 600px at 78% -8%, rgba(79, 195, 247, 0.07), transparent 60%),
        radial-gradient(900px 500px at 0% 100%, rgba(79, 195, 247, 0.035), transparent 55%);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.6;
}

/* Layout */
.app-layout { display: flex; min-height: 100vh; }

/* ========== Sidebar ========== */
.sidebar {
    width: 220px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 100;
    transition: width 0.3s ease;
}

.sidebar.collapsed {
    width: 0;
    overflow: hidden;
}

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

.sidebar-header .logo {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
}

.sidebar-header .logo-img {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    display: block;
}

.sidebar-header .logo-text {
    white-space: nowrap;
    transition: opacity 0.2s;
}

.logo-text h1 { font-size: 1rem; font-weight: 600; color: var(--accent); }
.logo-text .subtitle { font-size: 0.65rem; color: var(--text-muted); }

.sidebar.collapsed .logo-text { opacity: 0; width: 0; }

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.sidebar-toggle:hover { background: rgba(255,255,255,0.1); color: #fff; }

.nav-list {
    flex: 1;
    padding: 10px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
    overflow-x: hidden;
    /* Themed scrollbar (Firefox) */
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
/* Themed scrollbar (WebKit/Blink) — slim, translucent, accent on hover */
.nav-list::-webkit-scrollbar {
    width: 8px;
}
.nav-list::-webkit-scrollbar-track {
    background: transparent;
}
.nav-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 8px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
.nav-list::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
    background-clip: padding-box;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
    white-space: nowrap;
}

.nav-item:hover { background: rgba(79, 195, 247, 0.1); color: var(--accent); }
.nav-item.active { background: rgba(79, 195, 247, 0.15); color: var(--accent); font-weight: 600; }

/* ---- grouped nav tree ---- */
.nav-group { display: flex; flex-direction: column; }
.nav-group-header {
    display: flex; align-items: center; gap: 9px; width: 100%;
    background: none; border: none; cursor: pointer;
    color: var(--text-muted); padding: 10px 12px 5px;
    font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700;
}
.nav-group-header:hover { color: var(--text-secondary); }
.nav-group-icon { opacity: 0.65; flex: 0 0 auto; }
.nav-group-label { flex: 1; text-align: left; white-space: nowrap; }
.nav-group-caret { flex: 0 0 auto; opacity: 0.55; transition: transform 0.18s; }
.nav-group.collapsed .nav-group-caret { transform: rotate(-90deg); }
.nav-group-items { display: flex; flex-direction: column; gap: 2px; }
.nav-group.collapsed .nav-group-items { display: none; }
.nav-group.has-active .nav-group-header { color: var(--text-secondary); }

/* nav search */
.nav-search { display: flex; align-items: center; gap: 7px; margin: 8px 8px 2px;
    padding: 0 10px; background: var(--bg-elevated, rgba(255,255,255,0.04));
    border: 1px solid var(--border); border-radius: 8px; color: var(--text-muted); }
.nav-search input { flex: 1; background: none; border: none; outline: none;
    color: var(--text-primary); font-size: 0.85rem; padding: 8px 0; }
.nav-search input::placeholder { color: var(--text-muted); }

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.user-avatar { width: 32px; height: 32px; border-radius: 50%; }
.user-name { font-size: 0.85rem; font-weight: 600; }
.user-role { font-size: 0.7rem; color: var(--text-muted); text-transform: capitalize; }
.user-details { flex: 1; min-width: 0; }
.settings-btn { display: flex; padding: 6px; border-radius: 6px; color: var(--text-secondary); transition: all 0.2s; }
.settings-btn:hover, .settings-btn.active { background: rgba(79, 195, 247, 0.1); color: var(--accent); }

.logout-btn {
    display: block;
    text-align: center;
    padding: 6px;
    border-radius: 6px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.logout-btn:hover { background: rgba(255, 82, 82, 0.15); color: var(--error); }

/* ========== Main Content ========== */
.main-content {
    flex: 1;
    margin-left: 220px;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

.sidebar.collapsed ~ .main-content { margin-left: 0; }

/* Floating controls (replace the old full-width content-header bar) */
.floating-logo-btn,
.floating-menu-btn {
    display: none;
    position: fixed;
    top: 12px; left: 12px;
    z-index: 60;
    background: rgba(21, 23, 28, 0.72);
    backdrop-filter: blur(6px);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    padding: 6px;
    color: var(--accent);
    line-height: 0;
    transition: background 0.2s;
}

.floating-logo-btn:hover,
.floating-menu-btn:hover { background: rgba(79, 195, 247, 0.18); }
.floating-logo-btn img { width: 26px; height: 26px; display: block; }
.floating-menu-btn { font-size: 1.4rem; line-height: 1; padding: 3px 10px; }

/* Reopen button appears only when the sidebar is collapsed (desktop). */
.sidebar.collapsed ~ .main-content .floating-logo-btn { display: block; }
/* Give the content room for the reopen button so it never covers a heading. */
.sidebar.collapsed ~ .main-content .content-body { padding-left: 60px; }

.jobs-badge {
    display: flex; align-items: center; gap: 6px;
    padding: 4px 12px; border-radius: 20px;
    background: rgba(79,195,247,0.15); color: var(--accent);
    text-decoration: none; font-size: 0.8rem; font-weight: 600;
    transition: all 0.2s;
}

.jobs-badge:hover { background: rgba(79,195,247,0.25); }
/* Jobs badge floats top-right, only shown (via inline style) while jobs run. */
.floating-jobs { position: fixed; top: 12px; right: 16px; z-index: 60; }

.jobs-badge-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--accent);
    animation: pulse 1.5s infinite;
}

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

.content-body {
    padding: 25px;
}

/* On mobile the burger floats top-left; push content below it. */
@media (max-width: 768px) {
    .floating-menu-btn { display: block; }
    .content-body { padding-top: 60px; }
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.page-header h1 { font-size: 1.5rem; }
.page-header p { color: var(--text-secondary); font-size: 0.9rem; }

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 20px;
    margin-bottom: 20px;
}

/* Summary Cards */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.summary-card {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 18px;
    text-align: center;
    border: 1px solid var(--border);
}

.summary-card .value { font-size: 2rem; font-weight: 700; color: var(--accent); }
.summary-card .label { color: var(--text-secondary); font-size: 0.8rem; text-transform: uppercase; margin-top: 5px; }

/* Status Colors */
.status-ok { color: var(--ok); }
.status-warning { color: var(--warning); }
.status-critical { color: var(--error); }

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge.ok { background: rgba(76, 175, 80, 0.2); color: var(--ok); }
.badge.warning { background: rgba(255, 193, 7, 0.2); color: var(--warning); }
.badge.critical { background: rgba(255, 82, 82, 0.2); color: var(--error); }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--text-secondary); font-size: 0.8rem; text-transform: uppercase; font-weight: 600; }

/* Buttons */
.btn {
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-primary { background: var(--accent); color: var(--bg-dark); }
.btn-primary:hover { background: var(--accent-2); }
.btn-secondary { background: rgba(255,255,255,0.1); color: var(--text-primary); }
.btn-secondary:hover { background: rgba(255,255,255,0.15); }
.btn-danger { background: rgba(255, 82, 82, 0.2); color: var(--error); }
.btn-danger:hover { background: rgba(255, 82, 82, 0.3); }
.btn-small { padding: 4px 10px; font-size: 0.75rem; border-radius: 6px; }

/* Forms */
input, select, textarea {
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-elev);
    color: var(--text-primary);
    font-size: 0.85rem;
}

input:focus, select:focus { outline: none; border-color: var(--accent); }

/* Filters (from eproxy) */
.filters-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.filter-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-group label { font-size: 0.75rem; color: var(--text-secondary); text-transform: uppercase; }
.filter-actions { display: flex; align-items: flex-end; }

/* Results */
.results-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.data-table { width: 100%; }
.data-table th { background: var(--bg-elev); }

/* Toast Container */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transform: translateX(120%);
    transition: transform 0.3s ease;
    max-width: 400px;
}

.toast.show { transform: translateX(0); }
.toast.removing { transform: translateX(120%); }
.toast.success { background: rgba(76, 175, 80, 0.9); color: white; }
.toast.error { background: rgba(255, 82, 82, 0.9); color: white; }
.toast.warning { background: rgba(255, 193, 7, 0.9); color: #333; }
.toast.info { background: rgba(79, 195, 247, 0.9); color: #333; }
.toast-icon { font-size: 1.1rem; }

/* Confirm Dialog */
.confirm-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
}

.confirm-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    max-width: 420px;
    width: 90%;
}

.confirm-box h3 { margin-bottom: 12px; color: var(--text-primary); }
.confirm-box p { color: var(--text-secondary); margin-bottom: 20px; font-size: 0.9rem; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* Sidebar Overlay (mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
}

.sidebar-overlay.open { display: block; }

/* Responsive */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); width: 220px; }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .sidebar.collapsed ~ .main-content { margin-left: 0; }
    .mobile-menu-btn { display: block; }
    .sidebar-toggle { display: none; }
}
