/* ==========================================================================
   Work From Office Tracker — Design System
   Light theme by default; dark theme via :root[data-theme="dark"].
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; letter-spacing: -0.01em; }

:root {
    /* Surfaces & text (light) */
    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-2: #f5f7fb;
    --surface-3: #eef1f7;
    --border: #e4e8f0;
    --border-strong: #d3dae6;
    --text: #1b2436;
    --text-muted: #64748b;
    --text-faint: #94a3b8;

    /* Brand + accents */
    --primary: #3b5bfd;
    --primary-hover: #2743d8;
    --primary-soft: #ecf0ff;
    --on-primary: #ffffff;

    --brand-green: #45b649;
    --brand-navy: #2b2c5e;

    --success: #16a34a;
    --success-soft: #e7f6ec;
    --warning: #d97706;
    --warning-soft: #fdf1de;
    --danger: #e11d48;
    --danger-soft: #fde7ec;
    --info: #0ea5e9;
    --info-soft: #e4f4fd;
    --purple: #7c3aed;
    --purple-soft: #f0e9fe;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow: 0 4px 16px -6px rgba(16, 24, 40, 0.12);
    --shadow-lg: 0 16px 40px -12px rgba(16, 24, 40, 0.18);

    --radius: 14px;
    --radius-sm: 10px;

    /* Legacy aliases (kept so older markup keeps working) */
    --bg-dark: var(--bg);
    --card-bg: var(--surface);
    --card-border: var(--border);
    --border-color: var(--border);
    --text-main: var(--text);
    --primary-glow: rgba(59, 91, 253, 0.25);
    --success-glow: rgba(22, 163, 74, 0.22);
    --warning-glow: rgba(217, 119, 6, 0.22);
    --danger-glow: rgba(225, 29, 72, 0.22);
    --purple-glow: rgba(124, 58, 237, 0.2);
}

:root[data-theme="dark"] {
    --bg: #0b0f1a;
    --surface: #141a29;
    --surface-2: #1a2233;
    --surface-3: #222c40;
    --border: #273143;
    --border-strong: #35415a;
    --text: #eef2f8;
    --text-muted: #9aa8bf;
    --text-faint: #6b7a92;

    --primary: #6183ff;
    --primary-hover: #86a0ff;
    --primary-soft: rgba(97, 131, 255, 0.16);
    --on-primary: #0b1020;

    --brand-green: #56c95b;
    --brand-navy: #c9ccf2;

    --success: #34d399;
    --success-soft: rgba(52, 211, 153, 0.15);
    --warning: #fbbf24;
    --warning-soft: rgba(251, 191, 36, 0.15);
    --danger: #fb7185;
    --danger-soft: rgba(251, 113, 133, 0.15);
    --info: #38bdf8;
    --info-soft: rgba(56, 189, 248, 0.15);
    --purple: #a78bfa;
    --purple-soft: rgba(167, 139, 250, 0.16);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 6px 20px -6px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 20px 48px -12px rgba(0, 0, 0, 0.6);

    --primary-glow: rgba(97, 131, 255, 0.3);
}

html, body { min-height: 100%; }

body {
    background-color: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 24px;
    overflow-x: hidden;
    transition: background-color 0.25s ease, color 0.25s ease;
}

/* Base container */
.app-container {
    width: 100%;
    max-width: 1200px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    z-index: 1;
}

/* Card / panel */
.glass-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: background-color 0.25s ease, border-color 0.25s ease, box-shadow 0.2s ease;
}

/* ---------- Buttons ---------- */
.btn-primary, .btn-secondary, .btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.18s ease;
    border: 1px solid transparent;
    text-decoration: none;
    gap: 8px;
    line-height: 1.2;
}

.btn-primary {
    background-color: var(--primary);
    color: var(--on-primary);
    box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background-color: var(--primary-hover); box-shadow: 0 6px 16px -6px var(--primary-glow); }
.btn-primary:active { transform: translateY(1px); }

.btn-secondary {
    background-color: var(--surface);
    color: var(--text);
    border: 1px solid var(--border-strong);
}
.btn-secondary:hover { background-color: var(--surface-2); border-color: var(--primary); color: var(--primary); }
.btn-secondary:active { transform: translateY(1px); }

.btn-danger {
    background-color: var(--danger-soft);
    color: var(--danger);
    border: 1px solid transparent;
}
.btn-danger:hover { background-color: var(--danger); color: #fff; }

.btn-primary:disabled, .btn-secondary:disabled, .btn-danger:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* ---------- Status pills ---------- */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    border: 1px solid transparent;
}
.status-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; display: inline-block; }

.status-badge.online { background: var(--success-soft); color: var(--success); }
.status-badge.online::before { background: var(--success); }
.status-badge.offline { background: var(--danger-soft); color: var(--danger); }
.status-badge.offline::before { background: var(--danger); }
.status-badge.connecting { background: var(--warning-soft); color: var(--warning); }
.status-badge.connecting::before { background: var(--warning); animation: pulse 1.5s infinite; }

/* ---------- Theme toggle ---------- */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.05rem;
    transition: all 0.18s ease;
}
.theme-toggle:hover { color: var(--primary); border-color: var(--primary); background: var(--surface-2); }

/* ---------- Forms ---------- */
select option { background-color: var(--surface); color: var(--text); }

/* ---------- Generic table (fallback) ---------- */
.logs-table { width: 100%; border-collapse: collapse; text-align: left; }
.logs-table th, .logs-table td { padding: 14px 20px; font-size: 0.88rem; }
.logs-table th {
    background: var(--surface-2);
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
}
.logs-table tr { border-bottom: 1px solid var(--border); }
.logs-table tbody tr:hover { background: var(--surface-2); }

/* ---------- Scrollbars ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 9999px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ---------- Spinner + keyframes ---------- */
.spinner {
    border: 2px solid var(--border-strong);
    width: 18px; height: 18px;
    border-radius: 50%;
    border-left-color: var(--primary);
    animation: spin 0.8s linear infinite;
    display: none;
}
.loading-spinner {
    width: 34px; height: 34px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes popIn { from { transform: scale(0.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes pulse { 0%,100% { opacity: 0.5; } 50% { opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Amoeboids logo (real brand asset, theme-aware) ---------- */
/* Wordmark PNGs are 600x77. Set a height inline; width follows via aspect-ratio. */
.brand-logo {
    display: inline-block;
    height: 28px;
    aspect-ratio: 600 / 77;
    background-image: url('/frontend/assets/amoeboids-logo.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: left center;
}
:root[data-theme="dark"] .brand-logo {
    background-image: url('/frontend/assets/amoeboids-logo-white.png');
}

.hidden { display: none !important; }
