/* ========================================
   Quanta Platform - Mobile Responsive Enhancements
   تحسينات responsive للموبايل
   ======================================== */

/* ========== Base Mobile Styles ========== */
@media (max-width: 768px) {

    /* Global Mobile Fixes */
    * {
        -webkit-tap-highlight-color: transparent;
    }

    html {
        font-size: 14px;
        -webkit-text-size-adjust: 100%;
    }

    body {
        font-size: 14px;
        overflow-x: hidden;
    }

    /* Container Mobile */
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
        max-width: 100%;
    }

    /* ========== Navigation Mobile ========== */
    .navbar {
        height: 60px;
    }

    .navbar-content {
        height: 60px;
        padding: 0 1rem;
    }

    .navbar-brand {
        font-size: 1.25rem !important;
    }

    .navbar-brand img {
        height: 32px !important;
    }

    .navbar-menu {
        display: none !important;
    }

    .navbar-menu.show,
    .navbar-menu.active {
        display: flex !important;
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        bottom: 0;
        flex-direction: column;
        background: white;
        padding: 1rem;
        gap: 0.5rem;
        overflow-y: auto;
        z-index: 9999;
        animation: slideDown 0.3s ease;
    }

    .navbar-menu li {
        width: 100%;
        display: block !important;
    }

    .navbar-menu a {
        width: 100%;
        padding: 1rem !important;
        display: block !important;
        border-radius: 8px;
        background: #f8f9fa;
        color: #1a202c !important;
    }

    .navbar-menu a:hover {
        background: var(--color-primary);
        color: white !important;
    }

    .mobile-menu-toggle {
        display: block !important;
        background: none;
        border: none;
        font-size: 1.75rem;
        cursor: pointer;
        color: #1a202c;
        padding: 0.5rem;
        z-index: 10000;
    }

    /* ========== Typography Mobile ========== */
    h1 {
        font-size: 1.75rem !important;
        line-height: 1.3;
    }

    h2 {
        font-size: 1.5rem !important;
        line-height: 1.3;
    }

    h3 {
        font-size: 1.25rem !important;
    }

    h4 {
        font-size: 1.125rem !important;
    }

    p {
        font-size: 0.875rem;
        line-height: 1.6;
    }

    /* ========== Buttons Mobile ========== */
    .btn {
        padding: 0.875rem 1.5rem !important;
        font-size: 0.9rem !important;
        min-height: 44px;
        width: 100%;
        justify-content: center;
    }

    .btn-group {
        flex-direction: column;
        gap: 0.75rem;
        width: 100%;
    }

    .btn-group .btn {
        width: 100%;
    }

    /* ========== Cards Mobile ========== */
    .card {
        padding: 1.25rem !important;
        margin-bottom: 1rem;
        border-radius: 12px;
    }

    .card-header {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .card-title {
        font-size: 1.125rem !important;
    }

    /* ========== Grids Mobile ========== */
    .grid-2,
    .grid-3,
    .grid-4,
    .courses-grid,
    .teachers-grid,
    .assignments-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }

    /* ========== Hero Section Mobile ========== */
    .hero {
        padding-top: 60px;
        min-height: auto;
    }

    .hero-content {
        grid-template-columns: 1fr !important;
        gap: 2rem;
        text-align: center;
        padding: 2rem 0;
    }

    .hero-text h1 {
        font-size: 1.75rem !important;
    }

    .hero-text p {
        font-size: 1rem !important;
    }

    .hero-image {
        order: -1;
    }

    /* ========== Forms Mobile ========== */
    .form-group {
        margin-bottom: 1.25rem;
    }

    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    input[type="number"],
    textarea,
    select {
        font-size: 16px !important;
        /* Prevents zoom on iOS */
        padding: 0.875rem 1rem !important;
        min-height: 44px;
    }

    textarea {
        min-height: 120px;
    }

    /* ========== Tables Mobile ========== */
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    thead {
        display: none;
    }

    tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        padding: 1rem;
        background: white;
    }

    td {
        display: block;
        text-align: right;
        padding: 0.5rem 0;
        border-bottom: 1px solid #f3f4f6;
    }

    td:last-child {
        border-bottom: none;
    }

    td:before {
        content: attr(data-label);
        font-weight: 600;
        display: inline-block;
        margin-left: 0.5rem;
    }

    /* ========== Stats Mobile ========== */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem;
    }

    .stat-item {
        padding: 1rem !important;
        text-align: center;
    }

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

    .stat-label {
        font-size: 0.75rem !important;
    }

    /* ========== Footer Mobile ========== */
    .footer {
        padding: 2rem 0 1rem;
    }

    .footer-content {
        grid-template-columns: 1fr !important;
        gap: 2rem;
        text-align: center;
    }

    .footer-brand {
        grid-column: span 1;
    }

    .footer-links ul {
        padding: 0;
    }

    /* ========== Messages Mobile ========== */
    .alert {
        max-width: 90vw !important;
        right: 5vw !important;
        top: 70px !important;
        font-size: 0.875rem;
    }

    /* ========== Video Player Mobile ========== */
    .video-container,
    .video-wrapper,
    iframe[src*="youtube"],
    iframe[src*="vimeo"],
    iframe[src*="bunny"],
    video {
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 16/9;
        max-width: 100%;
    }

    /* ========== Course Detail Mobile ========== */
    .course-detail-header {
        flex-direction: column;
        text-align: center;
    }

    .course-image img {
        width: 100%;
        height: auto;
    }

    .course-sidebar {
        position: static;
        width: 100%;
        margin-top: 1rem;
    }

    .course-content {
        padding: 1rem;
    }

    /* ========== Dashboard Mobile ========== */
    .dashboard-grid {
        grid-template-columns: 1fr !important;
    }

    .dashboard-card {
        margin-bottom: 1rem;
    }

    /* ========== Assignment/Quiz Mobile ========== */
    .question-card {
        padding: 1rem !important;
        margin-bottom: 1rem;
    }

    .choice-option {
        padding: 0.875rem !important;
        font-size: 0.9rem;
    }

    .timer-display {
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        z-index: 999;
        padding: 0.75rem;
        background: white;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }

    /* ========== Profile Mobile ========== */
    .profile-header {
        flex-direction: column;
        text-align: center;
    }

    .profile-avatar {
        margin: 0 auto 1rem;
    }

    .profile-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }

    /* ========== Modal Mobile ========== */
    .modal {
        padding: 1rem;
    }

    .modal-content {
        width: 100%;
        max-width: 100%;
        margin: 0;
        border-radius: 12px;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem;
    }

    /* ========== Section Spacing Mobile ========== */
    .section {
        padding: 2rem 0;
    }

    .section-header {
        margin-bottom: 1.5rem;
        text-align: center;
    }

    /* ========== Touch-friendly improvements ========== */
    a,
    button,
    .btn,
    .clickable {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Prevent text selection on buttons */
    button,
    .btn {
        -webkit-user-select: none;
        user-select: none;
    }

    /* ========== Animations Mobile ========== */
    @keyframes slideDown {
        from {
            opacity: 0;
            transform: translateY(-20px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    @keyframes fadeIn {
        from {
            opacity: 0;
        }

        to {
            opacity: 1;
        }
    }

    /* ========== Utility Classes Mobile ========== */
    .mobile-hidden {
        display: none !important;
    }

    .mobile-visible {
        display: block !important;
    }

    .mobile-flex {
        display: flex !important;
    }

    .mobile-stack {
        flex-direction: column !important;
    }

    .mobile-center {
        text-align: center !important;
    }

    .mobile-full-width {
        width: 100% !important;
    }
}

/* ========== Tablet (641px - 768px) ========== */
@media (min-width: 641px) and (max-width: 768px) {
    .container {
        padding: 0 1.5rem;
    }

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

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

    h1 {
        font-size: 2rem !important;
    }

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

/* ========== Small Desktop (769px - 1024px) ========== */
@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        max-width: 720px;
    }

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

    .grid-4 {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

/* ========== Desktop (> 1024px) ========== */
@media (min-width: 1025px) {
    .mobile-menu-toggle {
        display: none !important;
    }

    .navbar-menu {
        display: flex !important;
    }
}

/* ========== Landscape Mobile ========== */
@media (max-width: 768px) and (orientation: landscape) {
    .hero {
        min-height: auto;
        padding: 3rem 0;
    }

    .navbar-menu.show,
    .navbar-menu.active {
        max-height: calc(100vh - 60px);
        overflow-y: auto;
    }
}

/* ========== High DPI Screens ========== */
@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {
    img {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* ========== Print Styles ========== */
@media print {

    .navbar,
    .footer,
    .mobile-menu-toggle,
    .btn,
    button {
        display: none !important;
    }

    .container {
        max-width: 100%;
    }

    * {
        background: white !important;
        color: black !important;
    }
}