/**
 * Donation Tracker - Premium Modern Stylesheet
 * Responsive Mobile-First Design System
 */

:root {
    --primary: #0284c7;
    --primary-hover: #0369a1;
    --primary-light: #e0f2fe;
    --primary-dark: #075985;
    
    --success: #10b981;
    --success-light: #d1fae5;
    --success-dark: #047857;

    --warning: #f59e0b;
    --warning-light: #fef3c7;
    
    --danger: #ef4444;
    --danger-light: #fee2e2;

    --cash: #059669;
    --cash-light: #ecfdf5;

    --upi: #7c3aed;
    --upi-light: #f5f3ff;

    --bank: #2563eb;
    --bank-light: #eff6ff;

    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    --bg-alt: #f1f5f9;

    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --border-focus: #38bdf8;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.04);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    
    --font-sans: 'Plus Jakarta Sans', 'Noto Sans Malayalam', system-ui, -apple-system, sans-serif;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-page);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* ==========================================
   Header & Navigation
   ========================================== */
.app-header {
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(8px);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 70px;
    gap: 1rem;
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: inherit;
}

.brand-logo-img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.brand-link:hover .brand-logo-img {
    transform: scale(1.05);
}

.brand-logo {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--primary), #38bdf8);
    color: #fff;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(2, 132, 199, 0.25);
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.02em;
}

.brand-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.lang-switcher {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--bg-alt);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
}

.lang-btn {
    text-decoration: none;
    color: var(--text-muted);
    padding: 0.2rem 0.4rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.lang-btn.active {
    background: #fff;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.lang-divider {
    color: var(--border);
}

.nav-bar {
    display: flex;
    align-items: center;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-item {
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.45rem 0.75rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.nav-item:hover, .nav-item.active {
    color: var(--primary);
    background: var(--primary-light);
}

.btn-nav-cta {
    background: var(--primary) !important;
    color: #fff !important;
    border-radius: var(--radius-full);
    padding: 0.45rem 1rem;
}

.btn-nav-cta:hover {
    background: var(--primary-hover) !important;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-alt);
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
}

.user-name {
    font-size: 0.8rem;
    font-weight: 600;
}

.user-role {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.15rem 0.4rem;
    border-radius: var(--radius-full);
    text-transform: uppercase;
}

.role-admin { background: #fee2e2; color: #b91c1c; }
.role-staff { background: #e0f2fe; color: #0369a1; }

.btn-logout {
    color: var(--text-muted);
    display: flex;
    align-items: center;
    text-decoration: none;
    margin-left: 0.25rem;
    transition: var(--transition);
}

.btn-logout:hover {
    color: var(--danger);
}

/* ==========================================
   Layout & Cards
   ========================================== */
.main-content {
    flex: 1;
    padding: 2rem 1rem 3rem;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.01em;
}

.card-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.card-header-flex {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.02em;
}

.page-subtitle {
    font-size: 0.95rem;
    color: var(--text-muted);
}

.header-buttons {
    display: flex;
    gap: 0.5rem;
}

/* ==========================================
   Hero & Auto-Refresh
   ========================================== */
.dashboard-hero {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1.5rem;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.hero-badge {
    display: inline-block;
    background: var(--primary-light);
    color: var(--primary-dark);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    margin-bottom: 0.5rem;
}

.hero-title {
    font-size: 2.25rem;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.03em;
    color: var(--text-main);
}

.hero-subtitle {
    font-size: 1rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
}

.hero-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.6rem;
}

.refresh-indicator {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    background: #fff;
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
}

.refresh-dot {
    width: 8px;
    height: 8px;
    background-color: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); opacity: 0.7; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(0.95); opacity: 0.7; }
}

/* ==========================================
   Metrics Grid & Stats Cards
   ========================================== */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.metric-card {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.metric-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.metric-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

.metric-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: bold;
}

.metric-value {
    font-size: 1.95rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-main);
    line-height: 1.1;
    margin-bottom: 0.5rem;
}

.metric-subtext {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.metric-primary {
    border-top: 4px solid var(--primary);
}
.metric-primary .metric-icon {
    background: var(--primary-light);
    color: var(--primary);
}
.metric-primary .metric-value {
    color: var(--primary-dark);
}

.metric-cash {
    border-top: 4px solid var(--cash);
}
.metric-cash .metric-icon {
    background: var(--cash-light);
    color: var(--cash);
}

.metric-upi {
    border-top: 4px solid var(--upi);
}
.metric-upi .metric-icon {
    background: var(--upi-light);
    color: var(--upi);
}

.metric-count {
    border-top: 4px solid #64748b;
}
.metric-count .metric-icon {
    background: var(--bg-alt);
    color: var(--text-muted);
}

.subtext-badge {
    background: #fef3c7;
    color: #b45309;
    padding: 0.15rem 0.45rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

/* ==========================================
   Filter Panel
   ========================================== */
.filter-panel {
    margin-bottom: 2rem;
    background: #ffffff;
}

.filter-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1.2fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

@media (max-width: 900px) {
    .filter-grid {
        grid-template-columns: 1fr 1fr;
    }
}
@media (max-width: 600px) {
    .filter-grid {
        grid-template-columns: 1fr;
    }
}

.filter-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* ==========================================
   Forms & Inputs
   ========================================== */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 1rem;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
}

.form-group label.required::after {
    content: " *";
    color: var(--danger);
}

.form-control {
    width: 100%;
    padding: 0.65rem 0.85rem;
    font-size: 0.95rem;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: #fff;
    color: var(--text-main);
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-row {
    display: flex;
    gap: 1rem;
}

.flex-1 { flex: 1; }
.flex-2 { flex: 2; }

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 0.75rem;
    color: var(--text-muted);
    pointer-events: none;
}

.input-with-icon .form-control {
    padding-left: 2.35rem;
}

.input-with-prefix {
    position: relative;
    display: flex;
    align-items: center;
}

.currency-prefix {
    position: absolute;
    left: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    font-size: 1.1rem;
}

.form-control.pl-prefix {
    padding-left: 2.2rem;
    font-size: 1.15rem;
    font-weight: 700;
}

.payment-options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.75rem;
    margin-top: 0.25rem;
}

.payment-option-card {
    position: relative;
    cursor: pointer;
}

.payment-option-card input[type="radio"] {
    position: absolute;
    opacity: 0;
}

.option-content {
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.85rem 0.5rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    transition: var(--transition);
    background: #fff;
}

.payment-option-card input[type="radio"]:checked + .option-content {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary-dark);
}

.option-title {
    font-size: 0.85rem;
    font-weight: 700;
}

.field-error {
    font-size: 0.75rem;
    color: var(--danger);
    font-weight: 600;
}

.field-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.has-error .form-control {
    border-color: var(--danger);
}

/* ==========================================
   Buttons
   ========================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 4px rgba(2, 132, 199, 0.2);
}
.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: #fff;
    color: var(--text-main);
    border-color: var(--border);
}
.btn-secondary:hover {
    background: var(--bg-alt);
}

.btn-light {
    background: var(--bg-alt);
    color: var(--text-main);
}
.btn-light:hover {
    background: var(--border);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover {
    background: #dc2626;
}

.btn-success {
    background: var(--success);
    color: #fff;
}
.btn-success:hover {
    background: var(--success-dark);
}

.btn-outline {
    background: transparent;
    border-color: var(--border);
    color: var(--text-muted);
}
.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-lg {
    padding: 0.85rem 1.75rem;
    font-size: 1rem;
    border-radius: var(--radius-md);
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

.btn-xs {
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
}

.btn-block {
    width: 100%;
}

/* ==========================================
   Tables
   ========================================== */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.875rem;
}

.table th {
    background: var(--bg-alt);
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

.table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

.table tbody tr:hover {
    background-color: #fafbfc;
}

.text-right { text-align: right; }
.text-center { text-align: center; }
.font-medium { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-primary { color: var(--primary); }
.text-muted { color: var(--text-muted); }

.badge-id {
    font-family: monospace;
    font-size: 0.8rem;
    font-weight: 600;
    background: var(--bg-alt);
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    color: var(--text-main);
}

.method-tag {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 700;
}

.method-cash {
    background: var(--cash-light);
    color: var(--cash);
}

.method-gpay_upi, .method-upi {
    background: var(--upi-light);
    color: var(--upi);
}

.method-bank {
    background: var(--bank-light);
    color: var(--bank);
}

.status-badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
}

.status-active {
    background: var(--success-light);
    color: var(--success-dark);
}

.status-deleted {
    background: var(--danger-light);
    color: var(--danger);
}

.row-deleted {
    opacity: 0.6;
    background-color: #fef2f2 !important;
}

.strike {
    text-decoration: line-through;
}

/* ==========================================
   Alerts & Notifications
   ========================================== */
.alert {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
}

.alert-success {
    background: var(--success-light);
    color: var(--success-dark);
    border: 1px solid #a7f3d0;
}

.alert-danger {
    background: var(--danger-light);
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.offline-banner {
    background: #fef3c7;
    color: #92400e;
    text-align: center;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 700;
    border-bottom: 1px solid #fde68a;
}

.hidden { display: none !important; }

/* ==========================================
   Auth & Admin Components
   ========================================== */
.auth-container {
    max-width: 420px;
    margin: 3rem auto;
}

.auth-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.auth-icon-circle {
    width: 60px;
    height: 60px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
}

.auth-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
}

.auth-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
}

.back-link {
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
}

.two-col-layout {
    display: flex;
    gap: 1.5rem;
}

@media (max-width: 850px) {
    .two-col-layout {
        flex-direction: column;
    }
}

.admin-quick-links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.quick-link-card {
    text-decoration: none;
    color: inherit;
    display: flex;
    gap: 1rem;
    align-items: center;
    transition: var(--transition);
}

.quick-link-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.quick-link-icon {
    font-size: 1.8rem;
}

.quick-link-info h3 {
    font-size: 1rem;
    font-weight: 700;
}

.quick-link-info p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.health-alert {
    padding: 1rem 1.25rem;
}
.health-alert-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.health-ok { border-left: 4px solid var(--success); }
.health-warn { border-left: 4px solid var(--warning); }

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-dialog {
    max-width: 440px;
    width: 90%;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1rem;
}

.json-dump {
    font-size: 0.72rem;
    background: var(--bg-alt);
    padding: 0.35rem 0.5rem;
    border-radius: var(--radius-sm);
    max-width: 200px;
    max-height: 80px;
    overflow-y: auto;
    word-break: break-all;
    white-space: pre-wrap;
}

/* ==========================================
   Footer
   ========================================== */
.app-footer {
    background: #ffffff;
    border-top: 1px solid var(--border);
    padding: 1.5rem 0;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: auto;
}

.footer-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.footer-info {
    display: flex;
    flex-direction: column;
}

.footer-org {
    font-weight: 700;
    color: var(--text-main);
}

.footer-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.badge-secure {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--success-dark);
    background: var(--success-light);
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 700;
}
