/* ============================================================
   MISI - Donation Collection Tracking System
   Mobile-first stylesheet
   ============================================================ */

/* ---- Reset & base ---------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary:       #2563eb;
    --primary-dark:  #1d4ed8;
    --primary-light: #dbeafe;
    --success:       #16a34a;
    --success-light: #dcfce7;
    --warning:       #d97706;
    --warning-light: #fef3c7;
    --danger:        #dc2626;
    --danger-light:  #fee2e2;
    --gray-50:       #f9fafb;
    --gray-100:      #f3f4f6;
    --gray-200:      #e5e7eb;
    --gray-400:      #9ca3af;
    --gray-500:      #6b7280;
    --gray-700:      #374151;
    --gray-900:      #111827;
    --white:         #ffffff;
    --radius:        8px;
    --radius-sm:     4px;
    --shadow-sm:     0 1px 3px rgba(0,0,0,.08);
    --shadow:        0 4px 12px rgba(0,0,0,.10);
    --font:          -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
}

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

body {
    font-family: var(--font);
    background: var(--gray-100);
    color: var(--gray-900);
    line-height: 1.55;
    min-height: 100vh;
}

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

/* ---- Topbar ---------------------------------------------- */
.topbar {
    background: var(--gray-900);
    color: var(--white);
    height: 56px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
}

.topbar-brand {
    color: var(--white);
    font-weight: 700;
    font-size: 15px;
    white-space: nowrap;
    flex-shrink: 0;
    text-decoration: none;
}

/* hamburger */
.nav-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 36px;
    height: 36px;
    padding: 4px;
    background: none;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
}
.nav-toggle span {
    display: block;
    height: 2px;
    background: #d1d5db;
    border-radius: 2px;
    transition: all .2s;
}
.nav-toggle:hover span { background: var(--white); }

/* slide-down mobile nav */
.topbar-nav {
    display: none;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    background: var(--gray-900);
    flex-direction: column;
    padding: 8px 0 12px;
    box-shadow: 0 6px 16px rgba(0,0,0,.3);
    z-index: 99;
}
.topbar-nav.open { display: flex; }
.topbar-nav a {
    color: #d1d5db;
    text-decoration: none;
    padding: 11px 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.topbar-nav a:hover, .topbar-nav a.active {
    background: rgba(255,255,255,.07);
    color: var(--white);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.topbar-user, .topbar-logout, .topbar-user-label {
    color: #9ca3af;
    font-size: 13px;
    text-decoration: none;
}
.topbar-user:hover, .topbar-logout:hover { color: var(--white); }

.badge-count {
    background: var(--danger);
    color: var(--white);
    border-radius: 10px;
    padding: 1px 6px;
    font-size: 11px;
    font-weight: 700;
}

/* desktop nav */
@media (min-width: 768px) {
    .nav-toggle { display: none; }
    .topbar { padding: 0 24px; }
    .topbar-nav {
        display: flex !important;
        position: static;
        flex-direction: row;
        background: none;
        padding: 0;
        box-shadow: none;
        flex: 1;
        justify-content: center;
        gap: 2px;
    }
    .topbar-nav a {
        padding: 6px 12px;
        border-radius: var(--radius-sm);
        white-space: nowrap;
    }
    .topbar-user-label { display: inline; }
}

/* ---- Layout ---------------------------------------------- */
.container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 16px;
}
.container-wide  { max-width: 1280px; }
.container-narrow { max-width: 560px; }

@media (min-width: 768px) {
    .container { padding: 24px; }
}

h1 { font-size: 22px; font-weight: 700; margin-bottom: 16px; color: var(--gray-900); }
h2 { font-size: 17px; font-weight: 700; }

.section-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--gray-700);
    margin: 24px 0 10px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--gray-200);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}

/* ---- Stat cards ------------------------------------------ */
.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

@media (min-width: 640px)  { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .stat-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; } }

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--primary);
    transition: box-shadow .15s;
}
.stat-card:hover { box-shadow: var(--shadow); }
.stat-card.green  { border-left-color: var(--success); }
.stat-card.amber  { border-left-color: var(--warning); }
.stat-card.gray   { border-left-color: var(--gray-400); }
.stat-card.purple { border-left-color: #7c3aed; }

.stat-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 4px;
}
.stat-value {
    font-size: clamp(18px, 4vw, 24px);
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.2;
}
.stat-sub {
    font-size: 12px;
    color: var(--gray-400);
    margin-top: 2px;
}

/* ---- Buttons --------------------------------------------- */
.btn, button[type="submit"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--primary);
    color: var(--white);
    text-decoration: none;
    padding: 9px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, box-shadow .15s;
    white-space: nowrap;
    font-family: var(--font);
}
.btn:hover, button[type="submit"]:hover {
    background: var(--primary-dark);
    text-decoration: none;
    color: var(--white);
    box-shadow: 0 2px 8px rgba(37,99,235,.3);
}
.btn-success { background: var(--success); }
.btn-success:hover { background: #15803d; box-shadow: 0 2px 8px rgba(22,163,74,.3); }
.btn-gray { background: var(--gray-500); }
.btn-gray:hover { background: var(--gray-700); }
.btn-sm { padding: 6px 14px; font-size: 13px; }

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
    box-shadow: none;
}
.btn-outline:hover {
    background: var(--primary-light);
    color: var(--primary-dark);
    box-shadow: none;
    text-decoration: none;
}

.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

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

/* ---- Quick nav links ------------------------------------- */
.quick-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}
.quick-links a {
    display: inline-block;
    padding: 6px 14px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 20px;
    font-size: 13px;
    color: var(--primary);
    font-weight: 500;
}
.quick-links a:hover { background: var(--primary-light); border-color: var(--primary); text-decoration: none; }

/* ---- Alerts ---------------------------------------------- */
.alert {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 16px;
    line-height: 1.5;
}
.alert a { font-weight: 600; }
.alert-error   { background: var(--danger-light);  color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: var(--success-light); color: #166534; border: 1px solid #86efac; }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fcd34d; }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fcd34d; }

/* ---- Badges ---------------------------------------------- */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}
.badge-green  { background: var(--success-light); color: #166534; }
.badge-gray   { background: var(--gray-100);      color: var(--gray-500); }
.badge-amber  { background: var(--warning-light); color: #92400e; }
.badge-red    { background: var(--danger-light);  color: #991b1b; }
.badge-blue   { background: var(--primary-light); color: #1e40af; }

/* ---- Tables ---------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); box-shadow: var(--shadow-sm); }

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    font-size: 13px;
    min-width: 520px;
}
.data-table th, .data-table td {
    text-align: left;
    padding: 10px 14px;
    border-bottom: 1px solid var(--gray-100);
    white-space: nowrap;
}
.data-table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-500);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid var(--gray-200);
}
.data-table tbody tr:hover { background: var(--gray-50); }
.data-table .actions { display: flex; gap: 10px; align-items: center; }

.subtotal-row td { background: var(--gray-50); font-weight: 600; border-top: 1px solid var(--gray-200); }
.grand-total-row td { background: var(--primary-light); font-weight: 700; border-top: 2px solid #93c5fd; }

/* ---- Forms ----------------------------------------------- */
.form-card {
    background: var(--white);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 16px;
}

@media (min-width: 640px) { .form-card { padding: 24px; } }

.form-card label {
    display: block;
    margin-top: 14px;
    margin-bottom: 4px;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
}
.form-card label:first-of-type { margin-top: 0; }

.form-card input,
.form-card select,
.form-card textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: var(--font);
    color: var(--gray-900);
    transition: border-color .15s, box-shadow .15s;
    background: var(--white);
}
.form-card input:focus,
.form-card select:focus,
.form-card textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.form-card small {
    display: block;
    color: var(--gray-400);
    font-size: 12px;
    margin-top: 4px;
}
.form-card input[disabled] {
    background: var(--gray-50);
    color: var(--gray-500);
    cursor: not-allowed;
}
.form-card button[type="submit"] { margin-top: 18px; width: 100%; }
@media (min-width: 640px) { .form-card button[type="submit"] { width: auto; } }

/* inline filter bar */
.form-card-inline {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.form-card-inline > div { flex: 1; min-width: 130px; }
.form-card-inline label { margin-top: 0 !important; }
.form-card-inline button[type="submit"],
.form-card-inline .btn { width: 100%; margin-top: 0; }

@media (min-width: 640px) {
    .form-card-inline { flex-direction: row; flex-wrap: wrap; align-items: flex-end; }
    .form-card-inline button[type="submit"],
    .form-card-inline .btn { width: auto; }
}

/* ---- Login page ------------------------------------------ */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}
.login-box {
    background: var(--white);
    padding: 32px 28px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 360px;
}
.login-box h1 {
    font-size: 17px;
    margin-bottom: 6px;
    text-align: center;
    font-weight: 700;
}
.login-box p.subtitle {
    font-size: 13px;
    color: var(--gray-500);
    text-align: center;
    margin-bottom: 20px;
}
.login-box label {
    display: block;
    margin-top: 14px;
    margin-bottom: 4px;
    font-size: 13px;
    font-weight: 600;
}
.login-box input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 14px;
}
.login-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.login-box button {
    width: 100%;
    margin-top: 20px;
    padding: 11px;
    font-size: 15px;
    border-radius: var(--radius-sm);
}

/* ---- Pagination ------------------------------------------ */
.pagination { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 6px; }
.pagination a {
    padding: 6px 12px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--primary);
}
.pagination a.active { background: var(--primary); color: var(--white); border-color: var(--primary); }
.pagination a:hover { background: var(--primary-light); text-decoration: none; }

/* ---- Report cards ---------------------------------------- */
.report-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-top: 16px;
}
@media (min-width: 640px)  { .report-cards { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1024px) { .report-cards { grid-template-columns: repeat(4, 1fr); } }

.report-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 22px;
    text-decoration: none;
    color: inherit;
    transition: box-shadow .15s, border-color .15s, transform .15s;
    display: block;
}
.report-card:hover {
    box-shadow: var(--shadow);
    border-color: var(--primary);
    transform: translateY(-2px);
    text-decoration: none;
}
.report-card-icon { font-size: 28px; margin-bottom: 10px; }
.report-card-title { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.report-card-desc  { font-size: 13px; color: var(--gray-500); line-height: 1.5; }

/* ---- Member rates inline form ---------------------------- */
.filter-bar { margin-bottom: 16px; }

/* ---- Misc ------------------------------------------------ */
details > summary { cursor: pointer; }

@media (max-width: 640px) {
    h1 { font-size: 18px; }
    .stat-card { padding: 12px; }
    .stat-value { font-size: 18px; }
}
