/* ============================================================
   Changisha — Stylesheet
   Lightweight, modern, mobile-first.
   ============================================================ */

:root {
    --c-primary: #0f766e;
    --c-primary-dark: #115e59;
    --c-accent: #f59e0b;
    --c-bg: #f8fafc;
    --c-surface: #ffffff;
    --c-border: #e2e8f0;
    --c-text: #0f172a;
    --c-muted: #64748b;
    --c-success: #16a34a;
    --c-danger: #dc2626;
    --c-warning: #d97706;
    --c-info: #2563eb;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--c-bg);
    color: var(--c-text);
    line-height: 1.5;
    font-size: 15px;
}

a { color: var(--c-primary); text-decoration: none; }
a:hover { color: var(--c-primary-dark); text-decoration: underline; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 1rem; }

/* ---------- Topbar ---------- */
.topbar {
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
    box-shadow: var(--shadow);
    position: sticky; top: 0; z-index: 50;
}
.topbar .container {
    display: flex; align-items: center; gap: 1rem;
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
}
.brand {
    display: flex; align-items: center; gap: 0.5rem;
    color: var(--c-text); font-size: 1.1rem;
    text-decoration: none !important;
}
.brand-icon { font-size: 1.4rem; }
.nav { display: flex; gap: 0.25rem; flex: 1; flex-wrap: wrap; }
.nav a {
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius);
    color: var(--c-muted);
    font-weight: 500;
}
.nav a:hover { background: var(--c-bg); text-decoration: none; }
.nav a.active { background: var(--c-primary); color: #fff; }
.user-menu { display: flex; align-items: center; gap: 0.75rem; }
.user-menu a { color: var(--c-muted); font-size: 0.9rem; }
.user-menu a:hover { color: var(--c-primary); }
.logout { color: var(--c-danger) !important; }

.sub-badge {
    font-size: 0.75rem; font-weight: 600;
    padding: 0.25rem 0.6rem; border-radius: 999px;
    background: var(--c-bg);
}
.sub-badge.sub-active   { background: #dcfce7; color: #166534; }
.sub-badge.sub-expired  { background: #fee2e2; color: #991b1b; }
.sub-badge.sub-admin    { background: #ede9fe; color: #5b21b6; }

/* ---------- Banners ---------- */
.banner {
    margin-top: 1rem; padding: 0.75rem 1rem;
    border-radius: var(--radius);
    display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
    justify-content: space-between;
}
.banner-warning { background: #fef3c7; color: #78350f; border: 1px solid #fcd34d; }

/* ---------- Main ---------- */
.main-content { padding: 2rem 1rem; min-height: calc(100vh - 130px); }

/* ---------- Cards ---------- */
.card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}
.card-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1rem; padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--c-border);
}
.card-header h2 { margin: 0; font-size: 1.15rem; }

/* ---------- Page header ---------- */
.page-head {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1.5rem; flex-wrap: wrap; gap: 0.5rem;
}
.page-head h1 { margin: 0; font-size: 1.5rem; }
.page-head p  { margin: 0.25rem 0 0; color: var(--c-muted); }

/* ---------- Stat cards ---------- */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem; margin-bottom: 1.5rem;
}
.stat {
    background: var(--c-surface);
    padding: 1.25rem; border-radius: var(--radius);
    border: 1px solid var(--c-border); box-shadow: var(--shadow);
}
.stat-label { color: var(--c-muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--c-text); margin-top: 0.25rem; }
.stat-icon  { float: right; font-size: 1.4rem; opacity: 0.5; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    background: var(--c-primary); color: #fff !important;
    border: none; border-radius: var(--radius);
    font-size: 0.9rem; font-weight: 500;
    cursor: pointer; text-decoration: none !important;
    transition: background 0.15s;
}
.btn:hover  { background: var(--c-primary-dark); }
.btn-sm     { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-block  { display: flex; width: 100%; justify-content: center; }
.btn-secondary { background: var(--c-muted); }
.btn-secondary:hover { background: #475569; }
.btn-success   { background: var(--c-success); }
.btn-success:hover { background: #15803d; }
.btn-danger    { background: var(--c-danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-warning   { background: var(--c-warning); color: #fff !important; }
.btn-outline   { background: transparent; color: var(--c-primary) !important; border: 1px solid var(--c-primary); }
.btn-outline:hover { background: var(--c-primary); color: #fff !important; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 1rem; }
.form-row   { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
label { display: block; font-weight: 500; margin-bottom: 0.35rem; font-size: 0.9rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="tel"], select, textarea {
    width: 100%; padding: 0.6rem 0.75rem;
    border: 1px solid var(--c-border); border-radius: var(--radius);
    font-size: 0.95rem; font-family: inherit; background: #fff;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.1);
}
textarea { resize: vertical; min-height: 80px; }
.form-help { font-size: 0.8rem; color: var(--c-muted); margin-top: 0.25rem; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data {
    width: 100%; border-collapse: collapse; background: var(--c-surface);
    border-radius: var(--radius); overflow: hidden; border: 1px solid var(--c-border);
}
table.data th, table.data td { padding: 0.7rem 0.85rem; text-align: left; border-bottom: 1px solid var(--c-border); }
table.data th { background: var(--c-bg); font-size: 0.8rem; text-transform: uppercase; color: var(--c-muted); font-weight: 600; letter-spacing: 0.05em; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: #fafbfc; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Alerts ---------- */
.alert { padding: 0.75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid; }
.alert-success { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.alert-danger  { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.alert-warning { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.alert-info    { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }

/* ---------- Badges ---------- */
.badge {
    display: inline-block; padding: 0.2rem 0.55rem; border-radius: 999px;
    font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em;
}
.badge-pending  { background: #fef3c7; color: #92400e; }
.badge-approved { background: #dcfce7; color: #166534; }
.badge-rejected { background: #fee2e2; color: #991b1b; }
.badge-active   { background: #dcfce7; color: #166534; }
.badge-closed   { background: #e2e8f0; color: #475569; }
.badge-archived { background: #fef3c7; color: #92400e; }

/* ---------- Auth pages ---------- */
.auth-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #0f766e 0%, #134e4a 100%);
    padding: 2rem 1rem;
}
.auth-card {
    background: #fff; padding: 2rem; border-radius: 12px;
    box-shadow: var(--shadow-lg); width: 100%; max-width: 420px;
}
.auth-card h1 { margin-top: 0; text-align: center; color: var(--c-primary); }
.auth-card .brand-icon { font-size: 3rem; display: block; text-align: center; margin-bottom: 0.5rem; }
.auth-card .small { text-align: center; margin-top: 1rem; color: var(--c-muted); font-size: 0.9rem; }

/* ---------- Footer ---------- */
.footer { background: var(--c-surface); border-top: 1px solid var(--c-border); padding: 1.25rem 0; margin-top: 2rem; color: var(--c-muted); font-size: 0.85rem; text-align: center; }

/* ---------- Utilities ---------- */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 0.5rem; } .gap-2 { gap: 1rem; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 0.5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 0.5rem; } .mb-2 { margin-bottom: 1rem; }
.text-muted { color: var(--c-muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-success { color: var(--c-success); }
.text-danger  { color: var(--c-danger); }
.font-bold { font-weight: 700; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--c-muted); }
.empty-state .icon { font-size: 3rem; opacity: 0.5; margin-bottom: 0.5rem; }

/* ---------- Hero (homepage) ---------- */
.hero {
    background: linear-gradient(135deg, #0f766e 0%, #134e4a 100%);
    color: #fff; padding: 4rem 1rem; text-align: center;
    border-radius: var(--radius); margin-bottom: 2rem;
}
.hero h1 { font-size: 2.5rem; margin: 0 0 0.5rem; }
.hero p  { font-size: 1.1rem; opacity: 0.9; margin: 0 0 1.5rem; }
.hero .btn { background: var(--c-accent); }
.hero .btn:hover { background: #d97706; }

.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.feature { background: var(--c-surface); padding: 1.5rem; border-radius: var(--radius); border: 1px solid var(--c-border); }
.feature .ico { font-size: 2rem; margin-bottom: 0.5rem; }
.feature h3 { margin: 0 0 0.5rem; }

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
    body { font-size: 14px; }

    /* Topbar: row 1 = brand + user actions kona ya kulia, row 2 = nav full-width */
    .topbar .container {
        padding: 0.5rem 0.75rem;
        gap: 0.5rem;
        align-items: center;
        justify-content: space-between;
    }
    .brand { font-size: 1rem; }
    .brand-icon { font-size: 1.2rem; }
    .brand strong { font-size: 1rem; }

    /* User menu — tighter, name truncated */
    .user-menu {
        gap: 0.4rem;
        font-size: 0.8rem;
        flex-shrink: 0;
    }
    .user-menu > a:not(.logout) {
        max-width: 90px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .sub-badge {
        font-size: 0.65rem;
        padding: 0.15rem 0.45rem;
    }

    /* Nav: full-width row 2, horizontal scroll badala ya kuwrap */
    .nav {
        order: 3;
        width: 100%;
        gap: 0.15rem;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 0.25rem;
        border-top: 1px solid var(--c-border);
        margin-top: 0.25rem;
        padding-top: 0.5rem;
    }
    .nav::-webkit-scrollbar { display: none; }
    .nav a {
        padding: 0.4rem 0.7rem;
        font-size: 0.8rem;
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Banner */
    .banner { font-size: 0.85rem; padding: 0.5rem 0.75rem; }

    /* Main */
    .main-content { padding: 1rem 0.75rem; }

    /* Page head — title + button stack vizuri */
    .page-head {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    .page-head h1 { font-size: 1.25rem; }
    .page-head p { font-size: 0.85rem; }
    .page-head .btn { width: 100%; justify-content: center; }

    /* Stats */
    .stats { grid-template-columns: 1fr 1fr; gap: 0.75rem; }
    .stat { padding: 0.85rem; }
    .stat-label { font-size: 0.7rem; }
    .stat-value { font-size: 1.2rem; }
    .stat-icon { font-size: 1.1rem; }

    /* Cards */
    .card { padding: 0.85rem; }
    .card-header h2 { font-size: 1rem; }

    /* Forms — full-width inputs */
    .form-row { grid-template-columns: 1fr; }

    /* Tables — keep horizontal scroll */
    table.data { font-size: 0.8rem; }
    table.data th, table.data td { padding: 0.5rem 0.5rem; }

    /* Hero */
    .hero { padding: 2rem 1rem; }
    .hero h1 { font-size: 1.5rem; }
    .hero p { font-size: 0.9rem; }

    /* Auth card */
    .auth-card { padding: 1.5rem 1.25rem; }
    .auth-card h1 { font-size: 1.5rem; }

    /* Footer */
    .footer { font-size: 0.75rem; padding: 0.75rem 0; }
    .footer .container span { display: block; line-height: 1.6; }
}

@media (max-width: 380px) {
    .stats { grid-template-columns: 1fr; }
    .stat-value { font-size: 1.1rem; }
}
