/* CrossCheck - Mobile-first responsive CSS */

:root {
    --primary: #0083ff;
    --primary-dark: #0066cc;
    --primary-light: #e8f4ff;
    --success: #28a745;
    --success-light: #d4edda;
    --danger: #dc3545;
    --danger-light: #f8d7da;
    --warning: #ffc107;
    --muted: #6c757d;
    --light: #f8f9fa;
    --border: #dee2e6;
    --text: #212529;
    --text-secondary: #495057;
    --white: #ffffff;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    background: var(--light);
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
}

/* Page entrance animation */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 16px;
    animation: fadeInUp 0.3s ease-out;
}

/* Navbar */
.navbar {
    background: var(--primary);
    color: var(--white);
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,131,255,0.15);
}
.nav-brand { font-weight: 700; font-size: 18px; letter-spacing: -0.3px; }
.nav-info { display: flex; align-items: center; gap: 12px; }
.nav-user { font-size: 14px; opacity: 0.9; }

/* Cards */
.card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}
.login-card {
    margin-top: 40px;
    animation: scaleIn 0.3s ease-out;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    border: 2px solid transparent;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: all 0.15s ease;
    min-height: 48px;
    line-height: 1.2;
    -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
    background: var(--primary);
    color: var(--white);
    box-shadow: 0 2px 4px rgba(0,131,255,0.2);
}
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 8px rgba(0,131,255,0.25); }
.btn-primary:disabled {
    background: var(--muted);
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.6;
}
.btn-outline {
    background: var(--white);
    border-color: var(--border);
    color: var(--text);
}
.btn-outline:hover { background: var(--light); border-color: var(--muted); }
.btn-sm { padding: 6px 12px; min-height: 36px; font-size: 14px; }
.btn-block { display: block; width: 100%; }
.btn-link { background: none; border: none; color: var(--primary); }
.btn-group { display: flex; gap: 12px; justify-content: center; margin-top: 16px; }

/* Loading state for buttons */
.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}
.btn-loading::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 20px; height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-secondary);
}
.form-control {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 16px;
    min-height: 48px;
    background: var(--white);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
select.form-control { appearance: auto; }
textarea.form-control { min-height: 80px; resize: vertical; }
.otp-input {
    text-align: center;
    font-size: 24px;
    letter-spacing: 8px;
    font-weight: 700;
}
.form-hint {
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 500;
    animation: slideDown 0.25s ease-out;
}
.alert-error {
    background: var(--danger-light);
    color: #721c24;
    border-left: 4px solid var(--danger);
}
.alert-success {
    background: var(--success-light);
    color: #155724;
    border-left: 4px solid var(--success);
}

/* Menu */
.menu-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 16px;
}
.menu-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 16px;
    background: var(--white);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    cursor: pointer;
    transition: all 0.15s ease;
    min-height: 48px;
    font-size: 16px;
    box-shadow: var(--shadow);
    -webkit-tap-highlight-color: transparent;
}
.menu-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); }
.menu-card:active { transform: scale(0.98); }
.menu-icon { font-size: 32px; font-weight: 700; margin-bottom: 8px; opacity: 0.8; }
.menu-label { font-size: 18px; font-weight: 700; }
.menu-desc { font-size: 14px; color: var(--muted); margin-top: 4px; }
.menu-receipt { border-left: 4px solid var(--success); }
.menu-expense { border-left: 4px solid var(--danger); }
.menu-summary { border-left: 4px solid var(--primary); }
.menu-mpesa { border-left: 4px solid #4caf50; }

.method-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 16px;
}

/* Page header */
.page-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}
.page-header h2 { font-size: 20px; letter-spacing: -0.3px; }

/* Step indicator dots */
.step-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: 20px;
}
.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
    transition: all 0.2s;
}
.dot.active {
    background: var(--primary);
    width: 24px;
    border-radius: 4px;
}
.dot.done {
    background: var(--primary);
    opacity: 0.4;
}

/* Autocomplete */
.autocomplete-results {
    position: relative;
    background: var(--white);
    border: 2px solid var(--primary);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    max-height: 200px;
    overflow-y: auto;
    display: none;
    z-index: 10;
    box-shadow: var(--shadow-md);
}
.autocomplete-results.active { display: block; }
.autocomplete-item {
    padding: 12px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--light);
    font-size: 14px;
    transition: background 0.1s;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover, .autocomplete-item:active { background: var(--primary-light); }
.autocomplete-item .church { color: var(--muted); font-size: 12px; margin-left: 4px; }

/* Breakdown */
.breakdown-total {
    background: var(--primary-light);
    padding: 14px;
    border-radius: var(--radius-sm);
    text-align: center;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--primary-dark);
    transition: background 0.2s, color 0.2s;
}
.breakdown-total.match {
    background: var(--success-light);
    color: #155724;
}
.breakdown-total.mismatch {
    background: var(--danger-light);
    color: #721c24;
}

/* Success */
.success-icon {
    font-size: 56px;
    color: var(--success);
    margin-bottom: 12px;
    animation: scaleIn 0.4s ease-out;
}

/* Success details */
.done-details {
    background: var(--light);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin: 16px 0;
    text-align: left;
}
.done-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 14px;
}
.done-label { color: var(--muted); }
.done-value { font-weight: 600; }

/* Confirmation overlay */
.confirm-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 16px;
}
.confirm-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    animation: scaleIn 0.2s ease-out;
}
.confirm-card h3 {
    margin: 0 0 16px;
    text-align: center;
}
.confirm-details { margin: 0 0 8px; }
.confirm-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.confirm-row:last-child { border-bottom: none; }
.confirm-label { color: var(--muted); }
.confirm-value { font-weight: 600; text-align: right; }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px 20px;
}
.empty-state-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.4;
}
.empty-state p { color: var(--muted); margin-bottom: 16px; }

/* Resend row */
.resend-row { margin-top: 12px; }

/* Week list */
.week-list { display: flex; flex-direction: column; gap: 10px; }
.week-card {
    display: block;
    background: var(--white);
    border-radius: var(--radius);
    padding: 16px;
    text-decoration: none;
    color: var(--text);
    box-shadow: var(--shadow);
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}
.week-card:hover { box-shadow: var(--shadow-md); }
.week-card:active { transform: scale(0.99); }
.week-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.week-church { font-weight: 700; }
.week-status {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.status-pending { background: #fff3cd; color: #856404; }
.status-approved { background: var(--success-light); color: #155724; }
.status-imported { background: var(--primary-light); color: #004085; }
.week-dates { font-size: 14px; color: var(--muted); }
.week-amounts { display: flex; justify-content: space-between; margin-top: 8px; font-size: 15px; }
.amount-in { color: var(--success); font-weight: 600; }
.amount-out { color: var(--danger); font-weight: 600; }
.week-counts { font-size: 12px; margin-top: 4px; color: var(--muted); }

/* Summary detail */
.summary-totals {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 20px;
}
.total-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 14px 8px;
    text-align: center;
    box-shadow: var(--shadow);
}
.total-in { border-top: 3px solid var(--success); }
.total-out { border-top: 3px solid var(--danger); }
.total-net-positive { border-top: 3px solid var(--success); }
.total-net-negative { border-top: 3px solid var(--danger); }
.total-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.total-amount { font-size: 16px; font-weight: 700; margin-top: 4px; }

/* Tables */
.table-wrapper { overflow-x: auto; margin-bottom: 20px; border-radius: var(--radius); box-shadow: var(--shadow); }
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    background: var(--white);
}
.data-table th {
    background: var(--light);
    padding: 10px 8px;
    text-align: left;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--muted);
    letter-spacing: 0.3px;
}
.data-table td {
    padding: 10px 8px;
    border-bottom: 1px solid var(--light);
}
.data-table tr:last-child td { border-bottom: none; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--muted); }

/* Delete button in tables */
.btn-delete {
    background: none;
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 4px;
    cursor: pointer;
    min-height: auto;
    transition: all 0.15s;
}
.btn-delete:hover {
    background: var(--danger);
    color: var(--white);
}

h3 { margin: 20px 0 10px; font-size: 16px; letter-spacing: -0.2px; }

/* Page header with subtitle */
.page-header-text h2 { line-height: 1.2; }

/* Section headers */
.section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 20px 0 8px;
}
.section-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}
.section-count {
    font-size: 12px;
    font-weight: 600;
    background: var(--light);
    color: var(--muted);
    padding: 1px 7px;
    border-radius: 10px;
    border: 1px solid var(--border);
}

/* Transaction list */
.txn-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 4px;
}
.txn-item {
    background: var(--white);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    box-shadow: var(--shadow);
}
.txn-main { flex: 1; min-width: 0; }
.txn-name {
    font-weight: 600;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.txn-meta {
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
}
.txn-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    flex-shrink: 0;
}
.txn-amount {
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
}
.txn-in { color: var(--success); }
.txn-out { color: var(--danger); }
.txn-empty { padding: 6px 0 16px; }

/* Sticky action bar */
.action-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--white);
    border-top: 1px solid var(--border);
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    display: flex;
    gap: 10px;
    z-index: 100;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
}
.action-bar-approve { flex: 1; }

/* Danger button variants */
.btn-danger {
    background: var(--danger);
    color: var(--white);
    border-color: var(--danger);
    box-shadow: 0 2px 4px rgba(220,53,69,0.2);
}
.btn-danger:hover { background: #c82333; border-color: #c82333; }
.btn-outline-danger {
    background: var(--white);
    color: var(--danger);
    border-color: var(--danger);
}
.btn-outline-danger:hover { background: var(--danger-light); }

/* PWA standalone mode: add safe area padding for notched phones */
@media (display-mode: standalone) {
    body { padding-top: env(safe-area-inset-top); }
    .navbar { padding-top: env(safe-area-inset-top); }
}
