/*
 * RCC Mobile-First Responsive Styles
 * Ensures all components work perfectly on mobile devices
 */

/* ========== MOBILE-FIRST BASE STYLES ========== */

/* Ensure proper spacing and gaps on all devices */
.gap-2 {
    gap: 0.5rem !important;
}

.gap-3 {
    gap: 1rem !important;
}

/* ========== RESPONSIVE HEADERS ========== */

/* Page headers should stack on mobile */
.page-header {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

@media (min-width: 768px) {
    .page-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
}

/* ========== RESPONSIVE BUTTONS ========== */

/* Buttons should be full-width on mobile, auto on larger screens */
.btn-responsive {
    width: 100%;
}

@media (min-width: 576px) {
    .btn-responsive {
        width: auto;
    }
}

/* Button groups should stack on mobile */
.btn-group-responsive {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

@media (min-width: 576px) {
    .btn-group-responsive {
        flex-direction: row;
        gap: 0.5rem;
    }
}

/* ========== RESPONSIVE TABLES ========== */

/* Always wrap tables in responsive container */
.table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Hide certain columns on mobile */
@media (max-width: 767px) {
    .hide-on-mobile {
        display: none !important;
    }

    /* Make table text smaller on mobile */
    .table {
        font-size: 0.875rem;
    }

    /* Compact action buttons on mobile */
    .table .btn-sm {
        padding: 0.2rem 0.4rem;
        font-size: 0.75rem;
    }
}

/* ========== RESPONSIVE CARDS ========== */

/* Cards should have less padding on mobile */
.card-body-responsive {
    padding: 1rem;
}

@media (min-width: 768px) {
    .card-body-responsive {
        padding: 1.5rem;
    }
}

/* ========== RESPONSIVE FORMS ========== */

/* Form groups should have appropriate spacing */
.form-group {
    margin-bottom: 1rem;
}

/* Labels should be clear on mobile */
label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: inline-block;
}

/* Form controls should be touch-friendly */
.form-control {
    min-height: 44px; /* iOS recommended minimum */
    font-size: 16px; /* Prevents iOS zoom on focus */
}

/* Select dropdowns should be touch-friendly */
select.form-control {
    min-height: 44px;
}

/* Checkboxes and radios should be larger on mobile */
.form-check-input {
    width: 1.25rem;
    height: 1.25rem;
}

/* ========== RESPONSIVE MODALS ========== */

/* Modals should be full-width on mobile */
@media (max-width: 575px) {
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }

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

/* Modal content should have appropriate padding on mobile */
.modal-body {
    padding: 1rem;
}

@media (min-width: 768px) {
    .modal-body {
        padding: 1.5rem;
    }
}

/* ========== RESPONSIVE NAVIGATION ========== */

/* Sidebar should be collapsible on mobile */
@media (max-width: 767px) {
    .admin-sidebar,
    .teacher-sidebar,
    .student-sidebar {
        position: fixed;
        left: -250px;
        transition: left 0.3s ease;
        z-index: 1050;
    }

    .admin-sidebar.show,
    .teacher-sidebar.show,
    .student-sidebar.show {
        left: 0;
    }

    .admin-content,
    .teacher-content,
    .student-content {
        margin-left: 0 !important;
    }

    /* Page headings should have space for toggle button */
    .admin-content h2:first-of-type,
    .teacher-content h2:first-of-type,
    .student-content h2:first-of-type,
    .admin-content .page-header h2,
    .teacher-content .page-header h2,
    .student-content .page-header h2 {
        padding-right: 60px;
    }

    /* Page header action buttons should be full-width on mobile */
    .page-header-actions .btn {
        width: 100% !important;
    }
}

/* Hamburger menu button for mobile */
.mobile-menu-toggle {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1051;
    display: block;
    background: #333;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.25rem;
}

@media (min-width: 768px) {
    .mobile-menu-toggle {
        display: none;
    }
}

/* ========== RESPONSIVE PAGINATION ========== */

/* Pagination should wrap on mobile */
.pagination {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.25rem;
}

/* Hide some page numbers on mobile */
@media (max-width: 575px) {
    .pagination .page-item:not(.active):not(:first-child):not(:last-child):nth-child(n+5) {
        display: none;
    }
}

/* ========== RESPONSIVE FILTERS ========== */

/* Filter sections should stack on mobile */
.filter-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (min-width: 768px) {
    .filter-section {
        flex-direction: row;
        align-items: center;
    }
}

/* ========== RESPONSIVE GRIDS ========== */

/* Ensure grid columns stack properly on mobile */
.row > [class*='col-'] {
    padding-left: 12px;
    padding-right: 12px;
}

@media (max-width: 575px) {
    .row > [class*='col-'] {
        padding-left: 8px;
        padding-right: 8px;
    }
}

/* ========== RESPONSIVE TEXT ========== */

/* Headings should scale appropriately */
h1 {
    font-size: 1.75rem;
}

h2 {
    font-size: 1.5rem;
}

h3 {
    font-size: 1.25rem;
}

@media (min-width: 768px) {
    h1 {
        font-size: 2.5rem;
    }

    h2 {
        font-size: 2rem;
    }

    h3 {
        font-size: 1.75rem;
    }
}

/* ========== RESPONSIVE SPACING ========== */

/* Reduce margins and padding on mobile */
@media (max-width: 575px) {
    .mb-4 {
        margin-bottom: 1rem !important;
    }

    .my-4 {
        margin-top: 1rem !important;
        margin-bottom: 1rem !important;
    }

    .py-4 {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }
}

/* ========== RESPONSIVE ALERTS ========== */

/* Alerts should be easy to dismiss on mobile */
.alert {
    position: relative;
    padding-right: 3rem; /* Space for close button */
}

.alert .close {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    padding: 0.5rem;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ========== RESPONSIVE BADGES ========== */

/* Badges should be readable on mobile */
.badge {
    font-size: 85%;
    padding: 0.35em 0.6em;
    white-space: nowrap;
}

@media (max-width: 575px) {
    .badge {
        font-size: 75%;
        padding: 0.25em 0.5em;
    }
}

/* ========== UTILITY CLASSES ========== */

/* Touch-friendly minimum sizes */
.touch-target {
    min-width: 44px;
    min-height: 44px;
}

/* Prevent text selection on buttons and interactive elements */
.btn,
.page-link,
.close {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Prevent horizontal scroll */
body {
    overflow-x: hidden;
}

/* ========== RESPONSIVE LOADING SPINNER ========== */

/* Loading spinner should be centered and visible on all devices */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    padding: 2rem;
}

.spinner-border {
    width: 3rem;
    height: 3rem;
}

@media (max-width: 575px) {
    .spinner-border {
        width: 2rem;
        height: 2rem;
    }
}

/* ========== PRINT STYLES ========== */

@media print {
    .no-print,
    .btn,
    .admin-sidebar,
    .teacher-sidebar,
    .student-sidebar,
    .mobile-menu-toggle {
        display: none !important;
    }

    .admin-content,
    .teacher-content,
    .student-content {
        margin-left: 0 !important;
    }
}
