@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

/* --- Design System & CSS Variables (Premium Light Theme) --- */
:root {
    --bg-dark: #f8fafc;
    --bg-obsidian: #ffffff;
    --card-bg: rgba(255, 255, 255, 0.85);
    --card-border: rgba(0, 0, 0, 0.06);
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    --primary: #4f46e5;
    --primary-light: #6366f1;
    --primary-gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    --primary-glow: rgba(79, 70, 229, 0.15);

    --success: #10b981;
    --success-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --success-glow: rgba(16, 185, 129, 0.15);

    --warning: #f59e0b;
    --warning-gradient: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    --warning-glow: rgba(245, 158, 11, 0.15);

    --danger: #ef4444;
    --danger-gradient: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    --danger-glow: rgba(239, 68, 68, 0.15);

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;

    --transition-fast: 0.2s ease;
    --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Base Resets & Typography --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(at 10% 10%, rgba(99, 102, 241, 0.03) 0px, transparent 50%),
        radial-gradient(at 90% 90%, rgba(139, 92, 246, 0.03) 0px, transparent 50%);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* --- Scrollbar Customization --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-dark);
}
::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* --- Layout Architecture --- */
.app-container {
    display: flex;
    flex-direction: row;
    min-height: 100vh;
    width: 100%;
}

/* Sidebar (Desktop Mode) */
.sidebar {
    width: 260px;
    background: var(--bg-obsidian);
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    padding: 2rem 1.5rem;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 100;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 3rem;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--primary-gradient);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px var(--primary-glow);
    font-weight: 800;
    color: white;
    font-size: 1.25rem;
}

.logo-text {
    font-weight: 700;
    font-size: 1.5rem;
    background: linear-gradient(to right, #1e293b, #7c3aed);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.nav-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-grow: 1;
}

.nav-item a {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-weight: 500;
    transition: var(--transition-smooth);
}

.nav-item a:hover {
    color: var(--text-primary);
    background: #f1f5f9;
}

.nav-item.active a {
    color: white;
    background: var(--primary-gradient);
    box-shadow: 0 4px 15px var(--primary-glow);
}

.nav-footer {
    padding-top: 1.5rem;
    border-top: 1px solid #e2e8f0;
}

/* Content Frame */
.main-content {
    flex-grow: 1;
    padding: 2.5rem;
    overflow-y: auto;
    padding-bottom: 6rem; /* extra spacing for mobile navbar spacer */
}

/* Mobile Bottom Navigation (frosted iOS/Android style) */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 12px;
    left: 12px;
    right: 12px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    padding: 0.65rem 1.25rem;
    z-index: 999;
    justify-content: space-around;
    align-items: center;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 600;
    transition: var(--transition-fast);
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
}

.mobile-nav-item i {
    font-size: 1.25rem;
}

.mobile-nav-item.active {
    color: var(--primary);
    background: rgba(79, 70, 229, 0.08);
}

/* --- Glassmorphic UI Cards (Frosted Glass Light) --- */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.03);
    transition: var(--transition-smooth);
}

.card:hover {
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.06);
}

/* --- Financial & Dashboard Metrics --- */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.metric-card {
    position: relative;
    overflow: hidden;
}

.metric-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
}

.metric-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
}

.metric-value {
    font-size: 1.85rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

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

/* Metric Colors */
.metric-expected .metric-icon { background: rgba(99, 102, 241, 0.1); color: var(--primary); }
.metric-expected::before { content: ''; position: absolute; left: 0; top: 0; height: 100%; width: 4px; background: var(--primary); }

.metric-collected .metric-icon { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.metric-collected::before { content: ''; position: absolute; left: 0; top: 0; height: 100%; width: 4px; background: var(--success); }

.metric-due .metric-icon { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.metric-due::before { content: ''; position: absolute; left: 0; top: 0; height: 100%; width: 4px; background: var(--warning); }

.metric-defaulters .metric-icon { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.metric-defaulters::before { content: ''; position: absolute; left: 0; top: 0; height: 100%; width: 4px; background: var(--danger); }

/* --- Forms & Inputs --- */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
    padding: 0.85rem 1rem;
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: var(--transition-smooth);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-light);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

select.form-control option {
    background: #ffffff;
    color: var(--text-primary);
}

/* --- Premium Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.85rem 1.75rem;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: var(--transition-smooth);
    text-decoration: none;
    text-align: center;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:hover {
    opacity: 0.95;
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.btn-success {
    background: var(--success-gradient);
    color: white;
    box-shadow: 0 4px 15px var(--success-glow);
}

.btn-success:hover {
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.btn-danger {
    background: var(--danger-gradient);
    color: white;
    box-shadow: 0 4px 15px var(--danger-glow);
}

.btn-secondary {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: #e2e8f0;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

/* --- Elegant Tables --- */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid #e2e8f0;
    margin-top: 1.5rem;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    background: #ffffff;
}

.custom-table th {
    background: #f8fafc;
    padding: 1rem 1.25rem;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 1px solid #e2e8f0;
}

.custom-table td {
    padding: 1rem 1.25rem;
    font-size: 0.95rem;
    border-bottom: 1px solid #e2e8f0;
    color: var(--text-primary);
    vertical-align: middle;
}

.custom-table tr:last-child td {
    border-bottom: none;
}

.custom-table tr:hover {
    background: #f8fafc;
}

.student-row-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.student-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    object-fit: cover;
    border: 2px solid #e2e8f0;
    background-color: #f1f5f9;
}

.student-initial-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--primary-gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
}

/* --- Badges & Statuses --- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
}

.badge-paid {
    background: rgba(16, 185, 129, 0.1);
    color: #065f46;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-partial {
    background: rgba(245, 158, 11, 0.1);
    color: #92400e;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-pending {
    background: rgba(239, 68, 68, 0.1);
    color: #991b1b;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* --- Search & Header Bar --- */
.dashboard-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    flex-grow: 1;
    max-width: 450px;
}

.search-box i {
    position: absolute;
    left: 1.15rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-box .form-control {
    padding-left: 2.75rem;
}

/* --- Dynamic UPI QR and Fee Screen styling --- */
.payment-selection {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 2rem;
}

.pay-mode-card {
    border: 2px solid #e2e8f0;
    border-radius: var(--radius-md);
    padding: 1.25rem;
    text-align: center;
    cursor: pointer;
    background: #f8fafc;
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.pay-mode-card input {
    display: none;
}

.pay-mode-card i {
    font-size: 1.75rem;
    color: var(--text-secondary);
}

.pay-mode-card:hover {
    border-color: #cbd5e1;
}

.pay-mode-card.selected {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.pay-mode-card.selected i {
    color: var(--primary);
}

#upi-qr-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius-md);
    margin: 1.5rem auto;
    width: fit-content;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.qr-label {
    text-align: center;
    font-size: 0.95rem;
    color: #1e293b;
    font-weight: 700;
    margin-top: 0.75rem;
}

/* --- Premium ID Card Mockup (Light Elegant) --- */
.id-card-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem 0;
}

.digital-id-card {
    width: 350px;
    height: 520px;
    background: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);
    border-radius: 20px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.digital-id-card::before {
    content: '';
    position: absolute;
    top: -50px;
    right: -50px;
    width: 150px;
    height: 150px;
    background: var(--primary-glow);
    border-radius: var(--radius-full);
    filter: blur(40px);
}

.id-header {
    padding: 1.5rem;
    text-align: center;
    border-bottom: 1px solid #e2e8f0;
}

.id-logo {
    font-weight: 800;
    font-size: 1.35rem;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    margin-bottom: 0.25rem;
}

.id-tagline {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.id-body {
    flex-grow: 1;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
}

.id-photo-container {
    width: 110px;
    height: 110px;
    border-radius: var(--radius-full);
    padding: 4px;
    background: var(--primary-gradient);
    box-shadow: 0 8px 20px var(--primary-glow);
    margin-bottom: 1rem;
}

.id-photo {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-full);
    object-fit: cover;
    border: 2px solid #ffffff;
    background: #f1f5f9;
}

.id-details {
    width: 100%;
    text-align: center;
    margin-bottom: 1rem;
}

.id-name {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.id-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    text-align: left;
    padding: 0 1rem;
}

.id-info-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.id-info-value {
    font-size: 0.85rem;
    color: var(--text-primary);
    font-weight: 600;
}

.id-verification-qr {
    background: white;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e2e8f0;
}

.id-status-strip {
    height: 10px;
    width: 100%;
    background: var(--danger);
}

.id-status-strip.paid {
    background: var(--success);
}

/* --- Inline Quick Add Batch --- */
.quick-batch-box {
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    display: none;
}

/* --- Mobile optimization media queries --- */
@media (max-width: 900px) {
    .sidebar {
        display: none;
    }
    
    .mobile-nav {
        display: flex;
    }
    
    .main-content {
        padding: 1.25rem;
        padding-bottom: 6.5rem; /* leaves space for floating bottom bar */
    }
}

@media (max-width: 600px) {
    /* Transform tabular data into beautiful responsive cards for small screens */
    .table-container {
        border: none;
        background: transparent;
    }

    .custom-table, 
    .custom-table thead, 
    .custom-table tbody, 
    .custom-table th, 
    .custom-table td, 
    .custom-table tr {
        display: block;
    }

    .custom-table thead {
        display: none; /* Hide headers */
    }

    .custom-table tr {
        background: var(--bg-obsidian);
        border: 1px solid var(--card-border);
        border-radius: var(--radius-lg);
        padding: 1.25rem;
        margin-bottom: 1.25rem;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.02);
    }

    .custom-table td {
        border-bottom: 1px solid #f1f5f9;
        padding: 0.75rem 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .custom-table td:last-child {
        border-bottom: none;
    }

    .custom-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-secondary);
        font-size: 0.8rem;
    }

    /* Override standard cell displays on mobile layout */
    .custom-table td.student-td {
        display: block;
        padding-top: 0;
        padding-bottom: 1rem;
        margin-bottom: 0.25rem;
        border-bottom: 2px solid #f1f5f9;
    }

    .custom-table td.student-td::before {
        display: none;
    }

    .custom-table td.action-td {
        justify-content: center;
        padding-top: 1rem;
        padding-bottom: 0;
        border-bottom: none;
    }

    .custom-table td.action-td::before {
        display: none;
    }
    
    .custom-table td.action-td .btn {
        flex-grow: 1; /* expand actions to match screen */
    }
}

@media (max-width: 480px) {
    /* 2x2 grid layout for metrics on small devices, saving a lot of scrolling */
    .metrics-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }
    
    .metric-card {
        padding: 1rem;
        border-radius: var(--radius-md);
    }
    
    .metric-header {
        font-size: 0.75rem;
        margin-bottom: 0.5rem;
    }
    
    .metric-icon {
        width: 28px;
        height: 28px;
        font-size: 0.9rem;
    }
    
    .metric-value {
        font-size: 1.25rem;
        margin-bottom: 0.15rem;
    }
    
    .metric-subtitle {
        font-size: 0.65rem;
    }

    .dashboard-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-box {
        max-width: 100%;
    }

    .btn {
        width: 100%;
    }

    .digital-id-card {
        width: 100%;
        max-width: 320px;
    }
    
    .payment-selection {
        grid-template-columns: 1fr; /* stacked payment options on small screen */
    }
}
