/* ============================================================
   Bravepesa — Main CSS
   Premium dark mode. Hand-crafted. Kenyan digital education.
   ============================================================ */

/* ── Premium Font Import ───────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;500;600;700;800&family=Inter:wght@400;500;600&display=swap');

/* ── Variables ─────────────────────────────────────────────── */
:root {
    /* Core palette — deep, warm, serious */
    --bg-base:       #0A0A09;
    --bg-surface:    #111110;
    --bg-elevated:   #191917;
    --bg-hover:      #212120;
    --bg-active:     #282826;

    /* Borders — warm-tinted, not cold grey */
    --border:        #252523;
    --border-light:  #2E2E2B;
    --border-warm:   #332F28;

    /* Text — warm whites, not clinical */
    --text-primary:  #EDE9E3;
    --text-secondary:#9E9890;
    --text-muted:    #5E5A54;
    --text-inverse:  #0A0A09;

    /* Brand — warm amber gold */
    --brand:         #C9963A;
    --brand-hover:   #DBA84E;
    --brand-dim:     rgba(201, 150, 58, 0.10);
    --brand-border:  rgba(201, 150, 58, 0.22);

    /* Teal accent — deep, sophisticated */
    --teal:          #2A7A6F;
    --teal-light:    #3A9B8E;
    --teal-dim:      rgba(42, 122, 111, 0.12);
    --teal-border:   rgba(42, 122, 111, 0.28);

    /* Terracotta accent — earthy, Kenyan */
    --terra:         #B85C38;
    --terra-dim:     rgba(184, 92, 56, 0.10);
    --terra-border:  rgba(184, 92, 56, 0.25);

    /* Accent (kept for compatibility) */
    --accent:        #3A7A8A;
    --accent-dim:    rgba(58, 122, 138, 0.12);

    /* Status */
    --success:       #3D8A5C;
    --success-dim:   rgba(61, 138, 92, 0.12);
    --warning:       #C4832A;
    --warning-dim:   rgba(196, 131, 42, 0.12);
    --error:         #B04040;
    --error-dim:     rgba(176, 64, 64, 0.12);

    /* Spacing */
    --sp-1: 0.25rem;  --sp-2: 0.5rem;   --sp-3: 0.75rem;
    --sp-4: 1rem;     --sp-5: 1.25rem;  --sp-6: 1.5rem;
    --sp-8: 2rem;     --sp-10: 2.5rem;  --sp-12: 3rem;
    --sp-16: 4rem;    --sp-20: 5rem;

    /* Typography */
    --text-xs:   0.75rem;
    --text-sm:   0.875rem;
    --text-base: 1rem;
    --text-lg:   1.125rem;
    --text-xl:   1.375rem;
    --text-2xl:  1.75rem;
    --text-3xl:  2.25rem;
    --text-4xl:  3rem;

    /* Radius — varied, not uniform */
    --r-xs:  0.25rem;
    --r-sm:  0.375rem;
    --r:     0.5rem;
    --r-lg:  0.875rem;
    --r-xl:  1.25rem;
    --r-2xl: 2rem;

    /* Motion */
    --ease-fast:   150ms ease;
    --ease-normal: 250ms ease;
    --ease-slow:   400ms ease;

    /* Shadows — warm-tinted, not cold black */
    --shadow-sm: 0 1px 4px rgba(10,8,4,0.5), 0 0 0 1px rgba(255,220,150,0.03);
    --shadow:    0 4px 20px rgba(10,8,4,0.55), 0 1px 4px rgba(10,8,4,0.3);
    --shadow-lg: 0 16px 48px rgba(10,8,4,0.65), 0 4px 12px rgba(10,8,4,0.4);
    --shadow-brand: 0 8px 28px rgba(201,150,58,0.18), 0 2px 8px rgba(201,150,58,0.12);
    --shadow-teal:  0 8px 28px rgba(42,122,111,0.18), 0 2px 8px rgba(42,122,111,0.10);
}

/* ── Force dark mode — no system override ──────────────────── */
html {
    color-scheme: dark;
    background: var(--bg-base);
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    font-size: var(--text-base);
    line-height: 1.65;
    color: var(--text-primary);
    background: var(--bg-base);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5 {
    font-family: 'Sora', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.025em;
    color: var(--text-primary);
}

h1 { font-size: var(--text-3xl); font-weight: 800; }
h2 { font-size: var(--text-2xl); font-weight: 700; }
h3 { font-size: var(--text-xl); font-weight: 700; }
h4 { font-size: var(--text-lg); font-weight: 600; }

p { color: var(--text-secondary); line-height: 1.7; }

a {
    color: var(--brand);
    text-decoration: none;
    transition: color var(--ease-fast);
}
a:hover { color: var(--brand-hover); }

img { max-width: 100%; height: auto; display: block; }

code {
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.875em;
    background: var(--bg-elevated);
    color: var(--brand);
    padding: 0.15em 0.4em;
    border-radius: var(--r-sm);
    border: 1px solid var(--border-warm);
}

hr {
    border: none;
    border-top: 1px solid var(--border);
    margin-block: var(--sp-4);
}

/* ── Skip Link ─────────────────────────────────────────────── */
.skip-link {
    position: absolute; top: -48px; left: var(--sp-4);
    background: var(--brand); color: var(--text-inverse);
    padding: var(--sp-2) var(--sp-4);
    border-radius: 0 0 var(--r) var(--r);
    font-weight: 600; font-size: var(--text-sm);
    z-index: 9999;
    transition: top var(--ease-fast);
}
.skip-link:focus { top: 0; }

/* ── Layout ────────────────────────────────────────────────── */
.container {
    width: 100%;
    max-width: 1200px;
    margin-inline: auto;
    padding-inline: var(--sp-4);
}
.narrow  { max-width: 700px; }
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    min-height: 44px;
    padding: 0.625rem 1.375rem;
    border-radius: var(--r);
    border: 1.5px solid transparent;
    font-family: 'Sora', system-ui, sans-serif;
    font-size: var(--text-sm);
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition:
        background var(--ease-fast),
        border-color var(--ease-fast),
        color var(--ease-fast),
        transform var(--ease-fast),
        box-shadow var(--ease-fast);
    -webkit-user-select: none;
    user-select: none;
}
.btn:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 3px;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; }

/* Primary */
.btn-primary {
    background: var(--brand);
    color: #0A0A09;
    border-color: var(--brand);
    font-weight: 700;
}
.btn-primary:hover {
    background: var(--brand-hover);
    border-color: var(--brand-hover);
    color: #0A0A09;
    transform: translateY(-1px);
    box-shadow: var(--shadow-brand);
    text-decoration: none;
}

/* Outline */
.btn-outline {
    background: transparent;
    border-color: var(--border-warm);
    color: var(--text-primary);
}
.btn-outline:hover {
    background: var(--bg-hover);
    border-color: var(--brand);
    color: var(--brand);
    text-decoration: none;
    transform: translateY(-1px);
}

/* Ghost */
.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--text-secondary);
}
.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    text-decoration: none;
}

/* Teal variant */
.btn-teal {
    background: var(--teal);
    color: #EDE9E3;
    border-color: var(--teal);
    font-weight: 700;
}
.btn-teal:hover {
    background: var(--teal-light);
    border-color: var(--teal-light);
    color: #EDE9E3;
    transform: translateY(-1px);
    box-shadow: var(--shadow-teal);
    text-decoration: none;
}

/* Danger */
.btn-error {
    background: var(--error-dim);
    border-color: var(--error);
    color: #D07070;
}
.btn-error:hover {
    background: var(--error);
    color: white;
    text-decoration: none;
}

/* Sizes */
.btn-full { width: 100%; }
.btn-lg   { min-height: 52px; padding: 0.875rem 2rem; font-size: var(--text-base); border-radius: var(--r-lg); }
.btn-sm   { min-height: 36px; padding: 0.375rem 0.875rem; font-size: var(--text-xs); }
.btn-xs   { min-height: 28px; padding: 0.2rem 0.6rem; font-size: var(--text-xs); }

/* ── Forms ─────────────────────────────────────────────────── */
.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    margin-bottom: var(--sp-4);
}
.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--sp-4);
}

label {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-secondary);
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="url"],
input[type="number"],
input[type="search"],
input[type="date"],
select,
textarea {
    width: 100%;
    min-height: 44px;
    padding: 0.625rem 0.875rem;
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1.5px solid var(--border-light);
    border-radius: var(--r);
    font-size: var(--text-sm);
    font-family: inherit;
    transition: border-color var(--ease-fast), box-shadow var(--ease-fast);
    -webkit-appearance: none;
    appearance: none;
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-dim);
}
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23A8A29E' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.875rem center;
    padding-right: 2.5rem;
    cursor: pointer;
}
textarea { resize: vertical; min-height: 100px; }

.form-hint  { font-size: var(--text-xs); color: var(--text-muted); }
.form-error { font-size: var(--text-xs); color: var(--error); }
.has-error input,
.has-error select,
.has-error textarea { border-color: var(--error); }

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    cursor: pointer;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-bottom: var(--sp-4);
}
.checkbox-label input[type="checkbox"] {
    width: 18px; height: 18px;
    min-height: auto;
    margin-top: 2px;
    flex-shrink: 0;
    accent-color: var(--brand);
    cursor: pointer;
}

/* ── Alerts ────────────────────────────────────────────────── */
.alert {
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--r);
    font-size: var(--text-sm);
    margin-bottom: var(--sp-4);
    border: 1px solid transparent;
    border-left-width: 3px;
    line-height: 1.5;
    display: block;
}
.alert-success {
    background: rgba(61, 138, 92, 0.10) !important;
    border-color: #3D8A5C !important;
    color: #5DBF85 !important;
}
.alert-error {
    background: rgba(176, 64, 64, 0.10) !important;
    border-color: #B04040 !important;
    color: #D07070 !important;
}
.alert-info {
    background: rgba(58, 122, 138, 0.10) !important;
    border-color: #3A7A8A !important;
    color: #5AABB8 !important;
}
.alert-warning {
    background: rgba(196, 131, 42, 0.10) !important;
    border-color: #C4832A !important;
    color: #E09A40 !important;
}

/* ── Badges ────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: var(--r-sm);
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    border: 1px solid;
}
.badge-completed,
.badge-active,
.badge-confirmed  { background: var(--success-dim); border-color: var(--success); color: #5DBF85; }
.badge-pending,
.badge-processing { background: var(--warning-dim); border-color: var(--warning); color: #E09A40; }
.badge-failed,
.badge-rejected,
.badge-expired    { background: var(--error-dim);   border-color: var(--error);   color: #D07070; }
.badge-in_progress{ background: var(--accent-dim);  border-color: var(--accent);  color: #5AABB8; }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--sp-6);
}

/* ── Data Table ────────────────────────────────────────────── */
.data-table-wrapper {
    overflow-x: auto;
    border-radius: var(--r-lg);
    border: 1px solid var(--border);
    background: var(--bg-surface);
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}
.data-table th {
    background: var(--bg-elevated);
    padding: var(--sp-3) var(--sp-4);
    text-align: left;
    font-family: 'Inter', system-ui, sans-serif;
    font-weight: 700;
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}
.data-table td {
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-hover); }

/* ── Dashboard Tabs ────────────────────────────────────────── */
.dashboard-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-1);
    margin-bottom: var(--sp-6);
    background: var(--bg-elevated);
    padding: var(--sp-1);
    border-radius: var(--r);
    border: 1px solid var(--border);
}

.service-tabs {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    margin-bottom: var(--sp-6);
}

.tab-btn {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    padding: var(--sp-4);
    font-family: 'Inter', system-ui, sans-serif;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--r-sm);
    transition: background var(--ease-fast), color var(--ease-fast), border-color var(--ease-fast);
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tab-btn .tab-label {
    font-family: 'Sora', system-ui, sans-serif;
    color: var(--text-primary);
    font-weight: 700;
    font-size: var(--text-base);
    letter-spacing: -0.015em;
}

.tab-btn .tab-price {
    font-weight: 600;
    color: var(--brand);
}

.tab-btn:hover { 
    background: var(--bg-hover); 
    color: var(--text-primary);
    border-color: var(--brand-border);
}

.tab-btn.active { 
    background: var(--brand); 
    color: #0A0A09;
    border-color: var(--brand);
}

.tab-btn.active .tab-label {
    color: #0A0A09;
}

.tab-btn.active .tab-price {
    color: rgba(10, 9, 4, 0.75);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Pagination ────────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-4);
    margin-top: var(--sp-8);
    color: var(--text-muted);
    font-size: var(--text-sm);
}

/* ── Empty State ───────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: var(--sp-12) var(--sp-8);
    color: var(--text-muted);
}
.empty-state p { color: var(--text-muted); }

/* ── Modal ─────────────────────────────────────────────────── */
.modal {
    position: fixed; inset: 0; z-index: 300;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center;
    padding: var(--sp-4);
}
.modal[hidden] { display: none; }
.modal-inner {
    background: var(--bg-elevated);
    border: 1px solid var(--border-warm);
    border-radius: var(--r-xl);
    padding: var(--sp-8);
    width: 100%; max-width: 520px;
    max-height: 90vh; overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

/* ── Skeleton ──────────────────────────────────────────────── */
.skeleton {
    background: linear-gradient(90deg,
        var(--bg-elevated) 25%,
        var(--bg-hover) 50%,
        var(--bg-elevated) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--r);
}
@keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position:  200% 0; }
}

/* ── Animations ────────────────────────────────────────────── */
.animate-ready {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}
.animate-ready.animate-in {
    opacity: 1;
    transform: translateY(0);
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
    .animate-ready { opacity: 1; transform: none; }
}

/* ── Legal Pages ───────────────────────────────────────────── */
.legal-page { padding-block: var(--sp-12); }
.legal-content {
    line-height: 1.8;
    color: var(--text-secondary);
    margin-top: var(--sp-6);
}

/* ── Contact ───────────────────────────────────────────────── */
.contact-page { padding-block: var(--sp-12); }
.contact-info { display: flex; flex-direction: column; gap: var(--sp-3); margin-block: var(--sp-6); }
.contact-info p { font-size: var(--text-base); }
.contact-info a { color: var(--brand); }

/* ── Utility classes ───────────────────────────────────────── */
.text-xs    { font-size: var(--text-xs); }
.text-sm    { font-size: var(--text-sm); }
.text-muted { color: var(--text-muted); }

/* ── Table action cell ─────────────────────────────────────── */
.table-actions-cell {
    display: flex;
    gap: var(--sp-2);
    align-items: center;
}

/* ── Proxy card header row ─────────────────────────────────── */
.proxy-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--sp-2);
}
.proxy-card-actions {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

/* ── Classes page intro text ───────────────────────────────── */
.classes-intro {
    color: var(--text-muted);
    font-size: var(--text-sm);
    margin-bottom: var(--sp-4);
    line-height: 1.7;
}

/* ── Proxy buy intro text ──────────────────────────────────── */
.proxy-buy-intro {
    color: var(--text-muted);
    font-size: var(--text-sm);
    margin-bottom: var(--sp-5);
    line-height: 1.6;
}
