/* ========================================================
   ELMS - Comprehensive Mobile & Responsive Stylesheet
   Optimized for Smartphones (320px - 576px),
   Tablets (577px - 991px), and Desktops (992px+)
   ======================================================== */

/* --------------------------------------------------------
   1. GLOBAL & BASE VIEWPORT FIXES
   -------------------------------------------------------- */
html, body {
    overflow-x: hidden !important;
    width: 100%;
    max-width: 100%;
    -webkit-text-size-adjust: 100%;
}

img, video, iframe, embed, object {
    max-width: 100%;
    height: auto;
}

/* Ensure smooth touch scrolling on mobile */
* {
    -webkit-tap-highlight-color: transparent;
}

/* Prevent iOS Safari auto-zoom on input focus */
@media (max-width: 767.98px) {
    input[type="text"],
    input[type="tel"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="search"],
    select,
    textarea {
        font-size: 16px !important;
    }
}

/* Common Table Responsiveness */
.table-responsive {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    margin-bottom: 1rem;
}

/* --------------------------------------------------------
   2. PUBLIC NAVBAR & HEADER (Mobile & Tablet)
   -------------------------------------------------------- */
@media (max-width: 991.98px) {
    .navbar {
        padding: 8px 12px !important;
    }

    .navbar-brand img {
        max-height: 34px !important;
        max-width: 140px !important;
    }

    .navbar-toggler {
        padding: 5px 9px;
        font-size: 1.15rem;
        border: 1px solid rgba(0, 0, 0, 0.1);
        border-radius: 8px;
    }

    .navbar-toggler:focus {
        box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.25);
    }

    .navbar-collapse {
        background: #ffffff;
        padding: 16px;
        border-radius: 12px;
        margin-top: 10px;
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
        border: 1px solid #f1f5f9;
        max-height: 80vh;
        overflow-y: auto;
    }

    .navbar-nav {
        align-items: stretch !important;
        gap: 4px;
        margin-bottom: 14px !important;
    }

    .navbar-nav .nav-link {
        padding: 10px 14px !important;
        border-radius: 8px;
        font-size: 0.98rem;
    }

    .navbar-nav .nav-link:hover,
    .navbar-nav .nav-link.active {
        background: #f1f5f9;
        color: #4f46e5 !important;
    }

    .navbar-nav form[action*="courses"] {
        max-width: 100% !important;
        margin: 0 0 12px 0 !important;
    }

    .navbar-nav form[action*="courses"] input {
        width: 100%;
    }

    .navbar .d-flex.ms-lg-3 {
        margin-left: 0 !important;
        flex-direction: column;
        align-items: stretch !important;
        gap: 10px !important;
        padding-top: 10px;
        border-top: 1px solid #f1f5f9;
    }

    .navbar .dropdown-menu {
        border-radius: 10px;
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
        border: 1px solid #e2e8f0;
    }
}

/* --------------------------------------------------------
   3. HERO SECTION & HOME PAGE (Mobile)
   -------------------------------------------------------- */
@media (max-width: 767.98px) {
    .hero-section {
        padding: 40px 16px !important;
        text-align: center;
    }

    .hero-section h1,
    .hero-section .display-3 {
        font-size: 1.85rem !important;
        line-height: 1.25;
        margin-bottom: 12px !important;
    }

    .hero-section p.lead {
        font-size: 0.96rem !important;
        margin-bottom: 24px !important;
        padding: 0 8px;
    }

    .hero-section form {
        flex-direction: column;
        gap: 10px;
        margin-bottom: 24px !important;
        width: 100% !important;
    }

    .hero-section form input {
        border-radius: 10px !important;
        width: 100% !important;
        text-align: center;
        padding: 12px !important;
        font-size: 1rem !important;
    }

    .hero-section form button {
        border-radius: 10px !important;
        width: 100% !important;
        padding: 12px !important;
        font-weight: 700;
    }

    .hero-section .d-flex.justify-content-center.gap-3 {
        flex-direction: column;
        gap: 10px !important;
        width: 100%;
    }

    .hero-section .d-flex.justify-content-center.gap-3 a {
        width: 100%;
        text-align: center;
        padding: 12px;
        font-size: 0.98rem;
    }

    /* Counter / Stats Boxes */
    .counter-box {
        padding: 14px 10px !important;
        border-radius: 10px;
    }

    .counter-box h2,
    .counter-box .display-5 {
        font-size: 1.6rem !important;
    }

    .counter-box p {
        font-size: 0.78rem !important;
    }

    /* Course Cards */
    .course-card,
    .card.h-100 {
        margin-bottom: 16px;
        border-radius: 12px !important;
    }

    .course-thumbnail img,
    .card-img-top {
        height: 160px !important;
        object-fit: cover;
    }

    .category-card {
        padding: 18px 10px !important;
    }

    .category-icon {
        font-size: 1.8rem !important;
        margin-bottom: 8px !important;
    }

    .category-card h5 {
        font-size: 0.92rem;
    }
}

/* --------------------------------------------------------
   4. COURSES CATALOG & FILTERS (Mobile)
   -------------------------------------------------------- */
@media (max-width: 991.98px) {
    .courses-filter-sidebar {
        margin-bottom: 20px;
    }

    .course-card-horizontal {
        flex-direction: column !important;
    }

    .course-card-horizontal img {
        width: 100% !important;
        height: 180px !important;
    }
}

/* --------------------------------------------------------
   5. COURSE PLAYER / LEARN PAGE (Mobile)
   -------------------------------------------------------- */
@media (max-width: 767.98px) {
    .video-player-container {
        position: relative;
        width: 100%;
        aspect-ratio: 16 / 9;
        margin-bottom: 14px;
        border-radius: 10px;
        overflow: hidden;
    }

    .video-player-container iframe,
    .video-player-container video {
        width: 100%;
        height: 100%;
    }

    .course-learn-curriculum {
        max-height: none !important;
        margin-top: 14px;
    }

    .lesson-item {
        padding: 12px 10px !important;
        font-size: 0.88rem;
    }
}

/* --------------------------------------------------------
   6. ONLINE TESTS & QUIZ SYSTEM (Mobile)
   -------------------------------------------------------- */
@media (max-width: 767.98px) {
    .quiz-timer-bar {
        position: sticky;
        top: 0;
        z-index: 100;
        background: #ffffff;
        padding: 10px 14px;
        border-bottom: 2px solid #e2e8f0;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .quiz-question-box {
        padding: 16px 14px !important;
        border-radius: 12px;
    }

    .quiz-question-text {
        font-size: 1.05rem !important;
        line-height: 1.5;
        margin-bottom: 16px !important;
    }

    .quiz-option-label {
        display: flex !important;
        align-items: center;
        padding: 14px 16px !important;
        border-radius: 10px !important;
        border: 2px solid #e2e8f0;
        margin-bottom: 10px !important;
        font-size: 0.96rem !important;
        min-height: 52px;
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .quiz-option-label:active {
        background-color: #e0e7ff;
        border-color: #4f46e5;
    }

    .quiz-nav-buttons {
        display: flex;
        flex-direction: column-reverse;
        gap: 10px;
        margin-top: 16px;
    }

    .quiz-nav-buttons button,
    .quiz-nav-buttons a {
        width: 100%;
        padding: 12px !important;
        font-weight: 700;
        border-radius: 10px;
    }

    .quiz-palette-modal .btn-palette {
        width: 38px;
        height: 38px;
        font-size: 0.82rem;
    }
}

/* --------------------------------------------------------
   7. STUDY MATERIALS PORTAL (Mobile)
   -------------------------------------------------------- */
@media (max-width: 767.98px) {
    .study-material-filter-scroll {
        display: flex;
        overflow-x: auto;
        white-space: nowrap;
        gap: 8px;
        padding-bottom: 6px;
        -webkit-overflow-scrolling: touch;
    }

    .study-material-filter-scroll::-webkit-scrollbar {
        display: none;
    }

    .material-card {
        margin-bottom: 14px;
        border-radius: 12px;
        padding: 14px !important;
    }

    .material-card .material-icon {
        width: 44px;
        height: 44px;
        font-size: 1.3rem;
    }

    .material-card .btn-download {
        width: 100%;
        margin-top: 10px;
        padding: 10px !important;
        font-weight: 600;
    }
}

/* --------------------------------------------------------
   8. STUDENT & INSTRUCTOR DASHBOARDS (Mobile)
   -------------------------------------------------------- */
@media (max-width: 767.98px) {
    .dashboard-welcome-banner {
        padding: 18px 14px !important;
        border-radius: 12px;
        margin-bottom: 16px !important;
    }

    .dashboard-welcome-banner h2 {
        font-size: 1.4rem !important;
    }

    /* 4-Feature Quick Cards: 2 Columns on Mobile */
    .row.g-3 > .col-md-3,
    .row.mb-4.g-3 > .col-md-3 {
        width: 50% !important;
        flex: 0 0 50% !important;
        max-width: 50% !important;
    }

    .row.g-3 > .col-md-3 .card-body,
    .row.mb-4.g-3 > .col-md-3 .card-body {
        padding: 12px 10px !important;
        flex-direction: column !important;
        text-align: center;
        gap: 6px;
    }

    .row.g-3 > .col-md-3 .btn-sm.rounded-circle,
    .row.mb-4.g-3 > .col-md-3 .btn-sm.rounded-circle {
        margin-right: 0 !important;
        margin-bottom: 4px;
    }

    .row.g-3 > .col-md-3 .fw-bold.small,
    .row.mb-4.g-3 > .col-md-3 .fw-bold.small {
        font-size: 0.78rem !important;
        line-height: 1.25;
    }

    .row.g-3 > .col-md-3 small,
    .row.mb-4.g-3 > .col-md-3 small {
        font-size: 0.68rem !important;
    }

    /* KPI Stat Cards on Mobile */
    .row.g-4.mb-4 > .col-md-6.col-xl-3,
    .row.g-4 > .col-xl-3.col-md-6 {
        width: 50% !important;
        flex: 0 0 50% !important;
        max-width: 50% !important;
    }

    .row.g-4.mb-4 > .col-md-6.col-xl-3 .card-body,
    .row.g-4 > .col-xl-3.col-md-6 .card-body {
        padding: 14px 12px !important;
    }

    .row.g-4.mb-4 > .col-md-6.col-xl-3 h2,
    .row.g-4 > .col-xl-3.col-md-6 h3 {
        font-size: 1.4rem !important;
    }

    .row.g-4.mb-4 > .col-md-6.col-xl-3 .rounded-circle,
    .row.g-4 > .col-xl-3.col-md-6 .rounded-circle {
        width: 42px !important;
        height: 42px !important;
        font-size: 0.85rem !important;
    }
}

@media (max-width: 480px) {
    /* For very narrow mobile screens, stack cards to 1 column */
    .row.g-3 > .col-md-3,
    .row.mb-4.g-3 > .col-md-3 {
        width: 100% !important;
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    .row.g-3 > .col-md-3 .card-body,
    .row.mb-4.g-3 > .col-md-3 .card-body {
        flex-direction: row !important;
        text-align: left;
        gap: 12px;
    }
}

/* --------------------------------------------------------
   9. AUTH & LOGIN / REGISTER (Mobile)
   -------------------------------------------------------- */
@media (max-width: 767.98px) {
    .auth-container {
        margin: 8px auto !important;
        border-radius: 14px !important;
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08) !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .auth-form-panel {
        padding: 1.5rem 1.15rem !important;
    }

    .auth-form-panel h3 {
        font-size: 1.35rem !important;
    }

    .auth-form-panel p.small {
        font-size: 0.84rem !important;
    }

    #otp_phone {
        font-size: 1.35rem !important;
        letter-spacing: 2px !important;
        padding: 12px !important;
    }

    #otp_code {
        font-size: 1.6rem !important;
        letter-spacing: 6px !important;
        padding: 12px !important;
    }

    #btnSendOtp,
    #btnVerifyLogin {
        padding: 14px !important;
        font-size: 1.05rem !important;
        border-radius: 10px !important;
    }
}

/* --------------------------------------------------------
   10. BATCHES, ATTENDANCE & FEES (Mobile)
   -------------------------------------------------------- */
@media (max-width: 767.98px) {
    .batch-card {
        margin-bottom: 12px;
        border-radius: 12px;
    }

    .attendance-table th,
    .attendance-table td {
        padding: 8px 6px !important;
        font-size: 0.82rem;
    }

    .fee-receipt-card {
        padding: 16px !important;
        margin: 0 !important;
        border-radius: 12px;
    }

    .fee-receipt-header {
        text-align: center;
    }
}

/* --------------------------------------------------------
   11. FOOTER (Mobile)
   -------------------------------------------------------- */
@media (max-width: 767.98px) {
    footer {
        padding: 30px 16px 20px !important;
        text-align: center;
    }

    footer .col-lg-3,
    footer .col-md-6 {
        margin-bottom: 24px;
    }

    footer .social-icons,
    footer .d-flex.gap-3 {
        justify-content: center !important;
    }
}

/* --------------------------------------------------------
   12. ADMIN PANEL FIXES & OFF-CANVAS DRAWER
   -------------------------------------------------------- */
@media (max-width: 991.98px) {
    .admin-sidebar {
        width: 280px !important;
        max-width: 82vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        bottom: 0 !important;
        transform: translateX(-100%) !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        z-index: 1050 !important;
        box-shadow: none !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .admin-sidebar.show {
        transform: translateX(0) !important;
        box-shadow: 0 0 35px rgba(0, 0, 0, 0.55) !important;
    }

    .admin-main-wrapper {
        margin-left: 0 !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }

    .admin-main-wrapper.wrapper-collapsed {
        margin-left: 0 !important;
    }

    .admin-header {
        height: auto !important;
        min-height: 54px !important;
        padding: 8px 12px !important;
    }

    .admin-content {
        padding: 14px 10px !important;
    }
}
