/* =====================================================================
   Cigaretto - design tokens and shared components
   Theme: light by default, dark via system preference or [data-theme]
   ===================================================================== */

:root {
    --sidebar: #0F2A1D;
    --bg: #F6F7F6;
    --surface: #FFFFFF;
    --surface-2: #F1F3F2;
    --border: #E3E7E5;
    --text: #111A15;
    --text-muted: #5B6660;      /* AA on white */
    --primary: #1F7A4D;
    --primary-hover: #19663F;
    --primary-soft: #E6F2EC;
    --warning: #F59E0B;
    --warning-soft: #FEF3E2;
    --warning-text: #8A5300;
    --danger: #DC2626;
    --danger-soft: #FDECEC;
    --danger-text: #B01E1E;
    --focus: rgba(31, 122, 77, .35);

    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(16, 24, 20, .04), 0 4px 16px rgba(16, 24, 20, .06);
    --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0B1410;
        --surface: #121D18;
        --surface-2: #18251F;
        --border: #24342C;
        --text: #E7EEEA;
        --text-muted: #9DAAA3;
        --primary: #2E9A64;
        --primary-hover: #36AD71;
        --primary-soft: #16301F;
        --warning-soft: #33260E;
        --warning-text: #F8C46A;
        --danger-soft: #3A1515;
        --danger-text: #F59A9A;
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .3);
    }
}

:root[data-theme="dark"] {
    --bg: #0B1410;
    --surface: #121D18;
    --surface-2: #18251F;
    --border: #24342C;
    --text: #E7EEEA;
    --text-muted: #9DAAA3;
    --primary: #2E9A64;
    --primary-hover: #36AD71;
    --primary-soft: #16301F;
    --warning-soft: #33260E;
    --warning-text: #F8C46A;
    --danger-soft: #3A1515;
    --danger-text: #F59A9A;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .3);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 600; }
p { margin: 0; }

a { color: var(--primary); text-decoration: none; font-weight: 500; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

.muted { color: var(--text-muted); }
.num { font-variant-numeric: tabular-nums; }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 44px; padding: 0 18px;
    font: 600 15px/1 var(--font);
    border: 1px solid transparent; border-radius: var(--radius-sm);
    cursor: pointer; transition: background .15s, border-color .15s;
}
.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-hover); }
.btn--secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn--secondary:hover { background: var(--surface-2); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--block { width: 100%; }

.link-btn {
    background: none; border: 0; padding: 0;
    font: 500 14px var(--font); color: var(--primary); cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }

/* ---------- Forms ---------- */
.form { display: grid; gap: 16px; }

.field { display: grid; gap: 6px; }
.field label { font-size: 14px; font-weight: 500; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="search"],
input[type="date"], input[type="time"], select, textarea {
    width: 100%; height: 44px; padding: 0 12px;
    font: 400 15px var(--font); color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: var(--text-muted); opacity: .7; }
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus);
}

.input-group { position: relative; }
.input-group input { padding-right: 44px; }
.input-group__btn {
    position: absolute; top: 0; right: 0; width: 44px; height: 44px;
    display: grid; place-items: center;
    background: none; border: 0; color: var(--text-muted); cursor: pointer;
}
.input-group__btn svg { width: 20px; height: 20px; }

input[aria-invalid="true"] { border-color: var(--danger); }
input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px rgba(220, 38, 38, .25); }
.field__error { font-size: 13px; color: var(--danger-text); }

/* Input with a fixed prefix, e.g. "@" before the username */
.input-prefix { position: relative; }
.input-prefix span {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    color: var(--text-muted); pointer-events: none;
}
.input-prefix input { padding-left: 30px; }

/* Two fields side by side, stacked on small screens */
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 380px) { .field-pair { grid-template-columns: 1fr; } }

/* Segmented toggle built from radios, e.g. $ / LBP */
.segmented {
    display: inline-flex; flex-shrink: 0;
    padding: 3px; gap: 2px;
    background: var(--surface-2);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.segmented label { position: relative; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
    display: grid; place-items: center;
    min-width: 44px; height: 36px; padding: 0 12px;
    border-radius: 6px; font-size: 14px; font-weight: 600; color: var(--text-muted);
}
.segmented input:checked + span { background: var(--primary); color: #fff; }
.segmented input:focus-visible + span { outline: 3px solid var(--focus); }

/* Amount input followed by a currency toggle */
.amount-row { display: flex; gap: 8px; align-items: center; }
.amount-row input { flex: 1; min-width: 0; font-variant-numeric: tabular-nums; }

/* "1 $ = [ 89,500 ] LBP" */
.rate-row { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.rate-row input { flex: 1; min-width: 0; text-align: center; font-variant-numeric: tabular-nums; }

select {
    appearance: none;
    padding-right: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6' fill='none' stroke='%235B6660' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center; background-size: 18px;
}

.checkbox { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.checkbox input { width: 18px; height: 18px; accent-color: var(--primary); margin: 0; flex-shrink: 0; }
.checkbox--top { align-items: flex-start; }
.checkbox--top input { margin-top: 1px; }

.hint { font-size: 13px; color: var(--text-muted); }

/* Live rule checklist (password) */
.checklist { display: grid; gap: 4px; margin: 4px 0 0; padding: 0; list-style: none; font-size: 13px; color: var(--text-muted); }
.checklist li { display: flex; align-items: center; gap: 8px; }
.checklist li::before {
    content: ""; width: 16px; height: 16px; flex-shrink: 0; border-radius: 50%;
    border: 1.5px solid var(--border);
}
.checklist li.is-met { color: var(--text); }
.checklist li.is-met::before {
    border-color: var(--primary);
    background: var(--primary) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8.5l2.5 2.5L12 5.5' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 12px no-repeat;
}

/* ---------- Alerts ---------- */
.alert {
    padding: 12px 14px; border-radius: var(--radius-sm);
    font-size: 14px; border: 1px solid transparent;
}
.alert--error   { background: var(--danger-soft);  color: var(--danger-text);  border-color: rgba(220, 38, 38, .25); }
.alert--warning { background: var(--warning-soft); color: var(--warning-text); border-color: rgba(245, 158, 11, .3); }
.alert--success { background: var(--primary-soft); color: var(--primary);      border-color: rgba(31, 122, 77, .25); }

/* ---------- Avatar ---------- */
.avatar {
    display: inline-grid; place-items: center;
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--primary); color: #fff;
    font-weight: 600; font-size: 15px; object-fit: cover;
}
.avatar--lg { width: 72px; height: 72px; font-size: 26px; }

/* ---------- Line icons (inline SVG) ---------- */
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
