@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

/* -----------------------------------------------
   JWilliams Daily Contribution – Golden Cards + Royal Blue Glass
-------------------------------------------------- */
:root {
    --primary: #0066F5;
    --primary-dark: #0047B3;
    --primary-light: #E8F1FF;
    --success: #16A34A;
    --success-light: #E6F7EC;
    --warning: #F59E0B;
    --warning-light: #FFF9EB;
    --danger: #EF4444;
    --danger-light: #FEE9E9;
    --bg: #1E3A8A;
    --card: #FFF9E6;
    --card-gradient: linear-gradient(135deg, #FFF8E7, #FFF3D4);
    --card-border: #FDE68A;
    --text: #0F172A;
    --text-secondary: #475569;
    --text-muted: #64748B;
    --border: #E2E8F0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.08);
    --radius: 16px;
    --radius-sm: 12px;
    --radius-xs: 8px;
    --transition: 0.2s cubic-bezier(0.2, 0, 0, 1);
    --font: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    --nav-height: 68px;
    --header-height: 60px;
    --safe-bottom: env(safe-area-inset-bottom, 16px);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 15px;
    -webkit-tap-highlight-color: transparent;
    scroll-behavior: smooth;
    overflow-x: hidden;
    /* Prevent horizontal scroll */
}

body {
    font-family: var(--font);
    background: linear-gradient(135deg, #1E3A8A 0%, #3B82F6 100%);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 24px);
    overflow-x: hidden;
    /* Prevent horizontal scroll */
}

.app-container {
    width: 100%;
    max-width: 480px;
    min-height: 100vh;
    min-height: 100dvh;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    position: relative;
    overflow-x: hidden;
    /* Ensure no internal horizontal overflow */
    display: flex;
    flex-direction: column;
    border-left: 1px solid rgba(255, 255, 255, 0.3);
    border-right: 1px solid rgba(255, 255, 255, 0.3);
}

@media (min-width: 768px) {
    .app-container {
        max-width: 720px;
        border-left: 1px solid rgba(255, 255, 255, 0.3);
        border-right: 1px solid rgba(255, 255, 255, 0.3);
        box-shadow: var(--shadow-lg);
        border-radius: 24px;
        margin-top: 16px;
        min-height: calc(100vh - 32px);
        overflow-x: visible;
        /* Allow shadows etc. */
    }

    body {
        padding-bottom: 0;
    }

    .bottom-nav {
        max-width: 720px;
        left: 50%;
        transform: translateX(-50%);
        border-radius: 20px 20px 0 0;
    }
}

@media (min-width: 1024px) {
    .app-container {
        max-width: 900px;
    }

    .bottom-nav {
        max-width: 900px;
    }

    .calendar-grid {
        grid-template-columns: repeat(7, 1fr);
        gap: 8px;
    }
}

/* ---------- HEADER ---------- */
.app-header {
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 0 16px;
    /* Slightly reduced padding for small screens */
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid rgba(255, 255, 255, 0.5);
    height: var(--header-height);
    gap: 8px;
    overflow: hidden;
    /* Prevent children from overflowing */
}

.app-header .logo {
    font-weight: 700;
    font-size: 1.1rem;
    /* Slightly smaller to fit new name */
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    /* Allow shrinking */
    flex-shrink: 1;
    overflow: hidden;
    /* Hide overflowing text */
}

.app-header .logo span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-header .logo .icon-circle {
    width: 34px;
    /* Slightly smaller icon to save space */
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, #0066F5, #0050CC);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 102, 245, 0.3);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    /* Prevent icons from shrinking */
}

#headerUserTag {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    max-width: 70px;
    /* Keep name short, truncate if needed */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    vertical-align: middle;
}

.btn-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(10px);
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    color: var(--text-secondary);
    position: relative;
    flex-shrink: 0;
    /* Prevent buttons from shrinking */
}

.btn-icon:active {
    background: rgba(255, 255, 255, 0.7);
    transform: scale(0.96);
}

.badge-dot {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 10px;
    height: 10px;
    border-radius: 10px;
    background: var(--danger);
    border: 2px solid #fff;
}

/* ---------- SCREENS & CONTENT ---------- */
.screen {
    display: none;
    animation: fadeSlideIn 0.25s ease;
    flex: 1;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.screen-content {
    padding: 16px;
    padding-bottom: calc(var(--nav-height) + 20px);
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* ---------- CARDS ---------- */
.card {
    background: var(--card-gradient);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--card-border);
    transition: box-shadow 0.2s;
    position: relative;
    overflow: hidden;
}

.card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.2);
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.card:hover::after {
    opacity: 1;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.card-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text);
    letter-spacing: -0.2px;
}

.card-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ---------- STATS ---------- */
.stat-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.stat-card {
    background: var(--card-gradient);
    border-radius: var(--radius);
    padding: 14px 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--card-border);
    text-align: left;
    transition: all 0.2s;
}

.stat-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.5px;
}

.stat-value.success {
    color: var(--success);
}

.stat-value.warning {
    color: var(--warning);
}

.stat-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 500;
}

/* ---------- BUTTONS ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    white-space: nowrap;
    min-height: 44px;
    font-family: var(--font);
    letter-spacing: 0.01em;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(0, 102, 245, 0.3);
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-success {
    background: var(--success);
    color: #fff;
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.3);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.75rem;
    min-height: 36px;
    border-radius: 8px;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.btn:disabled {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
}

/* Quick actions button */
.btn[style*="background:#f0f0f4"] {
    background: #FFF8E7 !important;
    color: #92400E !important;
    border: 1px solid #FDE68A;
}

/* ---------- FORMS ---------- */
.form-group {
    margin-bottom: 14px;
}

.form-label {
    display: block;
    font-weight: 600;
    font-size: 0.78rem;
    margin-bottom: 4px;
    color: var(--text);
}

.form-input {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid #E2E8F0;
    border-radius: 10px;
    font-size: 0.9rem;
    font-family: var(--font);
    transition: var(--transition);
    background: rgba(255, 255, 255, 0.9);
    color: var(--text);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 102, 245, 0.1);
    background: #fff;
}

.form-input:disabled {
    background: #F1F5F9;
    color: var(--text-muted);
    cursor: not-allowed;
}

.form-hint {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* TEXTAREA (Admin) */
#adminCollectionAccount,
textarea.form-input {
    min-height: 100px;
    max-height: 150px;
    resize: vertical;
    line-height: 1.6;
}

/* ---------- CALENDAR ---------- */
.calendar-month-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.calendar-month-title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    text-align: center;
}

.calendar-day-header {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-muted);
    padding: 6px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.calendar-day {
    aspect-ratio: 1;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
    position: relative;
    background: rgba(255, 255, 255, 0.8);
    color: var(--text);
    min-width: 34px;
    min-height: 34px;
}

.calendar-day:hover {
    border-color: var(--primary);
    background: #EEF4FF;
}

.calendar-day.paid {
    background: var(--success-light);
    color: var(--success);
    border-color: #B7E4C7;
    font-weight: 700;
}

.calendar-day.pending {
    background: var(--warning-light);
    color: #B45309;
    border-color: #FDE68A;
}

.calendar-day.missed {
    background: var(--danger-light);
    color: var(--danger);
    border-color: #FECACA;
}

.calendar-day.today {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(0, 102, 245, 0.2);
    font-weight: 800;
}

.calendar-day.future {
    background: #F1F5F9;
    color: #94A3B8;
    cursor: pointer;
}

.calendar-day .day-num {
    font-size: 0.8rem;
}

.calendar-day .day-icon {
    font-size: 0.55rem;
    position: absolute;
    bottom: 2px;
    opacity: 0.9;
}

.calendar-legend {
    display: flex;
    gap: 12px;
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 8px;
    flex-wrap: wrap;
}

.legend-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 4px;
    margin-right: 4px;
    vertical-align: middle;
}

.legend-dot.paid {
    background: var(--success);
}

.legend-dot.pending {
    background: var(--warning);
}

.legend-dot.missed {
    background: var(--danger);
}

.legend-dot.today {
    background: var(--primary);
}

.legend-dot.upcoming {
    background: #94A3B8;
}

/* ---------- PROGRESS BAR ---------- */
.progress-bar {
    height: 8px;
    border-radius: 4px;
    background: #E2E8F0;
    overflow: hidden;
    margin-top: 6px;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, #16A34A, #22C55E);
    transition: width 0.6s ease;
}

.progress-fill.warning-fill {
    background: linear-gradient(90deg, #F59E0B, #FBBF24);
}

/* ---------- TRANSACTIONS ---------- */
.tx-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    gap: 8px;
    font-size: 0.85rem;
}

.tx-item:last-child {
    border-bottom: none;
}

.tx-info {
    flex: 1;
    min-width: 0;
}

.tx-desc {
    font-weight: 600;
    font-size: 0.82rem;
}

.tx-date {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.tx-amount {
    font-weight: 700;
    font-size: 0.9rem;
    white-space: nowrap;
}

.tx-amount.credit {
    color: var(--success);
}

.tx-amount.debit {
    color: var(--danger);
}

.tx-status {
    font-size: 0.65rem;
    padding: 3px 8px;
    border-radius: 20px;
    font-weight: 600;
    white-space: nowrap;
}

.tx-status.pending {
    background: var(--warning-light);
    color: #92400E;
}

.tx-status.approved {
    background: var(--success-light);
    color: var(--success);
}

.tx-status.declined {
    background: var(--danger-light);
    color: var(--danger);
}

/* ---------- EMPTY STATE ---------- */
.empty-state {
    text-align: center;
    padding: 40px 16px;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
    opacity: 0.8;
}

/* ---------- AUTH TABS ---------- */
.tab-row {
    display: flex;
    gap: 4px;
    background: #F1F5F9;
    border-radius: 10px;
    padding: 4px;
    overflow-x: auto;
}

.tab-btn {
    flex: 1;
    padding: 8px 14px;
    border-radius: 8px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.82rem;
    font-family: var(--font);
    white-space: nowrap;
    transition: var(--transition);
    color: var(--text-secondary);
}

.tab-btn.active {
    background: #fff;
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

/* ---------- BOTTOM NAVIGATION ---------- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-top: 1px solid rgba(255, 255, 255, 0.5);
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: var(--nav-height);
    z-index: 200;
    padding: 0 4px calc(var(--safe-bottom) + 4px);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.05);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.bottom-nav::-webkit-scrollbar {
    display: none;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 12px;
    transition: var(--transition);
    border: none;
    background: transparent;
    font-family: var(--font);
    color: var(--text-muted);
    font-size: 0.6rem;
    font-weight: 500;
    min-width: 44px;
    flex-shrink: 0;
}

.nav-item.active {
    color: var(--primary);
    font-weight: 700;
}

.nav-item .nav-icon {
    font-size: 1.3rem;
}

.nav-item:active {
    background: rgba(255, 255, 255, 0.6);
}

/* ---------- MODAL ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    z-index: 500;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-sheet {
    background: var(--card-gradient);
    width: 100%;
    max-width: 480px;
    border-radius: 20px 20px 0 0;
    padding: 20px 16px;
    padding-bottom: calc(20px + var(--safe-bottom));
    max-height: 85vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.15);
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

.modal-handle {
    width: 32px;
    height: 4px;
    background: #CBD5E1;
    border-radius: 2px;
    margin: 0 auto 16px;
}

.modal-title {
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 16px;
    text-align: center;
}

/* ---------- TOASTS ---------- */
.toast-container {
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 90%;
    max-width: 440px;
    pointer-events: none;
}

.toast {
    padding: 12px 16px;
    border-radius: 12px;
    color: #fff;
    font-weight: 600;
    font-size: 0.82rem;
    animation: toastIn 0.4s ease, toastOut 0.3s ease 2.5s forwards;
    text-align: center;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.2);
    pointer-events: auto;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

.toast.info {
    background: var(--primary);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

/* ---------- MISC ---------- */
.highlight-box {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 10px;
    padding: 12px;
    font-size: 0.82rem;
    color: var(--primary-dark);
    font-weight: 500;
    word-break: break-word;
    border: 1px solid #FDE68A;
    white-space: pre-line;
}

.tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.tag.admin-tag {
    background: #FEE2E2;
    color: #991B1B;
}

.tag.user-tag {
    background: #DBEAFE;
    color: #1E40AF;
}

.divider {
    border: none;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    margin: 12px 0;
}

.user-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    cursor: pointer;
    transition: background 0.2s;
}

.user-row:hover {
    background: rgba(255, 255, 255, 0.5);
}

.user-row:last-child {
    border-bottom: none;
}

.text-center {
    text-align: center;
}

.mt-2 {
    margin-top: 10px;
}

.mt-3 {
    margin-top: 14px;
}

.mb-2 {
    margin-bottom: 10px;
}

.mb-3 {
    margin-bottom: 14px;
}

#screenAdmin .screen-content .card:last-child {
    margin-bottom: calc(var(--nav-height) + 16px);
}