/* ============================================
   AZALEA COIN - BASE STYLES (Mobile-First)
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@600;700&display=swap');

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

/* GLOBAL IMAGE SAFETY - no image can ever exceed its container, so a
   missing/stale stylesheet can never blow a logo up to full width again. */
img { max-width: 100%; height: auto; }

/* GLOBAL SVG SAFETY - an inline <svg> with no width/height renders at the
   container's full width (and fills solid black without a fill override).
   This guarantees a sane ceiling even if a stylesheet is stale or missing. */
svg { max-width: 100%; }
.stat-icon svg, .card-icon svg, .action-tile-icon svg { display: block; }
html { font-size: 16px; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f5f7;
    color: #1f2937;
    line-height: 1.5;
}

h1, h2, h3 { font-family: 'Cinzel', serif; font-weight: 600; }

.sidebar-brand-mark { width: 28px; height: 28px; vertical-align: middle; margin-right: 4px; }

a { color: #A87C18; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== LAYOUT ===== */
.container {
    width: 100%;
    padding: 15px;
    max-width: 480px;
    margin: 0 auto;
}

.card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 15px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.text-center { text-align: center; }

/* ===== AUTH ===== */
.auth-container { display: flex; align-items: center; min-height: 100vh; }
.auth-logo { width: 64px; height: 64px; margin-bottom: 16px; }
.auth-switch { margin-top: 16px; text-align: center; font-size: 14px; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; }
.form-group small { display: block; color: #6b7280; font-size: 12px; margin-top: 4px; }

.input-field {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #fafafa;
}
.input-field:focus { outline: none; border-color: #D9AC3C; background: #fff; }

.field-error { display: block; color: #dc2626; font-size: 13px; margin-top: 4px; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-block;
    padding: 14px 20px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    text-align: center;
    min-height: 44px;
}
.btn-block { width: 100%; }
.btn-primary { background: #D9AC3C; color: #141414; }
.btn-primary:hover { background: #A87C18; color: #141414; text-decoration: none; }
.btn-secondary { background: #e5e7eb; color: #1f2937; }
.btn-secondary:hover { background: #d1d5db; text-decoration: none; }
.btn-warning { background: #f59e0b; color: #fff; }
.btn-warning:hover { background: #d97706; text-decoration: none; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; text-decoration: none; }

/* ===== PAGINATION ===== */
.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 16px; padding: 12px; }
.pagination-info { font-size: 13px; color: #6b7280; }
.filter-bar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }

/* ===== ALERTS ===== */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-success { background: #d1fae5; color: #065f46; }
.notice { color: #6b7280; font-size: 14px; margin: 12px 0; }

/* ===== LANDING ===== */
.landing { display: flex; flex-direction: column; min-height: 100vh; justify-content: center; }
.landing-header { text-align: center; margin-bottom: 40px; }
.landing-logo { width: 88px; height: 88px; margin-bottom: 16px; }
.landing-header h1 { font-size: 32px; color: #A87C18; font-family: 'Cinzel', serif; font-weight: 700; }
.landing-tagline { font-family: 'Cinzel', serif; color: #7C580D; letter-spacing: 0.15em; font-size: 12px; text-transform: uppercase; margin-top: 4px; }
.landing-actions { display: flex; flex-direction: column; gap: 12px; }
.landing-footer { text-align: center; margin-top: 40px; font-size: 13px; color: #9ca3af; }

/* ===== ERROR PAGES ===== */
.error-container { display: flex; align-items: center; min-height: 100vh; }
.error-container h1 { font-size: 48px; color: #A87C18; margin-bottom: 12px; font-family: 'Cinzel', serif; }

/* ===== RESPONSIVE TABLES ===== */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 480px) {
    .table thead { display: none; }
    .table tr { display: block; margin-bottom: 15px; border: 1px solid #ddd; padding: 10px; border-radius: 8px; }
    .table td { display: block; text-align: left; padding: 5px 0; border: none; }
    .table td::before { content: attr(data-label); font-weight: bold; display: inline-block; width: 120px; }
}

/* ===== TABLET (481px+) ===== */
@media (min-width: 481px) {
    .container { padding: 20px; max-width: 720px; }
    .landing-actions { flex-direction: row; justify-content: center; }
    .btn { width: auto; }
}

/* ===== DESKTOP (769px+) ===== */
@media (min-width: 769px) {
    .container { max-width: 960px; padding: 30px; }
}

/* ===== LARGE DESKTOP (1025px+) ===== */
@media (min-width: 1025px) {
    .container { max-width: 1100px; }
}

/* ============================================
   AUTH PAGE NAVIGATION
   Public auth pages (login/register/forgot/reset/2FA) previously had
   no route back to the public site - a user who landed on /login.php
   had no way home short of editing the URL. The logo is now a link,
   plus an explicit back link for anyone who doesn't think to click it.
   ============================================ */
.auth-home {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 14px;
    font-size: 14px;
    font-weight: 600;
    color: #6b7280;
}
.auth-home:hover { color: #A87C18; text-decoration: none; }
.auth-home::before { content: '\2190'; font-size: 16px; }

.auth-logo-link { display: inline-block; }
.auth-logo-link:hover { text-decoration: none; }

.auth-footer-links {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid #e5e7eb;
    text-align: center;
    font-size: 13px;
    color: #6b7280;
}
.auth-footer-links a { color: #6b7280; margin: 0 6px; }
.auth-footer-links a:hover { color: #A87C18; }

/* ============================================
   PROGRESS BARS
   Used for cycle day progress and earning-cap usage.
   ============================================ */
.progress {
    width: 100%;
    height: 8px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
    margin: 8px 0 4px;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #A87C18, #D9AC3C);
    border-radius: 999px;
    transition: width .3s ease;
}
.progress-fill.is-full { background: linear-gradient(90deg, #b91c1c, #ef4444); }
.progress-fill.is-near { background: linear-gradient(90deg, #b45309, #f59e0b); }

.progress-meta {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: #6b7280;
}

/* ============================================
   REFERRAL LEVEL PILLS (spec 11.1 - level N
   unlocks at N direct referrals)
   ============================================ */
.level-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.level-pill {
    flex: 1 1 auto;
    min-width: 84px;
    text-align: center;
    padding: 8px 6px;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    opacity: .55;
}
.level-pill.unlocked {
    opacity: 1;
    border-color: #A87C18;
    background: #fffaf0;
}
.level-pill-label { display: block; font-size: 13px; color: #6b7280; }
.level-pill-rate { display: block; font-size: 20px; font-weight: 700; color: #1f2937; line-height: 1.3; }
.level-pill.unlocked .level-pill-rate { color: #A87C18; }
.level-pill-state { display: block; font-size: 12px; margin-top: 3px; color: #6b7280; }


/* ============================================
   MOBILE READABILITY FLOOR (spec 19.1:
   "Readable Text - Min font size 16px on mobile")
   Small meta text is fine on desktop but drops below the
   spec's mobile minimum on phones, so it scales up there.
   ============================================ */
@media (max-width: 480px) {
    body { font-size: 16px; }
    .notice,
    .list-item-meta,
    .stat-card-sub,
    .progress-meta,
    .qualify-note,
    .action-tile-sub,
    .level-pill-label { font-size: 15px; }
    .stat-card-label { font-size: 15px; }
    .stat-card-value { font-size: 24px; }
    .level-pill { min-width: 92px; }
}

/* ============================================
   SIDEBAR ACCORDION (user + admin)
   Vanilla CSS/JS - no framework, per spec 2.2.
   Collapsed by default; the group containing the active page is
   rendered already-open server-side, so nav never hides where you are.
   ============================================ */
.sidebar-group { display: block; }

.sidebar-group-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 13px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #C9A45C;
    min-height: 44px;
    text-align: left;
}
.sidebar-group-toggle:hover { color: #F0D48A; background: rgba(217,172,60,0.08); }

.sidebar-chevron {
    font-size: 11px;
    transition: transform .2s ease;
    flex: 0 0 auto;
    margin-left: 8px;
}
.sidebar-group-toggle.open .sidebar-chevron { transform: rotate(180deg); }

/* Collapsed by default. max-height keeps the open/close animated without
   needing JS to measure heights. */
.sidebar-group-items {
    list-style: none;
    max-height: 0;
    overflow: hidden;
    transition: max-height .25s ease;
}
.sidebar-group-items.open { max-height: 600px; }
.sidebar-group-items .sidebar-link { padding-left: 30px; font-size: 14px; }

/* No-JS fallback: if scripts fail, every group is left open rather than
   leaving the user with a nav they cannot expand. */
.no-js .sidebar-group-items { max-height: none; }

/* ============================================
   AUTH PAGES - centred, elevated layout
   Replaces the plain left-aligned card. The shell centres both
   axes at any viewport height, and the card widens on register
   (a 9-field form) while staying narrow on login.
   ============================================ */
.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px 16px;
    background:
        radial-gradient(1100px 520px at 50% -10%, #fdf6e6 0%, rgba(253,246,230,0) 70%),
        linear-gradient(180deg, #faf9f7 0%, #f2f1ee 100%);
}

.auth-card {
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
    background: #fff;
    border-radius: 18px;
    padding: 32px 26px;
    box-shadow:
        0 1px 2px rgba(24,20,10,0.05),
        0 12px 32px rgba(24,20,10,0.10);
    border-top: 3px solid #D9AC3C;
}
.auth-card.is-wide { max-width: 620px; }

/* Brand block */
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-brand .auth-logo-link { display: inline-block; }
.auth-brand img { width: 62px; height: 62px; margin-bottom: 10px; }
.auth-brand h1 {
    font-family: 'Cinzel', serif;
    font-size: 25px;
    color: #A87C18;
    letter-spacing: .02em;
    margin-bottom: 4px;
}
.auth-brand p {
    font-size: 14px;
    color: #6b7280;
    max-width: 340px;
    margin: 0 auto;
}

/* Back link sits above the brand, out of the way */
.auth-top { margin-bottom: 6px; }

/* Inputs get a clearer focus ring than the base style */
.auth-card .input-field {
    border-radius: 10px;
    background: #fcfcfd;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.auth-card .input-field:focus {
    outline: none;
    background: #fff;
    border-color: #D9AC3C;
    box-shadow: 0 0 0 3px rgba(217,172,60,0.18);
}
.auth-card .form-group label { font-size: 14px; color: #374151; }

.auth-card .btn-primary {
    border-radius: 10px;
    padding: 14px;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: .01em;
}

/* Two-up rows on wider screens so the register form isn't a
   nine-field column. Collapses to single column on mobile. */
.auth-row { display: grid; grid-template-columns: 1fr; gap: 0 16px; }
@media (min-width: 560px) {
    .auth-row.cols-2 { grid-template-columns: 1fr 1fr; }
}

/* Divider between the form and the switch link */
.auth-sep {
    display: flex; align-items: center; gap: 12px;
    margin: 20px 0 14px;
    color: #9ca3af; font-size: 13px;
}
.auth-sep::before, .auth-sep::after {
    content: ''; flex: 1; height: 1px; background: #e5e7eb;
}

.auth-switch { margin-top: 0; font-size: 15px; }
.auth-switch a { font-weight: 700; }

/* Section heading inside the register form */
.auth-section {
    margin: 22px 0 10px;
    padding-top: 16px;
    border-top: 1px solid #f0efec;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #A87C18;
}
.auth-section:first-of-type { border-top: none; padding-top: 0; }
.auth-section-hint {
    font-weight: 400; text-transform: none; letter-spacing: 0;
    color: #6b7280; font-size: 13px; display: block; margin-top: 3px;
}

@media (max-width: 480px) {
    .auth-card { padding: 24px 18px; border-radius: 14px; }
    .auth-brand h1 { font-size: 22px; }
}
