/* ========================================
   COMPREHENSIVE MOBILE RESPONSIVE STYLES
   Professional Mobile-First Design
   ======================================== */

/* ========================================
   MOBILE BREAKPOINTS
   ======================================== */
/* 
   - Mobile: < 768px
   - Tablet: 768px - 1024px
   - Desktop: > 1024px
*/

/* ========================================
   GLOBAL MOBILE FIXES
   ======================================== */
@media (max-width: 768px) {
    body {
        font-size: 14px;
        overflow-x: hidden;
    }

    .container {
        padding: 0 1rem;
    }

    /* Prevent horizontal scroll */
    * {
        max-width: 100%;
    }
}

/* ========================================
   LANDING PAGE - MOBILE
   ======================================== */
@media (max-width: 768px) {

    /* Hero Section */
    .hero-header {
        min-height: auto;
        padding-bottom: 2rem;
    }

    .navbar {
        padding: 1rem 0;
    }

    .navbar .container {
        flex-wrap: wrap;
        gap: 1rem;
    }

    .nav-brand {
        font-size: 1.25rem;
    }

    .nav-brand i {
        font-size: 1.5rem;
    }

    .nav-actions {
        width: 100%;
        justify-content: center;
        gap: 0.5rem;
    }

    .hero-content {
        padding: 2rem 0;
    }

    .hero-title {
        font-size: 2rem !important;
        line-height: 1.2;
        margin-bottom: 1rem;
    }

    .hero-subtitle {
        font-size: 1rem !important;
        margin-bottom: 1.5rem;
    }

    .hero-buttons {
        flex-direction: column !important;
        gap: 0.75rem;
        width: 100%;
    }

    .hero-buttons .btn {
        width: 100%;
        justify-content: center;
    }

    .hero-stats {
        flex-direction: column !important;
        gap: 1.5rem !important;
        margin-top: 2rem;
    }

    .stat {
        width: 100%;
    }

    .stat-number {
        font-size: 2rem;
    }

    /* Features Section */
    .features-section {
        padding: 2.5rem 0;
    }

    .section-title {
        font-size: 1.75rem !important;
        margin-bottom: 1.5rem;
    }

    .features-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }

    .feature-card {
        padding: 1.5rem;
    }

    .feature-icon {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }

    .feature-card h3 {
        font-size: 1.1rem;
    }

    /* Pricing Section */
    .pricing-section {
        padding: 2rem 0;
    }

    .pricing-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
        max-width: 100%;
    }

    .price-card {
        padding: 1.5rem;
    }

    .plan-name {
        font-size: 1.1rem;
    }

    .plan-price {
        font-size: 1.75rem;
    }

    .plan-features li {
        font-size: 0.875rem;
        padding: 0.4rem 0;
    }

    /* Footer */
    .footer {
        padding: 1.5rem 0;
        font-size: 0.875rem;
    }
}

/* ========================================
   AUTH PAGES - MOBILE
   ======================================== */
@media (max-width: 768px) {
    .auth-page {
        padding: 1rem;
        min-height: 100vh;
        display: flex !important;
        align-items: center;
    }

    .auth-container {
        width: 100%;
        max-width: 100%;
    }

    .auth-box {
        padding: 1.5rem;
        border-radius: 1rem;
    }

    .auth-header h2 {
        font-size: 1.5rem;
    }

    .auth-header p {
        font-size: 0.875rem;
    }

    .auth-form {
        gap: 0.75rem;
    }

    .form-group label {
        font-size: 0.8rem;
    }

    .form-control {
        padding: 0.75rem;
        font-size: 0.95rem;
    }

    .btn {
        padding: 0.75rem 1.25rem;
        font-size: 0.95rem;
    }

    .btn-large {
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
    }

    .social-login {
        flex-direction: column;
        gap: 0.5rem;
    }

    .btn-social {
        width: 100%;
    }

    .auth-footer {
        font-size: 0.875rem;
        margin-top: 1rem;
    }
}

/* ========================================
   DASHBOARD - MOBILE
   ======================================== */
@media (max-width: 768px) {

    /* Dashboard Layout */
    .dashboard-page {
        grid-template-columns: 1fr !important;
    }

    /* Mobile Menu Button */
    .mobile-menu-btn {
        display: flex !important;
        position: fixed;
        top: 15px;
        left: 15px;
        z-index: 9999;
        background: white;
        border-radius: 50%;
        width: 50px;
        height: 50px;
        box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
        border: 2px solid var(--primary);
        color: var(--primary);
        font-size: 1.25rem;
        cursor: pointer;
        align-items: center;
        justify-content: center;
        transition: transform 0.2s;
    }

    .mobile-menu-btn:active {
        transform: scale(0.95);
    }

    /* Sidebar */
    .sidebar {
        position: fixed !important;
        left: -100%;
        top: 0;
        width: 280px;
        height: 100vh;
        z-index: 10000;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
    }

    .sidebar.active {
        left: 0;
    }

    .sidebar-brand {
        padding: 1.25rem;
        font-size: 1.25rem;
    }

    .sidebar-nav {
        padding: 0.75rem;
    }

    .nav-item {
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
    }

    .nav-item i {
        font-size: 1.1rem;
    }

    /* Sidebar Overlay */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(2px);
        z-index: 9998;
    }

    .sidebar-overlay.active {
        display: block;
    }

    /* Dashboard Header */
    .dashboard-header {
        padding: 1rem 1rem 1rem 75px !important;
        min-height: auto !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.75rem;
        position: sticky;
        top: 0;
        z-index: 100;
    }

    .header-left {
        width: 100%;
    }

    .header-title-group {
        width: 100%;
    }

    .header-title-group h1 {
        font-size: 1.25rem !important;
        margin-bottom: 0.5rem;
    }

    .status-badges {
        flex-wrap: wrap;
        gap: 0.4rem;
    }

    .status-app-badge {
        font-size: 0.65rem;
        padding: 4px 8px;
    }

    .header-right {
        position: static;
        width: 100%;
        justify-content: space-between;
    }

    .user-info {
        border-left: none;
        padding-left: 0;
    }

    .user-text {
        display: none !important;
    }

    .avatar {
        width: 38px;
        height: 38px;
        font-size: 1rem;
    }

    /* Exam Switcher */
    .exam-switcher {
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
    }

    .exam-switcher label {
        font-size: 0.75rem;
    }

    .exam-switcher select {
        font-size: 0.8rem;
    }

    /* Dashboard Content */
    .dashboard-content {
        padding: 1rem;
    }

    /* Welcome Card */
    .welcome-card {
        padding: 1.25rem;
        margin-bottom: 1rem;
        border-radius: 0.75rem;
    }

    .welcome-card h2 {
        font-size: 1.25rem;
        margin-bottom: 0.5rem;
    }

    .welcome-card p {
        font-size: 0.95rem;
    }

    /* Stats Grid */
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem;
        margin-bottom: 1rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-card .stat-icon {
        width: 42px;
        height: 42px;
        font-size: 1.1rem;
    }

    .stat-card .stat-value {
        font-size: 1.35rem;
    }

    .stat-card .stat-label {
        font-size: 0.8rem;
    }

    /* Action Cards */
    .action-cards {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }

    .action-card {
        padding: 1.25rem;
    }

    .action-card i {
        font-size: 2.5rem;
    }

    .action-card h3 {
        font-size: 1.1rem;
    }

    .action-card p {
        font-size: 0.875rem;
    }
}

/* ========================================
   QUESTION INTERFACE - MOBILE
   ======================================== */
@media (max-width: 768px) {
    .test-header {
        flex-direction: column;
        padding: 1rem;
        margin-bottom: 0.75rem;
        gap: 0.75rem;
        text-align: center;
    }

    .test-header h2 {
        font-size: 1.25rem;
    }

    .test-info {
        flex-direction: column;
        gap: 0.5rem;
        font-size: 0.875rem;
    }

    .question-container {
        padding: 1.25rem;
        margin-bottom: 0;
    }

    .question-text {
        font-size: 1rem;
        margin-bottom: 1rem;
    }

    .options-container {
        gap: 0.6rem;
        margin-bottom: 1.25rem;
    }

    .option {
        padding: 0.75rem 1rem;
        border-radius: 10px;
    }

    .option input[type="radio"] {
        width: 18px;
        height: 18px;
    }

    .option label {
        font-size: 0.95rem;
    }

    .navigation-buttons {
        gap: 0.5rem;
        flex-wrap: wrap;
    }

    .navigation-buttons .btn {
        flex: 1 1 45%;
        min-width: 120px;
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }

    .question-grid {
        padding: 1rem;
        margin-top: 0;
    }

    .question-grid h4 {
        font-size: 0.875rem;
        margin-bottom: 0.6rem;
    }

    .grid {
        gap: 0.4rem;
    }

    .grid-item {
        width: 34px;
        height: 34px;
        font-size: 0.8rem;
    }
}

/* ========================================
   SUBSCRIPTION PAGE - MOBILE
   ======================================== */
@media (max-width: 768px) {
    .subscription-hero {
        padding: 1.25rem !important;
        margin-bottom: 1rem;
    }

    .subscription-hero h2 {
        font-size: 1.35rem;
    }

    .trial-banner {
        font-size: 0.8rem;
        padding: 6px 15px;
    }

    /* Subscription Plans */
    #subscriptionSection .pricing-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ========================================
   PHYSICAL GUIDANCE - MOBILE
   ======================================== */
@media (max-width: 768px) {
    .phy-form-container {
        padding: 1.25rem;
        margin-bottom: 1rem;
    }

    .phy-form .form-row {
        grid-template-columns: 1fr !important;
        gap: 0.75rem;
        margin-bottom: 0.75rem;
    }

    .physical-status-card {
        flex-direction: column;
        padding: 1.25rem;
        text-align: center;
        margin-bottom: 1rem;
    }

    .physical-status-card .status-icon {
        font-size: 2.5rem;
        width: 70px;
        height: 70px;
    }

    .phy-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
        margin-bottom: 1rem;
    }

    .phy-card-header {
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
    }

    .phy-card-body {
        padding: 1rem;
        font-size: 0.9rem;
    }
}

/* ========================================
   ANALYTICS PAGE - MOBILE
   ======================================== */
@media (max-width: 768px) {
    #analyticsContainer {
        padding: 0;
    }

    .analytics-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }

    .analytics-card {
        padding: 1.25rem;
    }

    .analytics-card h3 {
        font-size: 1.1rem;
    }

    /* Charts */
    canvas {
        max-height: 250px !important;
    }
}

/* ========================================
   AI CHAT WIDGET - MOBILE
   ======================================== */
@media (max-width: 768px) {
    .chat-widget {
        bottom: 70px !important;
        right: 15px !important;
        width: 55px !important;
        height: 55px !important;
    }

    .chat-widget i {
        font-size: 1.5rem;
    }

    .chat-container {
        position: fixed !important;
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        top: auto !important;
        width: 100% !important;
        height: 80vh !important;
        border-radius: 1rem 1rem 0 0 !important;
        max-height: 80vh;
    }

    .chat-messages {
        padding: 1rem;
        gap: 0.75rem;
    }

    .chat-message {
        max-width: 90%;
        font-size: 0.9rem;
    }

    .message-avatar {
        width: 35px;
        height: 35px;
    }

    .message-content {
        padding: 0.75rem;
    }

    .chat-input-container {
        padding: 0.75rem;
    }

    .chat-input {
        padding: 0.75rem;
        font-size: 0.95rem;
    }
}

/* ========================================
   MODALS - MOBILE
   ======================================== */
@media (max-width: 768px) {
    .modal-content {
        width: 95% !important;
        max-width: 95% !important;
        margin: 1rem auto;
        padding: 1.25rem;
    }

    .modal-header h3 {
        font-size: 1.25rem;
    }

    .modal-body {
        padding: 1rem 0;
    }

    .modal-footer {
        flex-direction: column;
        gap: 0.5rem;
    }

    .modal-footer .btn {
        width: 100%;
    }
}

/* ========================================
   NOTIFICATIONS - MOBILE
   ======================================== */
@media (max-width: 768px) {
    .notification {
        top: 10px !important;
        right: 10px !important;
        left: 10px !important;
        width: auto !important;
        padding: 0.875rem 1rem !important;
        font-size: 0.875rem !important;
    }
}

/* ========================================
   TABLES - MOBILE
   ======================================== */
@media (max-width: 768px) {
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        font-size: 0.85rem;
    }

    th,
    td {
        padding: 0.5rem !important;
    }
}

/* ========================================
   FORMS - MOBILE
   ======================================== */
@media (max-width: 768px) {

    select,
    input,
    textarea {
        font-size: 16px !important;
        /* Prevents zoom on iOS */
    }

    .form-row {
        grid-template-columns: 1fr !important;
    }
}

/* ========================================
   UTILITY CLASSES - MOBILE
   ======================================== */
@media (max-width: 768px) {
    .mobile-hidden {
        display: none !important;
    }

    .mobile-only {
        display: block !important;
    }

    .mobile-text-center {
        text-align: center !important;
    }

    .mobile-full-width {
        width: 100% !important;
    }
}

/* ========================================
   TABLET OPTIMIZATIONS (768px - 1024px)
   ======================================== */
@media (min-width: 768px) and (max-width: 1024px) {
    .container {
        padding: 0 2rem;
    }

    .hero-title {
        font-size: 2.75rem;
    }

    .features-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .pricing-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .dashboard-header {
        padding: 1.25rem 1.5rem;
    }
}

/* ========================================
   LANDSCAPE MOBILE FIXES
   ======================================== */
@media (max-width: 768px) and (orientation: landscape) {
    .hero-header {
        min-height: auto;
    }

    .auth-page {
        min-height: auto;
        padding: 1rem 0;
    }

    .dashboard-header {
        position: relative;
    }

    .chat-container {
        height: 90vh !important;
    }
}

/* ========================================
   TOUCH OPTIMIZATIONS
   ======================================== */
@media (hover: none) and (pointer: coarse) {

    /* Larger touch targets */
    .btn,
    .nav-item,
    .option,
    .grid-item {
        min-height: 44px;
        min-width: 44px;
    }

    /* Remove hover effects on touch devices */
    .btn:hover,
    .nav-item:hover,
    .feature-card:hover,
    .action-card:hover {
        transform: none;
    }

    /* Active states instead */
    .btn:active {
        transform: scale(0.98);
    }
}

/* ========================================
   SAFE AREA INSETS (iPhone X+)
   ======================================== */
@supports (padding: max(0px)) {

    .dashboard-header,
    .navbar,
    .footer {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }

    .mobile-menu-btn {
        left: max(15px, env(safe-area-inset-left));
    }

    .chat-widget {
        right: max(15px, env(safe-area-inset-right));
        bottom: max(70px, env(safe-area-inset-bottom));
    }
}