/* ============================================================
   SANYA — Stylesheet
   Brand colors: NetPoa (#0191FB blue, #08F5DA cyan, #0E1833 navy)
   Lightweight, modern, mobile-first.
   ============================================================ */

:root {
    /* NetPoa brand */
    --c-primary: #0191FB;        /* blue — main */
    --c-primary-dark: #0E1833;   /* navy — hover/dark */
    --c-accent: #08F5DA;         /* cyan — highlights, Pro */

    --c-bg: #f8fafc;
    --c-surface: #ffffff;
    --c-border: #e2e8f0;
    --c-text: #0E1833;           /* navy text */
    --c-muted: #64748b;
    --c-success: #16a34a;
    --c-danger: #dc2626;
    --c-warning: #d97706;
    --c-info: #0191FB;

    /* Brand gradient — kutumika kwa hero, login, kadi za pro */
    --grad-brand: linear-gradient(135deg, #08F5DA 0%, #0191FB 60%, #0E1833 100%);
    --grad-primary: linear-gradient(135deg, #0191FB 0%, #0E1833 100%);

    --radius: 8px;
    --shadow: 0 1px 3px rgba(14,24,51,0.06), 0 1px 2px rgba(14,24,51,0.04);
    --shadow-lg: 0 10px 15px -3px rgba(14,24,51,0.1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--c-bg);
    color: var(--c-text);
    line-height: 1.55;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
    letter-spacing: -0.01em;
}

h1, h2, h3, h4, h5 { font-weight: 700; letter-spacing: -0.02em; line-height: 1.25; color: var(--c-text); }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }

a { color: var(--c-primary); text-decoration: none; transition: color .15s ease; }
a:hover { color: var(--c-primary-dark); text-decoration: underline; }

/* Smooth transitions kwa interactive elements */
button, .btn, input, select, textarea { transition: all .15s ease; }

.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;
}
/* Drawer wrapper — desktop: invisible passthrough; mobile: real drawer container */
.drawer { display: contents; }
.brand {
    display: flex; align-items: center; gap: 0.5rem;
    color: var(--c-text); font-size: 1.15rem; font-weight: 800;
    letter-spacing: -0.02em;
    text-decoration: none !important;
}
.brand strong { font-weight: 800; }
.brand-icon { font-size: 1.4rem; }
.nav { display: flex; gap: 0.25rem; flex: 1; }
.nav a {
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius);
    color: var(--c-muted);
    font-weight: 500;
}
.nav a:hover { background: rgba(1, 145, 251, 0.08); text-decoration: none; color: var(--c-primary); }
.nav a.active { background: var(--c-primary); color: #fff; }

/* Nav dropdown (desktop hover-to-show) */
.nav-dropdown { position: relative; }
.nav-dropdown-trigger { display: inline-flex; align-items: center; gap: .25rem; }
.caret { font-size: .65em; opacity: .65; }
.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px); left: 0;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    padding: 0.35rem;
    z-index: 60;
}
.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu { display: flex; flex-direction: column; }
.nav-dropdown-menu a { padding: 0.55rem 0.75rem; font-size: .9rem; white-space: nowrap; }

.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; }

/* Hamburger button (mobile only) */
.hamburger {
    display: none; align-items: center; justify-content: center;
    width: 40px; height: 40px; padding: 0;
    background: transparent; border: 1px solid var(--c-border);
    border-radius: var(--radius); cursor: pointer;
    color: var(--c-text);
}
.hamburger:hover { background: var(--c-bg); border-color: var(--c-primary); }
.hamburger span {
    display: block; width: 18px; height: 2px; background: currentColor;
    margin: 3px 0; border-radius: 2px; transition: transform .25s, opacity .25s;
}
.hamburger.open span:nth-child(1) { transform: translateY(5px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-5px) rotate(-45deg); }

/* Backdrop wakati menu imefunguka */
.nav-backdrop { display: none; position: fixed; inset: 0; background: rgba(14,24,51,0.5); z-index: 49; }
.nav-backdrop.show { display: block; }

.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; }
.sub-badge.sub-free     { background: #cffafe; color: #0E1833; }

/* ---------- 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: 12px;
    padding: 1.25rem;
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
    transition: box-shadow .2s ease;
}
.card:hover { box-shadow: 0 4px 12px rgba(14,24,51,0.06); }
.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.1rem 1.25rem; border-radius: 12px;
    border: 1px solid var(--c-border); box-shadow: var(--shadow);
    transition: transform .2s ease, box-shadow .2s ease;
}
.stat:hover { transform: translateY(-2px); box-shadow: 0 6px 14px rgba(14,24,51,0.08); }
.stat-label { color: var(--c-muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.stat-value { font-size: 1.6rem; font-weight: 800; color: var(--c-text); margin-top: 0.25rem; letter-spacing: -0.02em; }
.stat-icon  { float: right; font-size: 1.4rem; opacity: 0.5; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
    padding: 0.6rem 1.15rem;
    background: var(--c-primary); color: #fff !important;
    border: none; border-radius: var(--radius);
    font-size: 0.9rem; font-weight: 600; letter-spacing: -0.01em;
    cursor: pointer; text-decoration: none !important;
    box-shadow: 0 1px 2px rgba(1,145,251,0.25);
    transition: all 0.18s ease;
}
.btn:hover  { background: var(--c-primary-dark); transform: translateY(-1px); box-shadow: 0 4px 8px rgba(14,24,51,0.15); }
.btn:active { transform: translateY(0); }
.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.25rem 0.65rem; border-radius: 999px;
    font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
}
.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: var(--grad-brand);
    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: var(--grad-brand);
    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: 768px) {
    body { font-size: 14px; }

    /* Topbar: brand kushoto, hamburger kulia */
    .topbar .container {
        padding: 0.5rem 0.75rem;
        gap: 0.5rem;
        justify-content: space-between;
    }
    .brand { font-size: 1rem; }
    .brand-icon { font-size: 1.3rem; }
    .brand strong { font-size: 1rem; }

    /* Hamburger button onyeshwa */
    .hamburger { display: flex; flex-direction: column; }

    /* Drawer — wrapper inakuwa real container badala ya display:contents */
    .drawer {
        display: flex !important;
        position: fixed;
        top: 0; right: -320px;
        width: 300px; max-width: 85vw;
        height: 100vh; height: 100dvh;
        background: #fff;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 0;
        box-shadow: -4px 0 24px rgba(14,24,51,0.18);
        z-index: 60;
        transition: right .25s ease;
        visibility: hidden;
    }
    .drawer.open {
        right: 0;
        visibility: visible;
    }

    /* Nav inajaza nafasi ya juu na ina-scroll, user-menu ina-pin chini */
    .drawer .nav {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 0.2rem;
        width: 100%;
        position: static;
        background: transparent;
        padding: 1.25rem 1rem 0.5rem;
        box-shadow: none;
        flex: 1 1 auto;
        overflow-y: auto;
        min-height: 0;
    }

    /* User-menu — sticky kwa chini, daima inaonekana */
    .drawer .user-menu {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 0.4rem;
        width: 100%;
        position: static;
        background: var(--c-bg);
        padding: 1rem;
        box-shadow: none;
        border-top: 1px solid var(--c-border);
        flex-shrink: 0;
    }

    .drawer .nav a,
    .drawer .user-menu a {
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
        font-weight: 500;
        border-radius: var(--radius);
        text-align: left;
        white-space: nowrap;
    }
    .drawer .nav a:hover,
    .drawer .user-menu a:hover { background: rgba(1,145,251,.08); color: var(--c-primary); }
    .drawer .nav a.active { background: var(--c-primary); color: #fff; }

    /* Mobile drawer: dropdown wrapper iko-flatten — items zinaonekana inline */
    .drawer .nav-dropdown { display: contents; }
    .drawer .nav-dropdown-menu { display: contents; }
    .drawer .nav-dropdown-trigger .caret { display: none; }
    .drawer .sub-badge {
        align-self: flex-start;
        font-size: 0.7rem;
        padding: 0.3rem 0.7rem;
        margin-bottom: 0.25rem;
    }
    .drawer .user-menu > a:not(.logout) {
        max-width: none;
        font-weight: 700;
        color: var(--c-text);
        background: #fff;
    }
    .drawer .user-menu .logout {
        background: rgba(220,38,38,0.08) !important;
        color: var(--c-danger) !important;
        font-weight: 600;
        text-align: center;
    }
    .drawer .user-menu .logout:hover {
        background: rgba(220,38,38,0.15) !important;
    }

    .sub-badge {
        font-size: 0.75rem;
        padding: 0.3rem 0.6rem;
        margin-bottom: 0.5rem;
        align-self: flex-start;
    }
    .user-menu > a:not(.logout) { max-width: none; overflow: visible; }

    /* 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; }
}
