/* Listing Tool — shared theme.
   Brand accent is controlled by a `data-brand` attribute on <html>:
     <html data-brand="minibay">  -> pink accent
     <html data-brand="upcase">   -> purple accent
     (no attribute)               -> neutral indigo fallback, used on
                                      brand-agnostic pages (dashboard, users, login)
*/

:root {
    --accent: #4f46e5;
    --accent-dark: #4338ca;
    --accent-soft: #eef2ff;
    --accent-ring: rgba(79, 70, 229, 0.12);

    --ink: #1a1f36;
    --ink-muted: #64748b;
    --ink-faint: #94a3b8;
    --bg: #f4f6fb;
    --surface: #ffffff;
    --border: #e2e8f0;
    --border-soft: #eef1f6;

    --sidebar-from: #1a2332;
    --sidebar-to: #0f1728;
    --sidebar-ink: #b0bccd;
    --sidebar-ink-dim: #8896b0;
    --sidebar-width: 260px;

    --radius-sm: 8px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.07);
    --shadow-lg: 0 10px 40px rgba(15, 23, 42, 0.10);
}

[data-brand="minibay"] {
    --accent: #d3266f;
    --accent-dark: #b3205e;
    --accent-soft: #fae5ee;
    --accent-ring: rgba(211, 38, 111, 0.14);
}

[data-brand="upcase"] {
    --accent: #843685;
    --accent-dark: #702e71;
    --accent-soft: #f0e7f0;
    --accent-ring: rgba(132, 54, 133, 0.14);
}

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

html, body { height: 100%; }

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--ink);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    accent-color: var(--accent);
}

a { color: var(--accent); }

/* ---------- App shell ---------- */

.app-wrapper { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--sidebar-from) 0%, var(--sidebar-to) 100%);
    color: var(--sidebar-ink);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-brand h3 {
    font-size: 1.08rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
    letter-spacing: -0.3px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-brand h3 i { color: var(--accent); }

.sidebar-brand small { color: var(--sidebar-ink-dim); font-size: 0.75rem; }

.sidebar-nav { padding: 16px 12px; flex: 1; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-ink);
    text-decoration: none;
    font-size: 0.87rem;
    font-weight: 500;
    margin-bottom: 2px;
    transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-nav a i { width: 18px; text-align: center; font-size: 0.95rem; }

.sidebar-nav a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }

.sidebar-nav a.active {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.main-content {
    flex: 1;
    padding: 32px 36px;
    min-width: 0;
}

.main-content.narrow { max-width: 760px; }
.main-content.medium { max-width: 860px; }

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header-left { display: flex; align-items: center; gap: 12px; }

.page-header h2 { font-size: 1.38rem; font-weight: 700; letter-spacing: -0.3px; }

/* Mobile sidebar toggle */
.sidebar-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border);
    background: var(--surface);
    color: var(--ink);
    font-size: 1.05rem;
    cursor: pointer;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    z-index: 999;
}

.sidebar-backdrop.visible { display: block; }

/* ---------- Buttons ---------- */

.btn-primary-brand {
    background: var(--accent);
    border: none;
    color: #fff;
    border-radius: var(--radius-md);
    padding: 10px 18px;
    font-weight: 600;
    font-size: 0.88rem;
    line-height: 1.2;
    transition: background 0.15s ease, transform 0.05s ease;
}

.btn-primary-brand:hover { background: var(--accent-dark); color: #fff; }
.btn-primary-brand:active { transform: translateY(1px); }
.btn-primary-brand:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary-brand:focus-visible { outline: 3px solid var(--accent-ring); outline-offset: 2px; }

.btn-outline-brand {
    border: 1.5px solid var(--accent);
    color: var(--accent);
    border-radius: var(--radius-md);
    padding: 9px 16px;
    font-weight: 600;
    font-size: 0.86rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    background: transparent;
    transition: background 0.15s ease;
}

.btn-outline-brand:hover { background: var(--accent-soft); color: var(--accent); }

/* ---------- Cards / surfaces ---------- */

.card-panel {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 22px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-soft);
    margin-bottom: 20px;
}

.card-panel:last-child { margin-bottom: 0; }

.card-panel-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: #334155;
    margin-bottom: 12px;
}

/* ---------- Forms ---------- */

label.form-label { font-weight: 600; font-size: 0.85rem; color: #334155; margin-bottom: 6px; }

.form-control, .form-select {
    border-radius: var(--radius-md);
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    font-size: 0.88rem;
    background-color: var(--surface);
}

.form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

/* Brand-select "filled" state: whole box takes the active brand's accent
   color once a real brand is chosen. --accent already resolves to the exact
   per-brand hex via the [data-brand="..."] rules above, so this stays in
   sync with the rest of the theme automatically. */
.form-select.brand-select-filled {
    background-color: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
}

.form-select.brand-select-filled:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.4);
}

.field-hint { font-size: 0.78rem; color: var(--ink-muted); margin-top: 5px; }

.color-chip {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.76rem;
    font-weight: 600;
    background: #f1f5f9;
    color: #475569;
    border: 1px solid rgba(0, 0, 0, 0.08);
    margin: 2px 4px 2px 0;
}

.section-divider { border-top: 1px solid var(--border-soft); margin: 24px 0; }

.alert-error { display: none; }

/* Standalone colored error box (job.html) — distinct from Bootstrap's alert-danger */
.alert-box {
    background: #fee2e2;
    color: #b91c1c;
    border-radius: var(--radius-md);
    padding: 14px 16px;
    margin-top: 14px;
    font-size: 0.88rem;
    line-height: 1.45;
}

/* ---------- Tables ---------- */

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }

th {
    text-align: left;
    color: var(--ink-muted);
    font-weight: 600;
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 11px 12px;
    border-bottom: 1px solid var(--border-soft);
}

td { padding: 13px 12px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }

tbody tr:last-child td { border-bottom: none; }

tr.job-row { cursor: pointer; transition: background 0.12s ease; }
tr.job-row:hover { background: #f8f9fc; }

/* ---------- Badges ---------- */

.badge-status {
    display: inline-block;
    padding: 4px 11px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: capitalize;
    letter-spacing: 0.2px;
}

.badge-pending   { background: #e2e8f0; color: #475569; }
.badge-running   { background: #dbeafe; color: #1d4ed8; }
.badge-completed { background: #dcfce7; color: #15803d; }
.badge-failed    { background: #fee2e2; color: #b91c1c; }

.brand-pill {
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    background: var(--accent-soft);
    color: var(--accent-dark);
    text-transform: capitalize;
    white-space: nowrap;
}

/* Fixed per-row brand colors for aggregate views (e.g. dashboard) where
   multiple brands appear side by side and a single global accent can't apply. */
.brand-pill-minibay { background: #fae5ee; color: #b3205e; }
.brand-pill-upcase  { background: #f0e7f0; color: #702e71; }

.badge-role { font-weight: 500; font-size: 0.7rem; padding: 4px 10px; border-radius: 20px; }

/* ---------- Empty / meta states ---------- */

.empty-state { text-align: center; padding: 56px 20px; color: var(--ink-faint); }
.empty-state i { font-size: 2.1rem; display: block; margin-bottom: 12px; color: var(--border); }

.meta-row { display: flex; gap: 32px; flex-wrap: wrap; margin-top: 14px; }
.meta-item .label { font-size: 0.73rem; color: var(--ink-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.meta-item .value { font-size: 0.95rem; font-weight: 600; margin-top: 3px; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Log console ---------- */

.log-console {
    background: var(--sidebar-to);
    color: #cbd5e1;
    border-radius: var(--radius-md);
    padding: 16px 18px;
    font-family: 'SF Mono', Menlo, Consolas, monospace;
    font-size: 0.82rem;
    max-height: 420px;
    overflow-y: auto;
    line-height: 1.55;
}

.log-line { padding: 2px 0; white-space: pre-wrap; word-break: break-word; }
.log-line .ts { color: #64748b; margin-right: 8px; }

/* ---------- Users table ---------- */

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.82rem;
    color: white;
    background: var(--accent);
    flex-shrink: 0;
}

/* ---------- Login page ---------- */

.login-page {
    background: var(--bg);
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    max-width: 400px;
    width: 100%;
    padding: 42px 38px;
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-soft);
}

.brand-logo {
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--ink);
    text-align: center;
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.brand-logo i { color: var(--accent); }

.error-msg { color: #dc2626; font-size: 0.85rem; text-align: center; margin-top: 12px; display: none; }

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
    .main-content { padding: 24px 20px; }
}

@media (max-width: 768px) {
    .sidebar-toggle { display: inline-flex; }

    .sidebar {
        position: fixed;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: var(--shadow-lg);
    }

    .sidebar.open { transform: translateX(0); }

    .main-content { padding: 20px 16px 32px; }
    .main-content.narrow, .main-content.medium { max-width: none; }

    .meta-row { gap: 20px; }
    .login-card { padding: 32px 24px; }
}
