/* Mobile Responsiveness Fixes */

/* ===========================
   1. TABLE HORIZONTAL SCROLLING
   =========================== */

/* Wrapper for tables to enable horizontal scrolling */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 1rem 0;
}

@media (max-width: 640px) {
    .table-responsive {
        box-shadow: inset -10px 0 10px -10px rgba(0, 0, 0, 0.1);
        border-radius: 0.5rem;
    }

    .table-responsive table {
        min-width: 600px;
    }
}

/* ===========================
   2. ADMIN SIDEBAR MOBILE FIX
   =========================== */

@media (max-width: 1024px) {

    /* Ensure drawer is closed by default on mobile */
    .drawer-toggle:not(:checked)~.drawer-side {
        transform: translateX(-100%);
    }

    /* Show hamburger menu on mobile */
    .drawer-toggle~.drawer-content .mobile-menu-btn {
        display: block !important;
    }
}

/* ===========================
   3. QUIZ TIMER MOBILE FIX
   =========================== */

@media (max-width: 640px) {
    .quiz-timer {
        position: sticky !important;
        top: 64px !important;
        z-index: 40 !important;
        width: 100% !important;
        left: 0 !important;
        right: 0 !important;
        padding: 0.5rem 1rem !important;
        font-size: 0.875rem !important;
    }

    /* Ensure timer doesn't overlap content */
    .quiz-content {
        margin-top: 60px !important;
    }
}

/* ===========================
   4. WORD BREAKING
   =========================== */

@media (max-width: 480px) {

    /* Prevent long words from breaking layout */
    .user-email,
    .long-text,
    .breakable {
        word-break: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }

    /* Table cells */
    td,
    th {
        word-break: break-word;
        max-width: 200px;
    }
}

/* ===========================
   5. LARGE SCREEN OPTIMIZATION
   =========================== */

@media (min-width: 1920px) {

    /* Constrain content width on very large screens */
    .container-max {
        max-width: 1600px;
        margin: 0 auto;
    }

    /* Admin content */
    #admin-content {
        max-width: 1400px;
        margin: 0 auto;
    }
}

/* ===========================
   6. TOUCH-FRIENDLY IMPROVEMENTS
   =========================== */

@media (hover: none) and (pointer: coarse) {

    /* Larger touch targets for touch devices */
    .btn,
    button,
    a.btn {
        min-height: 44px !important;
        min-width: 44px !important;
    }

    /* Larger clickable areas */
    .clickable {
        padding: 0.75rem !important;
    }

    /* Remove hover effects on touch devices */
    .btn:hover {
        transform: none !important;
    }
}

/* ===========================
   7. MOBILE NAVIGATION
   =========================== */

@media (max-width: 768px) {

    /* Stack navigation items vertically */
    .mobile-nav {
        flex-direction: column !important;
    }

    /* Full width buttons on mobile */
    .mobile-full-width {
        width: 100% !important;
    }

    /* Hide desktop-only elements */
    .desktop-only {
        display: none !important;
    }

    /* Show mobile-only elements */
    .mobile-only {
        display: block !important;
    }
}

/* ===========================
   8. RESPONSIVE FORMS
   =========================== */

@media (max-width: 640px) {

    /* Stack form groups vertically */
    .form-group {
        width: 100% !important;
        margin-bottom: 1rem !important;
    }

    /* Full width inputs on mobile */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    select,
    textarea {
        width: 100% !important;
    }

    /* Smaller text on mobile forms */
    .form-label {
        font-size: 0.875rem !important;
    }
}

/* ===========================
   9. MOBILE-FRIENDLY CARDS
   =========================== */

@media (max-width: 640px) {
    .card {
        margin: 0.5rem !important;
        padding: 1rem !important;
    }

    /* Reduce card padding on mobile */
    .card-body {
        padding: 1rem !important;
    }
}

/* Smooth scrolling on mobile */
@media (max-width: 768px) {
    html {
        scroll-behavior: smooth;
    }
}