/* Mobile Responsiveness Fixes for Trader's Room FX */

/* ====== BASE MOBILE STYLES ====== */

/* Ensure proper viewport and touch handling */
html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    touch-action: manipulation;
}

/* Base mobile settings */
body {
    overflow-x: hidden;
    min-height: 100vh;
}

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

/* Mobile navigation toggle */
.mobile-nav-toggle {
    display: none;
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    z-index: 1000;
}

.mobile-nav-toggle span {
    display: block;
    width: 25px;
    height: 3px;
    background: var(--text-heading);
    margin: 5px 0;
    transition: 0.3s;
}

/* Main navigation mobile styles */
@media (max-width: 768px) {
    .mobile-nav-toggle {
        display: block;
    }
    
    .main-nav {
        position: fixed;
        top: 0;
        right: -100%;
        width: 280px;
        height: 100vh;
        background: var(--bg-panel);
        box-shadow: -2px 0 10px rgba(0,0,0,0.1);
        transition: right 0.3s ease;
        z-index: 999;
        overflow-y: auto;
    }
    
    .main-nav.active {
        right: 0;
    }
    
    .main-nav ul {
        flex-direction: column;
        padding: 60px 20px 20px;
    }
    
    .main-nav li {
        margin: 0;
        width: 100%;
    }
    
    .main-nav a {
        display: block;
        padding: 15px;
        border-bottom: 1px solid var(--border-light);
    }
}

/* ====== HERO SECTION ====== */

@media (max-width: 768px) {
    .hero-panel {
        padding: 1.5rem !important;
        margin: 0 0.5rem;
    }
    
    .hero-panel h1 {
        font-size: 1.75rem !important;
        line-height: 1.2;
    }
    
    .hero-panel p {
        font-size: 0.95rem !important;
    }
    
    .hero-tags {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .hero-tag {
        font-size: 0.75rem;
        padding: 4px 10px;
    }
}

/* ====== CARDS & PANELS ====== */

/* Mobile card adjustments */
@media (max-width: 640px) {
    .academy-card {
        margin: 0 0.5rem;
        padding: 1rem !important;
    }
    
    .academy-panel {
        padding: 0.75rem !important;
    }
}

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

/* Make all tables responsive */
@media (max-width: 768px) {
    .responsive-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    thead, tbody, th, td, tr {
        display: block;
    }
    
    thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    
    tr {
        border: 1px solid var(--border-light);
        margin-bottom: 1rem;
        padding: 0.5rem;
    }
    
    td {
        border: none;
        border-bottom: 1px solid var(--border-light);
        position: relative;
        padding-left: 50% !important;
        white-space: normal;
    }
    
    td:before {
        position: absolute;
        top: 6px;
        left: 6px;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        font-weight: bold;
        content: attr(data-label);
    }
}

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

/* Mobile grid fixes */
@media (max-width: 640px) {
    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    .lg\\:grid-cols-2,
    .lg\\:grid-cols-3,
    .lg\\:grid-cols-4 {
        grid-template-columns: 1fr !important;
    }
}

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

/* Mobile form styles */
@media (max-width: 640px) {
    .form-control {
        font-size: 16px !important; /* Prevents zoom on iOS */
    }
    
    .form-group {
        margin-bottom: 1rem;
    }
    
    .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .btn-group {
        flex-direction: column;
    }
}

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

/* Mobile button fixes */
@media (max-width: 640px) {
    .btn-cta,
    .btn-secondary {
        min-height: 44px; /* iOS touch target */
        font-size: 16px;
        padding: 12px 20px;
    }
    
    .btn-sm {
        min-height: 40px;
        font-size: 14px;
        padding: 10px 16px;
    }
}

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

/* Mobile modal styles */
@media (max-width: 640px) {
    .modal {
        margin: 0;
        width: 100%;
        max-width: 100%;
        height: 100vh;
        border-radius: 0;
    }
    
    .modal-content {
        height: 100vh;
        overflow-y: auto;
    }
}

/* ====== IMAGES ====== */

/* Responsive images */
img {
    max-width: 100%;
    height: auto;
}

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

/* Mobile spacing adjustments */
@media (max-width: 640px) {
    .space-y-12 > * + * {
        margin-top: 2rem !important;
    }
    
    .space-y-6 > * + * {
        margin-top: 1rem !important;
    }
    
    .gap-6 {
        gap: 1rem !important;
    }
    
    .gap-4 {
        gap: 0.75rem !important;
    }
    
    .p-6 {
        padding: 1rem !important;
    }
    
    .px-6 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    .py-4 {
        padding-top: 0.75rem !important;
        padding-bottom: 0.75rem !important;
    }
}

/* ====== TYPOGRAPHY ====== */

/* Mobile text sizes */
@media (max-width: 640px) {
    h1 {
        font-size: 1.75rem !important;
        line-height: 1.2;
    }
    
    h2 {
        font-size: 1.5rem !important;
        line-height: 1.3;
    }
    
    h3 {
        font-size: 1.25rem !important;
        line-height: 1.4;
    }
    
    .text-2xl {
        font-size: 1.5rem !important;
    }
    
    .text-xl {
        font-size: 1.25rem !important;
    }
    
    .text-lg {
        font-size: 1.125rem !important;
    }
}

/* ====== DASHBOARD ====== */

/* Mobile dashboard fixes */
@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr !important;
    }
    
    .stat-card {
        margin-bottom: 1rem;
    }
    
    .sidebar {
        position: fixed;
        left: -100%;
        width: 280px;
        height: 100vh;
        background: var(--bg-panel);
        transition: left 0.3s ease;
        z-index: 999;
    }
    
    .sidebar.active {
        left: 0;
    }
    
    .main-content {
        margin-left: 0 !important;
    }
}

/* ====== TASKS/QUESTS ====== */

/* Mobile task view */
@media (max-width: 640px) {
    .task-card {
        padding: 1rem !important;
    }
    
    .task-meta {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .task-actions {
        flex-direction: column;
        margin-top: 1rem;
    }
    
    .task-actions button {
        width: 100%;
    }
}

/* ====== COURSES ====== */

/* Mobile course cards */
@media (max-width: 640px) {
    .course-card {
        margin-bottom: 1rem;
    }
    
    .course-card img {
        height: 200px;
        object-fit: cover;
    }
    
    .course-price {
        position: static;
        margin-top: 1rem;
    }
}

/* ====== PAYMENT ====== */

/* Mobile payment form */
@media (max-width: 640px) {
    .payment-form {
        padding: 1rem !important;
    }
    
    .payment-methods {
        grid-template-columns: 1fr !important;
    }
    
    .payment-summary {
        margin-top: 2rem;
    }
}

/* ====== LOADING STATES ====== */

/* Mobile loading spinner */
@media (max-width: 640px) {
    .loading-spinner {
        width: 40px;
        height: 40px;
    }
}

/* ====== ACCESSIBILITY ====== */

/* Focus states for mobile */
@media (hover: none) and (pointer: coarse) {
    .btn:active,
    .btn:focus {
        transform: scale(0.98);
    }
    
    .card:active {
        transform: scale(0.99);
    }
}

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

@media print {
    .no-print {
        display: none !important;
    }
    
    .academy-card {
        box-shadow: none !important;
        border: 1px solid #000 !important;
    }
}
