/* =====================================================================
   All Saints Chapel Lweza - Facilitation Registration System
   Purple & White Theme
   ===================================================================== */

:root {
    --purple-900: #3b0764;
    --purple-800: #4c1d95;
    --purple-700: #5b21b6;
    --purple-600: #6d28d9;
    --purple-500: #7c3aed;
    --purple-400: #9061f9;
    --purple-100: #ede9fe;
    --purple-50:  #f5f3ff;
    --white: #ffffff;
    --gray-50: #fafafa;
    --gray-100: #f4f4f6;
    --gray-200: #e5e5ea;
    --gray-400: #a0a0ab;
    --gray-600: #6b6b76;
    --gray-800: #2d2d36;
    --success: #16a34a;
    --success-bg: #dcfce7;
    --danger: #dc2626;
    --danger-bg: #fee2e2;
    --warning: #d97706;
    --warning-bg: #fef3c7;
    --radius: 14px;
    --radius-sm: 8px;
    --shadow: 0 2px 8px rgba(76, 29, 149, 0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-lg: 0 12px 32px rgba(76, 29, 149, 0.14);
    --sidebar-w: 230px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Segoe UI', Roboto, -apple-system, BlinkMacSystemFont, Arial, sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; margin: 0; padding: 0; }
button { font-family: inherit; }

/* ---------------- Topbar ---------------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    height: 64px;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 20px;
    background: linear-gradient(120deg, var(--purple-800), var(--purple-600));
    color: var(--white);
    box-shadow: var(--shadow);
}

.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.12);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.menu-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--white);
    margin: 0 auto;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
    width: 42px; height: 42px;
    background: var(--white);
    color: var(--purple-700);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800;
    font-size: 14px;
    flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 16px; }
.brand-text span { font-size: 12px; opacity: 0.85; }

/* ---------------- Shell / Sidebar ---------------- */
.app-shell { display: flex; min-height: calc(100vh - 64px - 50px); }

.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--white);
    border-right: 1px solid var(--gray-200);
    padding: 18px 12px;
    position: sticky;
    top: 64px;
    height: calc(100vh - 64px);
    overflow-y: auto;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14.5px;
    color: var(--gray-800);
    margin-bottom: 4px;
    transition: background 0.15s, color 0.15s;
}
.nav-icon { font-size: 15px; width: 18px; text-align: center; }
.nav-link:hover { background: var(--purple-50); color: var(--purple-700); }
.nav-link.active { background: var(--purple-700); color: var(--white); }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 30;
}

.main-content {
    flex: 1;
    padding: 24px;
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
}

.app-footer {
    text-align: center;
    padding: 16px;
    font-size: 12.5px;
    color: var(--gray-600);
    background: var(--white);
    border-top: 1px solid var(--gray-200);
}

/* ---------------- Page Heading ---------------- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 22px;
}
.page-header h1 {
    font-size: 22px;
    margin: 0 0 2px;
    color: var(--purple-900);
}
.page-header p {
    margin: 0;
    color: var(--gray-600);
    font-size: 13.5px;
}

/* ---------------- Buttons ---------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 20px;
    border-radius: var(--radius-sm);
    border: none;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: transform 0.08s ease, box-shadow 0.15s ease, background 0.15s;
    min-height: 44px;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--purple-700); color: var(--white); }
.btn-primary:hover { background: var(--purple-800); box-shadow: var(--shadow); }
.btn-outline { background: var(--white); color: var(--purple-700); border: 1.5px solid var(--purple-700); }
.btn-outline:hover { background: var(--purple-50); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: #b91c1c; }
.btn-success { background: var(--success); color: var(--white); }
.btn-sm { padding: 7px 12px; font-size: 12.5px; min-height: 34px; border-radius: 7px; }
.btn-block { width: 100%; }
.btn-icon { padding: 8px; min-width: 38px; }

/* ---------------- Cards / Stats ---------------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border-left: 5px solid var(--purple-600);
    position: relative;
    overflow: hidden;
}
.stat-card .stat-label { font-size: 12.5px; color: var(--gray-600); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.stat-card .stat-value { font-size: 26px; font-weight: 800; color: var(--purple-900); margin-top: 6px; }
.stat-card .stat-icon { position: absolute; right: 16px; top: 16px; font-size: 26px; opacity: 0.18; }

.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
    margin-bottom: 20px;
}
.card h2, .card h3 {
    margin-top: 0;
    color: var(--purple-900);
    font-size: 17px;
}

/* ---------------- Forms ---------------- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 18px;
}
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 13.5px; font-weight: 600; color: var(--gray-800); }
label .req { color: var(--danger); }

input[type="text"], input[type="number"], input[type="tel"], input[type="date"],
input[type="search"], select, textarea {
    padding: 12px 14px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 14.5px;
    background: var(--white);
    color: var(--gray-800);
    width: 100%;
    min-height: 46px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--purple-500);
    box-shadow: 0 0 0 3px var(--purple-100);
}
.hint { font-size: 12px; color: var(--gray-600); }
.error-text { font-size: 12px; color: var(--danger); display: none; }
.form-group.has-error input, .form-group.has-error select { border-color: var(--danger); }
.form-group.has-error .error-text { display: block; }

fieldset {
    border: 1.5px dashed var(--gray-200);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin: 6px 0 0;
}
fieldset legend {
    font-weight: 700;
    color: var(--purple-700);
    padding: 0 8px;
    font-size: 13.5px;
}
.conditional-field { display: none; }
.conditional-field.show { display: flex; }

/* ---------------- Signature Pad ---------------- */
.signature-wrap {
    background: var(--purple-50);
    border: 2px dashed var(--purple-400);
    border-radius: var(--radius);
    padding: 10px;
}
#signaturePad {
    width: 100%;
    height: 200px;
    background: var(--white);
    border-radius: var(--radius-sm);
    touch-action: none;
    display: block;
    border: 1px solid var(--gray-200);
}
.signature-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    flex-wrap: wrap;
    gap: 8px;
}

/* ---------------- Table ---------------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow); background: var(--white); }
table { width: 100%; border-collapse: collapse; min-width: 820px; }
thead th {
    background: var(--purple-700);
    color: var(--white);
    text-align: left;
    padding: 13px 16px;
    font-size: 12.5px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}
tbody td { padding: 13px 16px; font-size: 14px; border-bottom: 1px solid var(--gray-100); white-space: nowrap; }
tbody tr:hover { background: var(--purple-50); }
tbody tr:last-child td { border-bottom: none; }
.actions-cell { display: flex; gap: 6px; }

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    background: var(--purple-100);
    color: var(--purple-700);
}
.badge-cash { background: var(--success-bg); color: var(--success); }
.badge-mobile { background: var(--warning-bg); color: var(--warning); }
.badge-bank { background: var(--purple-100); color: var(--purple-700); }

.sig-thumb { width: 60px; height: 32px; object-fit: contain; background: var(--white); border: 1px solid var(--gray-200); border-radius: 4px; }

/* ---------------- Alerts / Toast ---------------- */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 18px;
}
.alert-success { background: var(--success-bg); color: var(--success); }
.alert-error { background: var(--danger-bg); color: var(--danger); }
.alert-warning { background: var(--warning-bg); color: var(--warning); }

/* ---------------- Search / Filter bar ---------------- */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
    align-items: flex-end;
}
.filter-bar .form-group { margin-bottom: 0; min-width: 150px; }
.quick-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

/* ---------------- Modal (delete confirm) ---------------- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(30, 10, 60, 0.45);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.modal-overlay.show { display: flex; }
.modal-box {
    background: var(--white);
    border-radius: var(--radius);
    padding: 26px;
    max-width: 380px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    text-align: center;
}
.modal-box h3 { margin-top: 0; color: var(--purple-900); }
.modal-box .modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-box .modal-actions .btn { flex: 1; }

/* ---------------- Print Slip ---------------- */
.print-slip {
    max-width: 500px;
    margin: 0 auto;
    background: var(--white);
    border-radius: var(--radius);
    padding: 30px;
    box-shadow: var(--shadow);
}
.print-slip .slip-header { text-align: center; border-bottom: 2px solid var(--purple-700); padding-bottom: 14px; margin-bottom: 14px; }
.print-slip .slip-header h2 { color: var(--purple-800); margin: 0 0 4px; }
.print-slip .slip-header p { margin: 0; color: var(--gray-600); font-size: 13px; }
.slip-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--gray-200); font-size: 14px; }
.slip-row span:first-child { color: var(--gray-600); font-weight: 600; }
.slip-sig { margin-top: 16px; text-align: center; }
.slip-sig img { max-width: 220px; border: 1px solid var(--gray-200); border-radius: 6px; }

/* ---------------- Detail view ---------------- */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.detail-item { padding: 12px 14px; background: var(--gray-50); border-radius: var(--radius-sm); }
.detail-item .label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--gray-600); font-weight: 700; }
.detail-item .value { font-size: 15px; font-weight: 600; margin-top: 4px; color: var(--gray-800); }

/* ---------------- Report grid ---------------- */
.report-section { margin-bottom: 26px; }
.report-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }

/* ---------------- Empty state ---------------- */
.empty-state { text-align: center; padding: 50px 20px; color: var(--gray-600); }
.empty-state .empty-icon { font-size: 40px; margin-bottom: 10px; }

/* ---------------- Responsive ---------------- */
@media (max-width: 900px) {
    .menu-toggle { display: flex; }
    .sidebar {
        position: fixed;
        left: -260px;
        top: 64px;
        z-index: 50;
        width: 240px;
        transition: left 0.2s ease;
        box-shadow: var(--shadow-lg);
    }
    .sidebar.open { left: 0; }
    .sidebar-overlay.show { display: block; }
    .main-content { padding: 16px; }
    table { min-width: 720px; }
}

@media (max-width: 560px) {
    .stat-card .stat-value { font-size: 21px; }
    .btn { width: 100%; }
    .quick-actions .btn, .filter-bar .btn { width: auto; }
    .page-header .btn { width: auto; }
}

/* ---------------- Print media ---------------- */
@media print {
    .topbar, .sidebar, .sidebar-overlay, .app-footer, .no-print { display: none !important; }
    .app-shell { display: block; }
    .main-content { padding: 0; max-width: 100%; }
    body { background: var(--white); }
    .print-slip { box-shadow: none; }
}
