/* =====================================================================
 * Admin theme — SELF-CONTAINED, fully decoupled from the public frontend.
 * One design, two modes: LIGHT (default) + DARK (body.admin-dark).
 * The ONLY customizable colour is the accent (--primary), injected per-tenant
 * from tenant_config('admin_accent'); everything else derives from the mode.
 * A small semantic palette (success / warning / danger) covers status colours
 * so the chrome stays on the single accent and nothing clashes.
 * Class + variable names are preserved; legacy --accent-red* alias --primary.
 * ===================================================================== */

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

:root {
    /* The one configurable accent. Hover/light shades derive from it. */
    --primary: #2563eb;
    --primary-hover: color-mix(in srgb, var(--primary) 82%, #000);
    --primary-light: color-mix(in srgb, var(--primary) 12%, transparent);
    --on-primary: #ffffff;            /* text/icon colour on a primary fill */

    /* LIGHT mode surfaces (default). */
    --bg-dark: #f4f5f7;               /* page background */
    --bg-card: #ffffff;               /* cards / panels / inputs */
    --bg-secondary: #eef0f3;          /* subtle fills, table head, hovers */
    --text-primary: #161a20;
    --text-muted: #687180;
    --border-color: #e3e6ea;

    /* Semantic status palette (mode-aware). */
    --success: #1f9254; --success-bg: rgba(31, 146, 84, 0.12);
    --warning: #b5830a; --warning-bg: rgba(181, 131, 10, 0.14);
    --danger:  #d23b3b; --danger-bg:  rgba(210, 59, 59, 0.12);

    /* Legacy aliases (old red names → the single accent). */
    --accent-red: var(--primary);
    --accent-red-hover: var(--primary-hover);
    --accent-red-light: var(--primary-light);

    --spacing: 1rem;
    --radius: 12px;
    --shadow-sm: 0 1px 2px rgba(20, 23, 28, 0.06);
    --shadow-md: 0 4px 14px rgba(20, 23, 28, 0.08);
    --shadow-lg: 0 12px 32px rgba(20, 23, 28, 0.12);
    --shadow-red: none;                 /* no glow */
    --gradient-primary: var(--primary); /* solid, no gradient */
    --gradient-dark: var(--bg-secondary);
}

/* DARK mode — same accent, dark surfaces + brighter status hues. */
body.admin-dark {
    --bg-dark: #0f1115;
    --bg-card: #171a21;
    --bg-secondary: #1d212a;
    --text-primary: #e8eaee;
    --text-muted: #9aa2ae;
    --border-color: #2a2f3a;

    --success: #3ad17e; --success-bg: rgba(58, 209, 126, 0.15);
    --warning: #f0b429; --warning-bg: rgba(240, 180, 41, 0.15);
    --danger:  #ff6b6b; --danger-bg:  rgba(255, 107, 107, 0.15);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55);
}

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* ---------- Login / set-password card ---------- */
.login-container {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: var(--spacing);
    background: var(--bg-dark);
}
.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 2.5rem;
    width: 100%; max-width: 440px;
    box-shadow: var(--shadow-lg);
}
.login-header { text-align: center; margin-bottom: 1.75rem; }
.login-header .logo { font-size: 2rem; font-weight: 800; color: var(--primary); margin-bottom: 0.5rem; }
.login-header h2 { font-size: 1.5rem; margin-bottom: 0.35rem; color: var(--text-primary); font-weight: 700; }
.login-header p { color: var(--text-muted); font-size: 0.97rem; }
.login-form { margin-top: 1.5rem; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; margin-bottom: 0.4rem; color: var(--text-primary); font-weight: 600; font-size: 0.9rem; }
.form-group input, .form-group textarea, .form-group select {
    width: 100%;
    padding: 0.7rem 0.9rem;
    background: var(--bg-card);
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 0.97rem;
    font-family: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-group textarea { resize: vertical; min-height: 100px; }
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.form-group input::placeholder, .form-group textarea::placeholder { color: var(--text-muted); }

.error-message {
    background: var(--danger-bg);
    border: 1.5px solid var(--danger);
    border-left-width: 3px;
    color: var(--text-primary);
    padding: 0.85rem 1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    font-size: 0.93rem;
    font-weight: 500;
}

/* ---------- Buttons ---------- */
.btn {
    padding: 0.65rem 1.4rem;
    border: 1.5px solid transparent;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease, color 0.15s ease;
    font-size: 0.95rem;
    font-family: inherit;
    text-decoration: none;
    display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
}
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); transform: translateY(-1px); }
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-outline { background: transparent; border-color: var(--border-color); color: var(--text-primary); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.85rem; }
/* Semantic action buttons (flat, no gradients). */
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { filter: brightness(0.94); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(0.94); }
.btn-info { background: var(--bg-secondary); color: var(--text-primary); border-color: var(--border-color); }
.btn-info:hover { border-color: var(--primary); color: var(--primary); }

.box-filter-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.box-filter-btn.active:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

/* ---------- Admin header (mobile top bar reuses these tokens) ---------- */
.admin-header {
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 0.9rem 0;
    position: sticky; top: 0; z-index: 100;
    box-shadow: var(--shadow-sm);
}
.admin-header-content { max-width: 1400px; margin: 0 auto; padding: 0 var(--spacing); display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.admin-header .logo { font-size: 1.4rem; font-weight: 800; color: var(--primary); }
.admin-header .user-info { display: flex; align-items: center; gap: 0.85rem; }
.admin-header .user-name { color: var(--text-muted); font-size: 0.92rem; }

/* ---------- Appearance control (light/dark + accent) ----------
 * A clear, labelled block: a segmented Light/Dark switch + an accent swatch.
 * Lives in the sidebar footer so it's always reachable. */
.admin-appearance {
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 0.75rem;
    margin-bottom: 0.85rem;
    display: flex; flex-direction: column; gap: 0.6rem;
}
.aa-label {
    font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em;
    text-transform: uppercase; color: var(--text-muted);
}
.theme-switch { display: flex; gap: 0.3rem; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 9px; padding: 0.2rem; }
.theme-switch button {
    flex: 1; border: 0; background: transparent; cursor: pointer;
    padding: 0.4rem 0.5rem; border-radius: 7px;
    font: inherit; font-size: 0.82rem; font-weight: 600;
    color: var(--text-muted);
    display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.theme-switch button:hover { color: var(--text-primary); }
.theme-switch button.active { background: var(--primary); color: var(--on-primary); }

/* Compact icon-only switch for the sidebar footer (no label/notes — saves space). */
.theme-switch-mini { width: max-content; margin: 0 auto 0.6rem; }
.theme-switch-mini button { flex: 0 0 auto; padding: 0.25rem 0.5rem; font-size: 0.95rem; line-height: 1; }
/* The accent isn't editable in admin — it follows the brand accent. A small note + live dot. */
.aa-accent-note { display: flex; align-items: center; gap: 0.4rem; font-size: 0.72rem; line-height: 1.3; color: var(--text-muted); }
.aa-accent-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; border: 1px solid var(--border-color); }

.admin-container { max-width: 1400px; margin: 0 auto; padding: 2rem var(--spacing); }
.admin-title { font-size: 1.7rem; margin-bottom: 1.5rem; color: var(--text-primary); font-weight: 700; }

/* ---------- Stat cards ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1.25rem; margin-bottom: 2rem; }
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
    transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    position: relative; overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 3px; background: var(--primary); transform: scaleX(0); transform-origin: left; transition: transform 0.25s ease; }
.stat-card:hover { border-color: var(--primary); transform: translateY(-3px); box-shadow: var(--shadow-md); }
.stat-card:hover::before { transform: scaleX(1); }
.stat-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; }
.stat-card-title { color: var(--text-muted); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.stat-card-icon { font-size: 1.5rem; color: var(--primary); display: inline-flex; }
.stat-card-icon svg { width: 22px; height: 22px; }
/* Inline single-color icons sitting next to text (labels, buttons, headings) */
.aa-label { display: flex; align-items: center; gap: 0.4rem; }
.aa-label svg { width: 14px; height: 14px; }
.btn svg { vertical-align: -0.18em; }
.admin-container h2 svg, .admin-container h3 svg { vertical-align: -0.18em; }
.stat-card-value { font-size: 2.1rem; font-weight: 800; color: var(--text-primary); margin-bottom: 0.35rem; }
.stat-card-change { font-size: 0.85rem; color: var(--text-muted); }

/* ---------- Content sections ---------- */
.content-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 2rem;
    margin-bottom: 1.75rem;
    box-shadow: var(--shadow-sm);
}
.section-title { font-size: 1.4rem; margin-bottom: 1.5rem; color: var(--text-primary); padding-bottom: 0.85rem; border-bottom: 1px solid var(--border-color); font-weight: 700; position: relative; }
.section-title::after { content: ''; position: absolute; bottom: -1px; left: 0; width: 54px; height: 2px; background: var(--primary); }

/* ---------- Tables ---------- */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
table th, table td { padding: 0.85rem 1rem; text-align: left; border-bottom: 1px solid var(--border-color); }
table th { background: var(--bg-secondary); color: var(--text-muted); font-weight: 700; text-transform: uppercase; font-size: 0.78rem; letter-spacing: 0.04em; }
table td { color: var(--text-primary); }
table tr:hover { background: var(--bg-secondary); }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 0.3rem 0.7rem; border-radius: 999px; font-size: 0.78rem; font-weight: 700; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-info    { background: var(--primary-light); color: var(--primary); }

/* ---------- Generic toggle switch (shared by SMS editor + working hours) ---------- */
.ui-sw { display: inline-flex; align-items: center; gap: 0.55rem; cursor: pointer; user-select: none; position: relative; }
.ui-sw input { position: absolute; opacity: 0; width: 0; height: 0; }
.ui-sw-track { width: 40px; height: 23px; border-radius: 999px; background: var(--border-color); position: relative; transition: background 0.15s ease; flex-shrink: 0; }
.ui-sw-track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; transition: transform 0.15s ease; box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.ui-sw input:checked + .ui-sw-track { background: var(--primary); }
.ui-sw input:checked + .ui-sw-track::after { transform: translateX(17px); }
.ui-sw input:focus-visible + .ui-sw-track { box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 35%, transparent); }
.ui-sw-text { font-weight: 600; color: var(--text-primary); font-size: 0.88rem; }

/* ---------- SMS text editor ---------- */
.sms-group { background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 14px; overflow: hidden; }
.sms-group-head { display: flex; align-items: center; gap: 0.7rem; padding: 0.9rem 1.1rem; border-bottom: 1px solid var(--border-color); }
.sms-group-head > svg { color: var(--primary); flex-shrink: 0; }
.sms-group-title { font-weight: 700; font-size: 1.02rem; color: var(--text-primary); }
.sms-group-hint { font-size: 0.82rem; color: var(--text-muted); margin-top: 0.1rem; }
.sms-group-count { margin-left: auto; font-style: normal; font-size: 0.78rem; font-weight: 700; color: var(--text-muted); background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 999px; padding: 0.1rem 0.55rem; }
.sms-group-body { padding: 0.9rem 1.1rem; display: flex; flex-direction: column; gap: 0.9rem; }
.sms-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 12px; padding: 1rem 1.1rem; }
.sms-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.sms-card-titles { flex: 1; min-width: 200px; }
.sms-card-title { font-weight: 700; font-size: 0.98rem; color: var(--text-primary); }
.sms-card-desc { margin-top: 0.2rem; color: var(--text-muted); font-size: 0.85rem; line-height: 1.4; }
.sms-card-actions { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.sms-reset { background: transparent; border: 1px solid var(--border-color); color: var(--text-muted); border-radius: 8px; padding: 0.4rem 0.7rem; font: inherit; font-size: 0.82rem; font-weight: 600; cursor: pointer; transition: color 0.12s ease, border-color 0.12s ease; }
.sms-reset:hover { color: var(--text-primary); border-color: var(--text-muted); }
.sms-ta { width: 100%; min-height: 84px; resize: vertical; margin-top: 0.85rem; background: var(--bg-secondary); border: 1.5px solid var(--border-color); border-radius: 10px; color: var(--text-primary); font-family: inherit; font-size: 0.92rem; line-height: 1.5; padding: 0.7rem 0.9rem; box-sizing: border-box; }
.sms-ta:focus { outline: none; border-color: var(--primary); }
/* contenteditable pill editor */
.sms-editor { width: 100%; min-height: 84px; margin-top: 0.85rem; background: var(--bg-secondary); border: 1.5px solid var(--border-color); border-radius: 10px; color: var(--text-primary); font-family: inherit; font-size: 0.92rem; line-height: 2; padding: 0.55rem 0.9rem; box-sizing: border-box; white-space: pre-wrap; word-break: break-word; }
.sms-editor:focus { outline: none; border-color: var(--primary); }
.sms-editor:empty::before { content: 'Scrie mesajul…'; color: var(--text-muted); }
.tok { display: inline-flex; align-items: center; background: color-mix(in srgb, var(--primary) 14%, transparent); border: 1px solid color-mix(in srgb, var(--primary) 40%, transparent); color: var(--primary); border-radius: 6px; padding: 0.02rem 0.45rem; margin: 0 1px; font-size: 0.82rem; font-weight: 600; white-space: nowrap; user-select: none; cursor: default; }
.sms-vars { margin-top: 0.7rem; display: flex; align-items: flex-start; gap: 0.5rem; flex-wrap: wrap; }
.sms-vars-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; padding-top: 0.3rem; }
.sms-vars-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; flex: 1; }
.var-chip { display: inline-flex; align-items: center; gap: 0.3rem; background: color-mix(in srgb, var(--primary) 10%, transparent); border: 1px solid color-mix(in srgb, var(--primary) 35%, transparent); color: var(--primary); border-radius: 999px; padding: 0.28rem 0.6rem; font: inherit; font-size: 0.8rem; font-weight: 600; cursor: pointer; transition: background 0.12s ease; }
.var-chip:hover { background: color-mix(in srgb, var(--primary) 20%, transparent); }
.var-chip svg { flex-shrink: 0; }
.sms-preview { margin-top: 0.8rem; background: var(--bg-secondary); border: 1px dashed var(--border-color); border-radius: 10px; padding: 0.6rem 0.8rem; }
.sms-preview-label { display: block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 700; margin-bottom: 0.25rem; }
.sms-preview-body { font-size: 0.9rem; color: var(--text-primary); line-height: 1.5; white-space: pre-wrap; word-break: break-word; }

/* ---------- Working hours ---------- */
.wh-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.wh-sub { color: var(--text-muted); font-size: 0.88rem; margin: 0.25rem 0 0; }
.wh-rows { display: flex; flex-direction: column; gap: 0.5rem; }
.wh-day { display: grid; grid-template-columns: 110px 150px 1fr; align-items: center; gap: 1rem; border: 1px solid var(--border-color); border-radius: 10px; padding: 0.6rem 0.9rem; background: var(--bg-secondary); }
.wh-day-name { font-weight: 700; color: var(--text-primary); }
.wh-times { display: inline-flex; align-items: center; gap: 0.5rem; transition: opacity 0.15s ease; }
.wh-times-off { opacity: 0.35; pointer-events: none; }
.wh-times input[type=time] { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 8px; color: var(--text-primary); padding: 0.4rem 0.5rem; font: inherit; }
.wh-dash { color: var(--text-muted); }
.wh-settings { display: flex; flex-direction: column; gap: 1.25rem; max-width: 560px; }
.wh-field > label:not(.ui-sw) { display: block; font-weight: 600; color: var(--text-primary); margin-bottom: 0.35rem; }
.wh-field small { display: block; color: var(--text-muted); margin-top: 0.3rem; font-size: 0.82rem; line-height: 1.4; }
.wh-field input[type=number] { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 8px; color: var(--text-primary); padding: 0.45rem 0.6rem; font: inherit; max-width: 120px; }
.wh-input-suffix { display: inline-flex; align-items: center; gap: 0.5rem; }
.wh-input-suffix span { color: var(--text-muted); font-size: 0.9rem; }
.wh-save-bar { display: flex; align-items: center; gap: 0.9rem; }
.wh-msg { font-size: 0.9rem; }

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .login-card { padding: 1.75rem; }
    .admin-header-content { flex-direction: column; gap: 0.85rem; }
    .stats-grid { grid-template-columns: 1fr; }
    .table-container { overflow-x: scroll; }
}
@media (max-width: 600px) {
    .sms-card-actions { width: 100%; }
    .sms-vars-label { width: 100%; padding-top: 0; }
    .wh-day { grid-template-columns: 1fr; gap: 0.5rem; }
}
