/* --------------------------------------------------------------------------
   WhatsApp Bulk Sender - stylesheet
   Plain CSS, no build step. Custom properties up top for easy retheming.
   -------------------------------------------------------------------------- */

:root {
    --wa-green:   #128C7E;
    --wa-green-d: #0f7268;
    --wa-teal:    #25D366;

    --bg:      #f4f6f8;
    --surface: #ffffff;
    --border:  #e3e8ee;
    --text:    #1c2733;
    --muted:   #6b7a8d;

    --danger:  #d64545;
    --warn:    #b7791f;
    --info:    #2b6cb0;
    --ok:      #2f855a;

    --radius: 10px;
    --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
    --sidebar-w: 232px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif;
}

a { color: var(--wa-green); }

code {
    background: #eef1f5;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: .9em;
}

.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---- Sidebar ----------------------------------------------------------- */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: #10222e;
    color: #cbd7e2;
    display: flex;
    flex-direction: column;
    padding: 18px 14px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 6px 20px;
}

.brand-mark {
    background: var(--wa-green);
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: grid;
    place-items: center;
}

.brand-text { font-weight: 600; color: #fff; }

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav-item {
    color: #9fb0c0;
    text-decoration: none;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 14px;
}

.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item.active { background: var(--wa-green); color: #fff; font-weight: 500; }

.sidebar-foot { margin-top: auto; border-top: 1px solid rgba(255,255,255,.08); padding-top: 14px; }
.user-name { color: #fff; font-size: 14px; }
.user-role { color: #7d90a3; font-size: 12px; text-transform: capitalize; }
.user-chip { margin-bottom: 10px; padding: 0 6px; }

/* ---- Main -------------------------------------------------------------- */
.main { padding: 28px 32px; }
.has-sidebar .main { margin-left: var(--sidebar-w); }

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.page-head h1 { margin: 0 0 4px; font-size: 24px; }
.page-head p  { margin: 0; font-size: 14px; }

/* ---- Card -------------------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
    margin-bottom: 20px;
}

.card h2 { margin: 0 0 14px; font-size: 17px; }

/* ---- Stats ------------------------------------------------------------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px;
}

.stat-value { font-size: 28px; font-weight: 600; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ---- Steps list -------------------------------------------------------- */
.steps { margin: 0; padding-left: 20px; color: var(--muted); }
.steps li { padding: 3px 0; }
.steps li.done { color: var(--ok); font-weight: 500; }

/* ---- Empty state ------------------------------------------------------- */
.empty { text-align: center; padding: 34px 20px; }
.empty h3 { margin: 0 0 8px; font-size: 16px; }
.empty p  { margin: 0 auto; max-width: 460px; font-size: 14px; }

/* ---- Table ------------------------------------------------------------- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.table tbody tr:last-child td { border-bottom: 0; }

/* ---- Badges ------------------------------------------------------------ */
.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
    background: #eef1f5;
    color: var(--muted);
}

.badge-approved, .badge-completed { background: #e6f4ec; color: var(--ok); }
.badge-pending,  .badge-queued    { background: #fdf3e2; color: var(--warn); }
.badge-rejected, .badge-failed,
.badge-cancelled                  { background: #fdeaea; color: var(--danger); }
.badge-running                    { background: #e8f0fb; color: var(--info); }

/* ---- Progress ---------------------------------------------------------- */
.progress { background: #eef1f5; border-radius: 999px; height: 6px; overflow: hidden; width: 120px; }
.progress-bar { background: var(--wa-teal); height: 100%; }

/* ---- Forms ------------------------------------------------------------- */
.field { display: block; margin-bottom: 16px; }
.field-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }

.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    background: #fff;
    color: var(--text);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--wa-green);
    box-shadow: 0 0 0 3px rgba(18, 140, 126, .12);
}

.field input:disabled { background: #f7f9fb; color: var(--muted); }

.hint { display: block; margin-top: 5px; line-height: 1.45; }

/* ---- Diagnosis steps --------------------------------------------------- */
.diag-step {
    display: flex;
    gap: 12px;
    padding: 13px 0;
    border-bottom: 1px solid var(--border);
}

.diag-step:last-child { border-bottom: 0; }

.diag-mark {
    flex: 0 0 22px;
    height: 22px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
}

.diag-mark.ok  { background: var(--ok); }
.diag-mark.bad { background: var(--danger); }

.diag-body { flex: 1; min-width: 0; }
.diag-body code { word-break: break-all; }

/* Two fields side by side, stacking on narrow screens. */
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 620px) { .field-row { grid-template-columns: 1fr; } }

.form-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 28px;
}

/* Settings detail table reads better with a fixed label column. */
.table th { width: 190px; }

/* ---- Buttons ----------------------------------------------------------- */
.btn {
    display: inline-block;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: 8px;
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
}

.btn-primary { background: var(--wa-green); color: #fff; }
.btn-primary:hover { background: var(--wa-green-d); }
.btn-primary:disabled { background: #a9c4c0; cursor: not-allowed; }

.btn-ghost { background: transparent; border-color: rgba(255,255,255,.18); color: #cbd7e2; }
.btn-ghost:hover { background: rgba(255,255,255,.08); color: #fff; }

.btn-outline { background: #fff; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--wa-green); color: var(--wa-green); }
.btn-outline:disabled { color: var(--muted); cursor: not-allowed; border-color: var(--border); }

.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ---- Alerts ------------------------------------------------------------ */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 18px;
    font-size: 14px;
    border: 1px solid transparent;
}

.alert-success { background: #e6f4ec; border-color: #bfe3ce; color: #1e5b3c; }
.alert-error   { background: #fdeaea; border-color: #f5c6c6; color: #8f2c2c; }
.alert-warn    { background: #fdf3e2; border-color: #f2ddb5; color: #7a5410; }
.alert-info    { background: #e8f0fb; border-color: #c5d9f5; color: #1f4e85; }

/* ---- Login ------------------------------------------------------------- */
.is-guest .main { padding: 0; }

.auth-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 10px 34px rgba(16, 24, 40, .10);
    padding: 32px;
    width: 100%;
    max-width: 400px;
}

.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-brand .brand-mark { margin: 0 auto 12px; width: 44px; height: 44px; font-size: 16px; }
.auth-brand h1 { margin: 0 0 6px; font-size: 20px; }
.auth-brand p  { margin: 0; font-size: 14px; }

.auth-hint { margin: 18px 0 0; text-align: center; font-size: 12.5px; line-height: 1.7; }

/* ---- Small screens ----------------------------------------------------- */
@media (max-width: 760px) {
    .sidebar {
        position: static;
        width: auto;
        flex-direction: row;
        align-items: center;
        gap: 12px;
        padding: 12px;
        overflow-x: auto;
    }
    .nav { flex-direction: row; }
    .sidebar-foot { margin: 0 0 0 auto; border: 0; padding: 0; display: flex; align-items: center; gap: 10px; }
    .user-chip { margin: 0; }
    .has-sidebar .main { margin-left: 0; padding: 20px 16px; }
    .page-head { flex-direction: column; }
}
