/* ============================================================
   Payments Page — Clean Mobile-First CSS
   ============================================================ */

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

html, body {
    width: 100%;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f8fafc;
    color: #334155;
    line-height: 1.6;
}

/* --- LAYOUT --- */
.container {
    display: flex;
    min-height: 100vh;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    width: 280px;
    background: linear-gradient(180deg, #1e3a5f 0%, #1e293b 100%);
    box-shadow: 2px 0 10px rgba(0,0,0,0.05);
    padding: 2rem 0;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 16px;
}

.parent-icon {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.12);
    color: #7dd3fc;
    font-size: 18px;
}

.sidebar-header-text {
    min-width: 0;
}

.sidebar-role {
    font-size: 10px;
    font-weight: 700;
    color: #7dd3fc;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 2px;
}

.sidebar-name {
    font-size: 15px;
    font-weight: 600;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: #3b82f6;
    margin-bottom: 0.5rem;
}

.logo .icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
}

.nav-menu {
    list-style: none;
    padding: 24px 0;
}

.nav-item {
    margin-bottom: 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 2rem;
    color: #64748b;
    text-decoration: none;
    transition: all 0.2s ease;
    border-right: 3px solid transparent;
}

.nav-link:hover,
.nav-link.active {
    background-color: #f1f5f9;
    color: #3b82f6;
    border-right-color: #3b82f6;
}

.nav-link i {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

/* Parent portal nav items (navy sidebar) */
.nav-link.parent-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    margin: 2px 12px;
    color: #cbd5e1;
    border-radius: 8px;
    border-right: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}

.nav-link.parent-nav-item i {
    width: 18px;
    text-align: center;
    font-size: 15px;
}

.nav-link.parent-nav-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.nav-link.parent-nav-item.active {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

/* Parent identity / child switcher */
.parent-identity {
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    margin: 4px 12px 12px;
}

.parent-label {
    font-size: 11px;
    color: #94a3b8;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.child-switcher-select {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    color: #1e293b;
    background: white;
    cursor: pointer;
}

/* Sidebar footer (logout) */
.sidebar-footer {
    margin-top: auto;
    padding: 16px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logout {
    color: #f87171;
    font-weight: 700;
}

.sidebar-logout:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
}

.user-section {
    position: absolute;
    bottom: 2rem;
    left: 2rem;
    right: 2rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: #3b82f6;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    flex-shrink: 0;
}

.logout-btn {
    width: 100%;
    padding: 10px;
    background: #fee2e2;
    color: #dc2626;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
}

.logout-btn:hover { background: #fecaca; }

/* Sidebar Overlay (mobile backdrop) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
    flex: 1;
    margin-left: 280px;
    padding: 2rem;
    min-width: 0; /* prevents flex blowout */
}

/* --- Header --- */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    background: white;
    padding: 1.25rem 1.5rem;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    gap: 1rem;
}

.header-content h1 {
    font-size: 1.6rem;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.2;
}

.header-content p {
    color: #64748b;
    font-size: 0.9rem;
    margin-top: 2px;
}

.header-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.icon-btn {
    width: 40px;
    height: 40px;
    background: #f1f5f9;
    border: none;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #64748b;
    font-size: 15px;
    transition: background 0.2s ease;
}

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

/* Hide hamburger on desktop */
#menuToggle { display: none; }

/* ============================================================
   LOADING STATE
   ============================================================ */
.loading-state {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 50vh;
    padding: 2rem;
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: #64748b;
}

.loading-spinner i { font-size: 2rem; }
.loading-spinner span { font-size: 1rem; }

/* ============================================================
   PAYMENT CARD
   ============================================================ */
.payment-card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    overflow: hidden;
    width: 100%;
}

/* Payment status banner (paid / outstanding) */
#paymentStatusBanner.payment-status.paid,
#paymentStatusBanner.payment-status.outstanding {
    border-radius: 8px;
    padding: 12px 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

#paymentStatusBanner.payment-status.paid {
    background: #f0fdf4;
    border: 1px solid #86efac;
    color: #166534;
}

#paymentStatusBanner.payment-status.outstanding {
    background: #fff7ed;
    border: 1px solid #fdba74;
    color: #9a3412;
}

/* School Info Header */
.school-info-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    border-bottom: 1px solid #f1f5f9;
}

.school-logo img {
    width: 56px;
    height: 56px;
    border-radius: 0.75rem;
    object-fit: cover;
    flex-shrink: 0;
}

.school-details h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 2px;
}

.school-details p {
    font-size: 0.85rem;
    color: #64748b;
}

/* Sections */
.compulsory-section,
.services-section {
    padding: 1.5rem;
}

.compulsory-section {
    border-bottom: 1px solid #f1f5f9;
}

.section-title {
    font-size: 1rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e2e8f0;
}

/* ============================================================
   PAYMENT ITEMS
   ============================================================ */
.payment-items {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.payment-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    gap: 0.75rem;
}

.payment-item:hover:not(.compulsory) {
    border-color: #6366f1;
    box-shadow: 0 2px 8px rgba(99,102,241,0.1);
}

.payment-item.selected {
    border-color: #10b981;
    background: #f0fdf4;
}

.payment-item.compulsory {
    border-color: #f59e0b;
    background: #fefce8;
    cursor: not-allowed;
}

.item-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}

.item-checkbox {
    width: 22px;
    height: 22px;
    min-width: 22px;
    border: 2px solid #d1d5db;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.item-checkbox.checked  { background: #10b981; border-color: #10b981; color: white; }
.item-checkbox.disabled { background: #f59e0b; border-color: #f59e0b; color: white; }
.item-checkbox i { font-size: 11px; }

.item-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}

.item-icon {
    width: 38px;
    height: 38px;
    min-width: 38px;
    background: #f1f5f9;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6366f1;
    font-size: 0.95rem;
}

.item-details {
    flex: 1;
    min-width: 0;
}

.item-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: #1e293b;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-description {
    font-size: 0.8rem;
    color: #64748b;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-badge {
    display: inline-block;
    padding: 2px 8px;
    background: #f59e0b;
    color: white;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.item-price {
    font-weight: 700;
    color: #059669;
    font-size: 1rem;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: #64748b;
}

.empty-icon {
    font-size: 3rem;
    color: #d1d5db;
    margin-bottom: 1rem;
}

.empty-state h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 0.5rem;
}

.empty-state p {
    font-size: 0.9rem;
    max-width: 360px;
    margin: 0 auto;
    line-height: 1.6;
}

/* ============================================================
   PAYMENT SUMMARY
   ============================================================ */
.summary-section {
    padding: 1.5rem;
    border-top: 1px solid #f1f5f9;
}

.summary-section .section-title {
    margin-bottom: 1rem;
}

.summary-items {
    margin-bottom: 1rem;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.625rem 0;
    border-bottom: 1px solid #f1f5f9;
    gap: 1rem;
}

.summary-item:last-child { border-bottom: none; }

.summary-item span:first-child {
    color: #64748b;
    font-size: 0.9rem;
}

.summary-item span:last-child {
    font-weight: 600;
    color: #1e293b;
    font-size: 0.9rem;
    text-align: right;
}

.summary-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-top: 2px solid #e2e8f0;
    margin-bottom: 1.25rem;
    gap: 1rem;
}

.total-label {
    font-size: 1rem;
    font-weight: 600;
    color: #1e293b;
}

.total-amount {
    font-size: 1.4rem;
    font-weight: 700;
    color: #059669;
}

/* Pay Button */
.pay-button {
    width: 100%;
    padding: 14px 1rem;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    min-height: 50px;
    touch-action: manipulation;
}

.pay-button:hover {
    background: linear-gradient(135deg, #2563eb, #1e3a8a);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(59,130,246,0.35);
}

.pay-button:active { transform: translateY(0); }

/* ============================================================
   UNIVERSAL INPUT PROTECTION (iOS Safari anti-zoom)
   ============================================================ */
input, select, textarea, button {
    font-size: 16px !important;
    touch-action: manipulation !important;
}

/* ============================================================
   RESPONSIVE — TABLET (≤ 1024px)
   ============================================================ */
@media (max-width: 1024px) {
    .main-content { padding: 1.5rem; }
}

/* ============================================================
   RESPONSIVE — MOBILE (≤ 768px)
   All mobile rules are consolidated here — no duplicates.
   ============================================================ */
@media (max-width: 768px) {

    /* Sidebar: slide off-screen; JS adds .active to show it */
    .sidebar {
        transform: translateX(-100%);
        z-index: 1000;
        width: 260px;
    }

    .sidebar.active {
        transform: translateX(0);
    }

    /* Main content: full width, no left margin */
    .main-content {
        margin-left: 0;
        padding: 0.875rem;
        width: 100%;
    }

    /* Header: keep as row (title left, buttons right) */
    .header {
        padding: 0.875rem 1rem;
        margin-bottom: 1rem;
        gap: 0.75rem;
        align-items: flex-start;
    }

    .header-content h1 {
        font-size: 1.2rem;
        line-height: 1.25;
    }

    .header-content p {
        font-size: 0.8rem;
    }

    /* Show hamburger on mobile */
    #menuToggle { display: flex; }

    /* Payment card: tighter radius on mobile */
    .payment-card { border-radius: 12px; }

    /* School header: stack vertically */
    .school-info-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 1rem;
        gap: 0.75rem;
    }

    .school-logo img {
        width: 52px;
        height: 52px;
    }

    .school-details h2 { font-size: 1rem; }
    .school-details p  { font-size: 0.8rem; }

    /* Sections: tighter padding */
    .compulsory-section,
    .services-section {
        padding: 1rem;
    }

    .section-title {
        font-size: 0.9rem;
        margin-bottom: 0.75rem;
    }

    /* Payment items: stack price on new line when needed */
    .payment-item {
        padding: 0.875rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .item-left {
        /* Let item-left take full row, price goes below */
        min-width: 0;
        flex: 1 1 auto;
    }

    .item-price {
        font-size: 0.95rem;
        min-width: fit-content;
    }

    .item-icon {
        width: 34px;
        height: 34px;
        min-width: 34px;
        font-size: 0.85rem;
    }

    .item-name { font-size: 0.875rem; }
    .item-description { font-size: 0.75rem; }

    /* Summary */
    .summary-section {
        padding: 1rem;
    }

    .summary-item span:first-child,
    .summary-item span:last-child {
        font-size: 0.85rem;
    }

    .total-label  { font-size: 0.9rem; }
    .total-amount { font-size: 1.2rem; }

    /* Pay button: full-width, big tap target */
    .pay-button {
        padding: 15px 1rem;
        font-size: 0.95rem;
        border-radius: 10px;
        min-height: 52px;
    }

    /* Empty state */
    .empty-state {
        padding: 2rem 1rem;
    }

    .empty-icon   { font-size: 2.5rem; }
    .empty-state h3 { font-size: 1rem; }
    .empty-state p  { font-size: 0.85rem; }

    /* Loading */
    .loading-state { min-height: 40vh; padding: 2rem 1rem; }
    .loading-spinner span { font-size: 0.875rem; }
}

/* ============================================================
   RESPONSIVE — SMALL PHONES (≤ 420px)
   ============================================================ */
@media (max-width: 420px) {

    .main-content { padding: 0.625rem; }

    .header {
        padding: 0.75rem;
        margin-bottom: 0.75rem;
    }

    .header-content h1 { font-size: 1.05rem; }
    .header-content p  { font-size: 0.75rem; }

    .school-info-header { padding: 0.875rem; }

    .compulsory-section,
    .services-section {
        padding: 0.875rem;
    }

    .payment-item { padding: 0.75rem; }

    .item-checkbox { width: 20px; height: 20px; min-width: 20px; }

    .item-icon {
        width: 30px;
        height: 30px;
        min-width: 30px;
        font-size: 0.8rem;
    }

    .item-name { font-size: 0.825rem; }
    .item-price { font-size: 0.875rem; }

    .summary-section { padding: 0.875rem; }

    .total-amount { font-size: 1.1rem; }

    .pay-button {
        padding: 13px 0.875rem;
        font-size: 0.9rem;
        min-height: 48px;
    }
}