/* ============================================
   Capital CST - Mobile Reports Responsive CSS
   For standalone views (Layout = null)
   ============================================ */

/* ============================================
   1️⃣ BASE MOBILE OVERRIDES
   ============================================ */

@media (max-width: 768px) {
    /* Main content padding */
    .main-content {
        padding: 80px 12px 30px !important;
    }

    /* Page header */
    .page-header {
        margin-bottom: 25px !important;
    }

    .page-header h1 {
        font-size: 1.3rem !important;
    }

    .page-icon {
        width: 55px !important;
        height: 55px !important;
        font-size: 1.3rem !important;
        border-radius: 14px !important;
    }

    /* Navbar */
    .navbar-custom {
        padding: 10px 0 !important;
    }

    .navbar-custom .container {
        padding: 0 12px !important;
    }

    .navbar-brand {
        font-size: 0.95rem !important;
        gap: 8px !important;
    }

    .brand-icon {
        width: 32px !important;
        height: 32px !important;
        font-size: 0.9rem !important;
    }

    .back-btn {
        font-size: 0.85rem !important;
        padding: 8px 14px !important;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 75px 8px 25px !important;
    }

    .page-header h1 {
        font-size: 1.15rem !important;
    }

    .page-icon {
        width: 45px !important;
        height: 45px !important;
        font-size: 1.1rem !important;
    }
}

/* ============================================
   2️⃣ GRIDS → SINGLE COLUMN ON MOBILE
   ============================================ */

@media (max-width: 768px) {
    /* Summary / Stats grids */
    .summary-grid,
    .stats-grid,
    .stats-row,
    .balance-grid,
    .discrepancy-details {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    /* Summary cards → horizontal compact layout */
    .summary-card {
        padding: 14px 16px !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 12px !important;
        text-align: right !important;
        border-radius: 12px !important;
    }

    .summary-card .summary-label,
    .summary-card .summary-sub {
        text-align: right !important;
    }

    .summary-card .summary-value {
        font-size: 1.4rem !important;
    }

    .summary-card .summary-label {
        font-size: 0.8rem !important;
        margin-bottom: 2px !important;
    }

    .summary-card .summary-sub {
        font-size: 0.75rem !important;
    }

    .summary-card .summary-label + .summary-value + .summary-sub {
        margin-top: 2px !important;
    }

    /* Stat cards (alternative pattern) */
    .stat-card {
        padding: 14px 16px !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 12px !important;
    }

    /* Filter rows */
    .filter-row,
    .filters-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    /* Charts grids */
    .charts-grid {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }

    /* Period grids */
    .periods-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    /* Month selector: 3 columns instead of 4 */
    .month-selector {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px !important;
    }

    /* Years grid */
    .years-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    /* Form rows */
    .form-row {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    /* Cards grid (Reports hub) */
    .cards-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }
}

@media (max-width: 480px) {
    .summary-card .summary-value {
        font-size: 1.2rem !important;
    }

    .month-selector {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ============================================
   3️⃣ CARDS & CONTAINERS
   ============================================ */

@media (max-width: 768px) {
    .card {
        padding: 14px !important;
        border-radius: 14px !important;
        margin-bottom: 12px !important;
    }

    .card-title {
        font-size: 1rem !important;
        margin-bottom: 14px !important;
    }

    /* Sections (used in DailyReport etc.) */
    .section {
        border-radius: 14px !important;
        margin-bottom: 12px !important;
    }

    .section-header {
        padding: 12px 14px !important;
    }

    .section-header h3 {
        font-size: 0.9rem !important;
    }
}

/* ============================================
   4️⃣ TABLES → HORIZONTAL SCROLL + COMPACT
   ============================================ */

@media (max-width: 768px) {
    /* Wrap tables in scrollable container */
    .data-table,
    .installment-inner-table {
        display: block !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        white-space: nowrap !important;
    }

    .data-table thead,
    .data-table tbody,
    .data-table tr,
    .installment-inner-table thead,
    .installment-inner-table tbody,
    .installment-inner-table tr {
        display: revert !important;
    }

    .data-table th,
    .data-table td {
        padding: 8px 10px !important;
        font-size: 0.8rem !important;
        white-space: nowrap !important;
    }

    .installment-inner-table th,
    .installment-inner-table td {
        padding: 6px 8px !important;
        font-size: 0.75rem !important;
        white-space: nowrap !important;
    }

    /* Scroll hint shadow */
    [style*="overflow-x: auto"],
    div:has(> .data-table) {
        position: relative;
        -webkit-overflow-scrolling: touch;
    }
}

/* ============================================
   5️⃣ TABS & STATUS FILTERS
   ============================================ */

@media (max-width: 768px) {
    /* Tab buttons → horizontal scroll */
    .tab-buttons {
        display: flex !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        gap: 8px !important;
        padding-bottom: 8px !important;
        margin-bottom: 15px !important;
        scrollbar-width: none !important;
    }

    .tab-buttons::-webkit-scrollbar {
        display: none !important;
    }

    .tab-btn {
        padding: 8px 14px !important;
        font-size: 0.8rem !important;
        white-space: nowrap !important;
        flex-shrink: 0 !important;
        border-radius: 8px !important;
    }

    /* Status filter buttons */
    .status-filter {
        display: flex !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        gap: 8px !important;
        padding-bottom: 8px !important;
        scrollbar-width: none !important;
    }

    .status-filter::-webkit-scrollbar {
        display: none !important;
    }

    .status-btn {
        padding: 8px 14px !important;
        font-size: 0.8rem !important;
        white-space: nowrap !important;
        flex-shrink: 0 !important;
    }
}

/* ============================================
   6️⃣ FORMS & INPUT ELEMENTS
   ============================================ */

@media (max-width: 768px) {
    .form-group {
        margin-bottom: 12px !important;
    }

    .form-group label {
        font-size: 0.85rem !important;
        margin-bottom: 6px !important;
    }

    .form-control,
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="date"],
    input[type="search"],
    select,
    textarea {
        font-size: 16px !important; /* Prevents iOS zoom */
        padding: 10px 12px !important;
        border-radius: 10px !important;
        min-height: 44px !important;
    }

    /* Action buttons */
    .btn {
        min-height: 44px !important;
        font-size: 0.9rem !important;
        padding: 10px 16px !important;
        border-radius: 10px !important;
    }

    .form-actions {
        flex-direction: column !important;
        gap: 10px !important;
    }

    .form-actions .btn {
        width: 100% !important;
    }
}

/* ============================================
   7️⃣ BADGES & SMALL ELEMENTS
   ============================================ */

@media (max-width: 768px) {
    .badge-paid,
    .badge-unpaid,
    .badge-overdue,
    .badge-partial,
    .badge-cash,
    .badge-installment,
    [class*="badge-"] {
        font-size: 0.7rem !important;
        padding: 3px 8px !important;
    }
}

/* ============================================
   8️⃣ PRINT BUTTON → FULL WIDTH BAR
   ============================================ */

@media (max-width: 768px) {
    .print-btn {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        border-radius: 0 !important;
        padding: 14px !important;
        text-align: center !important;
        font-size: 0.95rem !important;
        z-index: 100 !important;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15) !important;
    }

    /* Add bottom padding to main content so print btn doesn't cover content */
    .main-content {
        padding-bottom: 70px !important;
    }
}

/* ============================================
   9️⃣ TYPOGRAPHY ADJUSTMENTS
   ============================================ */

@media (max-width: 768px) {
    h1 { font-size: 1.3rem !important; }
    h2 { font-size: 1.15rem !important; }
    h3 { font-size: 1rem !important; }
    h4 { font-size: 0.95rem !important; }

    .amount-green,
    .amount-red,
    .amount-orange,
    .amount-cash,
    .amount-installment,
    .amount-remaining,
    .amount-paid,
    .amount-overdue {
        font-size: 0.85rem !important;
    }
}

/* ============================================
   🔟 MODALS & ALERTS
   ============================================ */

@media (max-width: 768px) {
    .alert,
    .alert-danger,
    .alert-success,
    .alert-warning,
    .alert-info {
        padding: 12px 14px !important;
        font-size: 0.85rem !important;
        border-radius: 12px !important;
    }

    .modal-content {
        width: calc(100% - 24px) !important;
        margin: 12px !important;
        border-radius: 16px !important;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 14px !important;
    }
}

/* ============================================
   1️⃣1️⃣ PROGRESS BARS
   ============================================ */

@media (max-width: 768px) {
    .progress-bar-container {
        height: 6px !important;
        margin-top: 6px !important;
    }
}

/* ============================================
   1️⃣2️⃣ EXPANDABLE ROWS (InstallmentsReport)
   ============================================ */

@media (max-width: 768px) {
    .student-row {
        cursor: pointer;
    }

    .installment-detail td {
        padding: 8px !important;
    }

    .installment-detail > td > div {
        padding: 8px !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
}

/* ============================================
   1️⃣3️⃣ PERIOD/DATE CARDS
   ============================================ */

@media (max-width: 768px) {
    .period-card,
    .month-btn {
        padding: 10px !important;
        font-size: 0.85rem !important;
        border-radius: 10px !important;
    }

    .period-info {
        font-size: 0.8rem !important;
    }
}

/* ============================================
   1️⃣4️⃣ RECEIPT / PRINT VIEWS
   ============================================ */

@media (max-width: 768px) {
    .receipt-container,
    .receipt {
        padding: 15px !important;
        font-size: 0.85rem !important;
    }
}

/* ============================================
   1️⃣5️⃣ CHART CONTAINERS
   ============================================ */

@media (max-width: 768px) {
    canvas {
        max-height: 250px !important;
    }

    .chart-container {
        padding: 12px !important;
    }
}

/* ============================================
   1️⃣6️⃣ OVERDUE / ALERT BOXES
   ============================================ */

@media (max-width: 768px) {
    .overdue-alert,
    .alert-box,
    .info-box,
    .warning-box {
        padding: 12px 14px !important;
        font-size: 0.85rem !important;
        border-radius: 12px !important;
    }

    .overdue-alert .count,
    .alert-box .count {
        font-size: 1.3rem !important;
    }
}

/* ============================================
   1️⃣7️⃣ SEARCH & FILTER BARS
   ============================================ */

@media (max-width: 768px) {
    .search-box,
    .search-container {
        width: 100% !important;
    }

    .search-box input,
    .search-container input {
        width: 100% !important;
        font-size: 16px !important;
    }

    .filter-actions {
        flex-direction: column !important;
        gap: 8px !important;
    }

    .filter-actions .btn {
        width: 100% !important;
    }
}

/* ============================================
   1️⃣8️⃣ EXAM & SCHEDULE SPECIFIC
   ============================================ */

@media (max-width: 768px) {
    .schedule-grid,
    .exam-grid,
    .question-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    .question-card,
    .exam-card {
        padding: 12px !important;
    }

    .time-slot {
        font-size: 0.8rem !important;
    }
}

/* ============================================
   1️⃣9️⃣ SAFE AREA (NOTCHED PHONES)
   ============================================ */

@supports (padding: env(safe-area-inset-bottom)) {
    @media (max-width: 768px) {
        .main-content {
            padding-bottom: calc(70px + env(safe-area-inset-bottom)) !important;
        }

        .print-btn {
            padding-bottom: calc(14px + env(safe-area-inset-bottom)) !important;
        }
    }
}

/* ============================================
   2️⃣0️⃣ REPORTS HUB SPECIFIC
   ============================================ */

@media (max-width: 768px) {
    .report-section {
        margin-bottom: 20px !important;
    }

    .section-title {
        font-size: 1rem !important;
        margin-bottom: 12px !important;
    }

    .report-card,
    .action-card {
        padding: 14px !important;
        border-radius: 12px !important;
    }

    .report-card .card-icon,
    .action-card .card-icon {
        width: 40px !important;
        height: 40px !important;
        font-size: 1rem !important;
    }

    .report-card h4,
    .action-card h4 {
        font-size: 0.9rem !important;
    }

    .report-card p,
    .action-card p {
        font-size: 0.8rem !important;
    }
}

/* ============================================
   2️⃣1️⃣ MATERIALS & SCHEDULE VIEWS
   ============================================ */

@media (max-width: 768px) {
    .material-card,
    .subject-card {
        padding: 12px !important;
        border-radius: 12px !important;
    }

    .material-card .material-icon {
        width: 40px !important;
        height: 40px !important;
    }

    .schedule-table {
        display: block !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .schedule-table th,
    .schedule-table td {
        padding: 8px !important;
        font-size: 0.8rem !important;
        white-space: nowrap !important;
    }
}

/* ============================================
   2️⃣2️⃣ STUDENT DASHBOARD
   ============================================ */

@media (max-width: 768px) {
    .welcome-card {
        padding: 20px 15px !important;
        border-radius: 16px !important;
    }

    .welcome-card h2 {
        font-size: 1.2rem !important;
    }

    .info-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }
}

/* ============================================
   2️⃣3️⃣ PERMISSIONS & SETTINGS
   ============================================ */

@media (max-width: 768px) {
    .permission-group {
        padding: 12px !important;
    }

    .permission-item {
        padding: 10px 0 !important;
        font-size: 0.85rem !important;
    }

    .setting-card {
        padding: 14px !important;
    }

    .branch-card {
        padding: 12px !important;
    }
}

/* ============================================
   2️⃣4️⃣ HOME PAGE SPECIFIC
   ============================================ */

@media (max-width: 768px) {
    .hero-section {
        padding: 30px 15px !important;
    }

    .hero-section h1 {
        font-size: 1.5rem !important;
    }

    .hero-section p {
        font-size: 0.9rem !important;
    }

    .features-grid,
    .services-grid,
    .news-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .feature-card,
    .service-card,
    .news-card {
        padding: 14px !important;
    }

    .registration-form {
        padding: 20px 15px !important;
    }
}

/* ============================================
   2️⃣5️⃣ REDUCED MOTION
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
