/**
 * Rabeya Girls Hostel — shared responsive styles (admin + public)
 */

/* ─── Admin: page headers & action buttons ─── */
@media (max-width: 767.98px) {
    .page-header,
    .d-flex.justify-content-between.align-items-center,
    .dashboard-header,
    .payments-header,
    .payment-form-header,
    .payment-detail-header,
    .categories-page .page-header,
    .payment-heads-page .page-header {
        flex-direction: column !important;
        flex-wrap: wrap !important;
        align-items: stretch !important;
        gap: 0.75rem !important;
    }

    .page-header h1,
    .page-header h2,
    .page-header h3,
    .page-title,
    .d-flex.justify-content-between.align-items-center h1,
    .d-flex.justify-content-between.align-items-center h2,
    .d-flex.justify-content-between.align-items-center h3,
    .dashboard-header h1,
    .payments-header h1 {
        width: 100% !important;
        font-size: 1.35rem !important;
    }

    .page-header > div:last-child,
    .d-flex.justify-content-between.align-items-center > div:last-child,
    .d-flex.justify-content-between > div:last-child,
    .dashboard-header-actions,
    .payments-header > div,
    .page-header-actions,
    .categories-page .page-header > div:last-child,
    .payment-heads-page .page-header > div {
        width: 100% !important;
        margin-left: 0 !important;
        white-space: normal !important;
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
        justify-content: flex-start !important;
    }

    .page-header .btn,
    .page-header a.btn,
    .d-flex.justify-content-between.align-items-center .btn,
    .d-flex.justify-content-between.align-items-center a.btn,
    .d-flex.justify-content-between .btn,
    .payments-header .btn-add-payment,
    .payments-header .btn-report,
    .categories-page .btn-add,
    .payment-heads-page .btn-add {
        flex: 1 1 calc(50% - 0.25rem) !important;
        min-width: 0 !important;
        white-space: normal !important;
        text-align: center !important;
        justify-content: center !important;
    }

    .page-header a:only-child,
    .d-flex.justify-content-between.align-items-center > div:last-child a:only-child,
    .d-flex.justify-content-between.align-items-center > div:last-child .btn:only-child {
        flex: 1 1 100% !important;
    }
}

/* ─── Admin: top navbar ─── */
@media (max-width: 767.98px) {
    header.navbar .container-xl {
        flex-wrap: wrap;
        gap: 0.35rem;
    }

    header.navbar .navbar-brand {
        font-size: 0.9rem !important;
        max-width: calc(100% - 3rem);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    header.navbar .navbar-nav.flex-row {
        width: 100%;
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: 0.35rem;
        padding-bottom: 0.25rem;
    }

    header.navbar .nav-item .btn {
        padding: 0.35rem 0.6rem !important;
        font-size: 0.8rem !important;
    }

    header.navbar .nav-item form {
        width: auto;
    }
}

@media (max-width: 400px) {
    header.navbar .nav-item .btn {
        padding: 0.3rem 0.45rem !important;
        font-size: 0.75rem !important;
    }
}

/* ─── Admin: tables ─── */
.table-responsive {
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 767.98px) {
    .table-responsive,
    .payments-table-wrapper,
    .report-print-area {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .payments-table-wrapper {
        overflow: visible;
    }

    .payments-table-wrapper .table-responsive-inner,
    .payments-table-wrapper > .payments-table-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table th,
    .table td {
        font-size: 0.85rem;
        padding: 0.5rem 0.4rem;
        vertical-align: middle;
    }

    .action-buttons,
    .btn-list {
        display: flex;
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .action-buttons .btn,
    .btn-list .btn {
        padding: 0.25rem 0.45rem;
        font-size: 0.75rem;
    }
}

/* ─── Admin: forms & filters ─── */
@media (max-width: 767.98px) {
    .container-xl,
    .container-fluid {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

    .card-body {
        padding: 0.75rem !important;
    }

    .filters-card,
    .table-card {
        padding: 1rem !important;
    }

    .row.g-3 > [class*="col-"],
    .row.g-2 > [class*="col-"] {
        margin-bottom: 0.25rem;
    }

    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }

    .payment-item-row .col-md-1,
    .payment-item-row .col-md-2,
    .payment-item-row .col-md-3,
    .payment-item-row .col-md-5,
    .payment-item-row .col-md-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .payment-item-row .d-flex.gap-1 {
        justify-content: flex-start;
    }
}

/* ─── Admin: reports toolbar ─── */
@media (max-width: 767.98px) {
    .report-toolbar {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    .report-toolbar .d-flex {
        flex-wrap: wrap;
        width: 100%;
    }

    .report-toolbar .btn {
        flex: 1 1 auto;
    }

    .report-print-area {
        padding: 1rem !important;
        overflow-x: auto;
    }

    .report-print-area .table {
        min-width: 520px;
        font-size: 0.85rem;
    }
}

/* ─── Admin: receipt screen preview ─── */
@media (max-width: 767.98px) {
    body:has(.receipt-page) {
        background: #e5e7eb;
    }

    .receipt-page {
        width: 100% !important;
        min-height: auto !important;
        margin: 0.5rem !important;
        border-radius: 8px;
    }

    .no-print.print-button,
    .no-print.back-button {
        position: static !important;
        display: block;
        width: calc(100% - 1rem);
        margin: 0.5rem auto;
        text-align: center;
    }
}

/* ─── Public site extras (home) ─── */
@media (max-width: 767.98px) {
    .site-section,
    .section {
        padding: 3rem 0 !important;
    }

    .hero-split-wrapper .main-slide-content h1,
    .hero-content h1 {
        font-size: clamp(1.5rem, 6vw, 2rem) !important;
    }

    .about-content h2 {
        font-size: 1.75rem !important;
    }

    .navbar .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .site-navbar .brand-text {
        font-size: 0.95rem;
    }

    .hero-cta .btn,
    .cta-buttons .btn,
    .room-card .btn {
        width: 100%;
        max-width: 100%;
    }

    .footer-grid {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
    }

    .stat-card {
        padding: 1rem !important;
    }
}

@media (max-width: 575.98px) {
    .hero-split-wrapper .main-slider-col {
        height: 260px !important;
    }

    .hero-split-wrapper .rooms-slider-col {
        height: 280px !important;
    }

    .floating-social {
        right: 0 !important;
        bottom: 0.75rem !important;
        border-radius: 12px 0 0 12px !important;
    }

    .contact-intro {
        padding: 1.5rem 1rem !important;
    }

    .stat-card .stat-number {
        font-size: 1.75rem !important;
    }
}

/* ─── Admin: mobile sidebar ─── */
@media (max-width: 991.98px) {
    .navbar-vertical.navbar-expand-lg .navbar-collapse {
        position: fixed;
        top: 0;
        left: 0;
        width: 16rem;
        max-width: 85vw;
        height: 100vh;
        z-index: 1050;
        overflow-y: auto;
        background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.2);
        padding-top: 3.5rem;
    }

    .navbar-vertical.navbar-expand-lg .navbar-collapse:not(.show) {
        display: none !important;
    }

    .page-wrapper {
        margin-left: 0 !important;
    }
}

/* Filter form submit rows */
@media (max-width: 767.98px) {
    form .col-md-auto,
    form .col-auto.d-flex {
        width: 100%;
    }

    form .col-md-auto .btn,
    form .col-auto .btn {
        width: 100%;
    }
}

/* Touch-friendly targets */
@media (max-width: 767.98px) {
    .btn,
    .nav-link,
    .form-control,
    .form-select {
        min-height: 38px;
    }

    .btn-sm {
        min-height: 34px;
    }
}
