/*
 * Flux PR Lab - Responsive Enhancements
 * Additional mobile and tablet optimizations
 */

/* ===== RESPONSIVE UTILITIES ===== */

/* Prevent horizontal overflow */
html,
body {
    overflow-x: hidden;
    max-width: 100vw;
}

/* ===== MOBILE TAP TARGETS (44px minimum) ===== */
@media (max-width: 768px) {

    /* Buttons and Interactive Elements */
    .btn {
        min-height: 44px;
        padding: var(--space-3) var(--space-5);
    }

    .btn-sm {
        min-height: 40px;
        padding: var(--space-2) var(--space-4);
    }

    .btn-icon {
        min-width: 44px;
        min-height: 44px;
    }

    /* Form inputs */
    .form-input,
    .form-select,
    .form-textarea {
        min-height: 48px;
        font-size: 16px;
        /* Prevents iOS zoom on focus */
    }

    /* Accordion triggers larger for easier tapping */
    .accordion-trigger {
        min-height: 56px;
        padding: var(--space-4) var(--space-5);
    }

    .accordion-icon {
        width: 24px;
        height: 24px;
    }

    /* Nav links */
    .mobile-nav-link {
        min-height: 48px;
        display: flex;
        align-items: center;
    }

    /* Checkboxes and radio buttons */
    .form-checkbox {
        width: 24px;
        height: 24px;
        min-width: 24px;
    }
}

/* ===== HERO SECTION MOBILE ===== */
@media (max-width: 640px) {
    .hero-ctas {
        flex-direction: column;
        width: 100%;
    }

    .hero-ctas .btn {
        width: 100%;
        justify-content: center;
    }
}

/* ===== CARDS RESPONSIVE ===== */
@media (max-width: 640px) {
    .card {
        padding: var(--space-4);
    }

    .card-icon {
        width: 48px;
        height: 48px;
    }

    .card-icon svg {
        width: 24px;
        height: 24px;
    }

    /* Stack card grids */
    .grid.md\:grid-cols-2,
    .grid.md\:grid-cols-3,
    .grid.md\:grid-cols-4 {
        grid-template-columns: 1fr !important;
    }
}

@media (min-width: 641px) and (max-width: 1023px) {

    /* Tablet: 2-column max */
    .grid.lg\:grid-cols-3,
    .grid.lg\:grid-cols-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ===== ADMIN TABLE TO CARDS ON MOBILE ===== */
@media (max-width: 768px) {

    /* Hide table header on mobile */
    .admin-table thead {
        display: none;
    }

    .admin-table,
    .admin-table tbody,
    .admin-table tr,
    .admin-table td {
        display: block;
        width: 100%;
    }

    .admin-table tr {
        background: var(--color-bg-tertiary);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-lg);
        padding: var(--space-4);
        margin-bottom: var(--space-3);
    }

    .admin-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: var(--space-2) 0;
        border: none;
        border-bottom: 1px solid var(--color-border);
    }

    .admin-table td:last-child {
        border-bottom: none;
    }

    .admin-table td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: var(--text-sm);
        color: var(--color-text-muted);
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }

    /* Actions row - horizontal on mobile */
    .admin-table td.actions-cell {
        justify-content: flex-start;
        gap: var(--space-2);
        flex-wrap: wrap;
    }

    .admin-table td.actions-cell::before {
        display: none;
    }
}

/* ===== ADMIN SIDEBAR RESPONSIVE ===== */
@media (max-width: 1023px) {
    .admin-layout {
        flex-direction: column;
    }

    .admin-sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 280px;
        height: 100vh;
        z-index: var(--z-modal);
        transition: left var(--transition-base);
        background: var(--color-bg-secondary);
        border-right: 1px solid var(--color-border);
    }

    .admin-sidebar.open {
        left: 0;
    }

    .admin-sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: calc(var(--z-modal) - 1);
        opacity: 0;
        visibility: hidden;
        transition: all var(--transition-base);
    }

    .admin-sidebar-overlay.open {
        opacity: 1;
        visibility: visible;
    }

    .admin-content {
        margin-left: 0;
        width: 100%;
    }

    /* Mobile header for admin */
    .admin-mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: var(--space-4);
        background: var(--color-bg-secondary);
        border-bottom: 1px solid var(--color-border);
    }

    .admin-menu-toggle {
        display: flex;
        width: 44px;
        height: 44px;
    }
}

@media (min-width: 1024px) {
    .admin-mobile-header {
        display: none;
    }

    .admin-menu-toggle {
        display: none;
    }

    .admin-sidebar-overlay {
        display: none;
    }
}

/* ===== BUILDER LAYOUT RESPONSIVE ===== */
@media (max-width: 1023px) {
    .builder-layout {
        flex-direction: column;
    }

    .builder-hierarchy {
        position: fixed;
        top: 0;
        left: -100%;
        width: 300px;
        height: 100vh;
        z-index: var(--z-modal);
        transition: left var(--transition-base);
        background: var(--color-bg-secondary);
        overflow-y: auto;
    }

    .builder-hierarchy.open {
        left: 0;
    }

    .builder-editor {
        width: 100%;
        margin-left: 0;
    }

    .builder-toggle {
        display: flex;
        position: fixed;
        bottom: var(--space-4);
        left: var(--space-4);
        z-index: calc(var(--z-modal) - 1);
    }
}

@media (min-width: 1024px) {
    .builder-toggle {
        display: none;
    }
}

/* ===== INTERNSHIPS PAGE RESPONSIVE ===== */
@media (max-width: 768px) {

    /* Program overview cards - scrollable row */
    .program-overview-grid {
        display: flex;
        overflow-x: auto;
        gap: var(--space-4);
        padding-bottom: var(--space-4);
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
    }

    .program-overview-grid>* {
        flex: 0 0 280px;
        scroll-snap-align: start;
    }

    /* Week-by-week learning - single column */
    .curriculum-grid {
        grid-template-columns: 1fr !important;
    }

    /* What interns build - single column */
    .intern-builds-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ===== PORTAL RESPONSIVE ===== */
@media (max-width: 768px) {

    /* Track cards full width */
    .track-card {
        width: 100%;
    }

    /* Curriculum modules collapsible */
    .curriculum-modules {
        display: flex;
        flex-direction: column;
        gap: var(--space-3);
    }

    .curriculum-module {
        border: 1px solid var(--color-border);
        border-radius: var(--radius-lg);
        overflow: hidden;
    }

    .module-header {
        padding: var(--space-4);
        cursor: pointer;
    }

    .module-lessons {
        padding: 0 var(--space-4) var(--space-4);
    }

    /* Lesson content responsive images */
    .lesson-content img,
    .lesson-content video,
    .lesson-content iframe {
        max-width: 100%;
        height: auto;
    }
}

/* ===== NEWSLETTER FORM RESPONSIVE ===== */
@media (max-width: 640px) {
    .footer-newsletter .flex.gap-4 {
        flex-direction: column;
    }

    .footer-newsletter .form-input {
        width: 100%;
    }

    .footer-newsletter .btn {
        width: 100%;
    }
}

/* ===== MODAL RESPONSIVE ===== */
@media (max-width: 640px) {
    .modal {
        width: calc(100% - var(--space-4));
        max-height: calc(100vh - var(--space-8));
        border-radius: var(--radius-xl);
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: var(--space-4);
    }

    .modal-footer {
        flex-direction: column;
    }

    .modal-footer .btn {
        width: 100%;
    }
}

/* ===== TABS SCROLLABLE ON MOBILE ===== */
@media (max-width: 640px) {

    .tabs,
    .blog-filters {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .tabs::-webkit-scrollbar,
    .blog-filters::-webkit-scrollbar {
        display: none;
    }

    .tab-button {
        flex-shrink: 0;
    }
}

/* ===== BACK TO TOP MOBILE POSITION ===== */
@media (max-width: 768px) {
    .back-to-top {
        bottom: calc(var(--space-20) + var(--space-4));
        right: var(--space-4);
    }
}

/* ===== TOAST CONTAINER MOBILE ===== */
@media (max-width: 640px) {
    .toast-container {
        left: var(--space-4) !important;
        right: var(--space-4) !important;
        bottom: calc(var(--space-20) + var(--space-4)) !important;
    }

    .toast {
        width: 100%;
    }
}

/* ===== SECTION SPACING MOBILE ===== */
@media (max-width: 640px) {
    .section {
        padding-block: var(--space-10);
    }

    .section-lg {
        padding-block: var(--space-12);
    }

    .section-header {
        margin-bottom: var(--space-8);
    }
}

/* ===== PREFERS REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {

    .reveal,
    .reveal-stagger>* {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .card:hover,
    .btn:hover {
        transform: none;
    }

    .mobile-menu {
        transition: none;
    }

    .admin-sidebar,
    .builder-hierarchy {
        transition: none;
    }
}

/* ===== PRINT STYLES ===== */
@media print {

    .header,
    .footer,
    .mobile-cta-bar,
    .back-to-top,
    .toast-container {
        display: none !important;
    }

    .main {
        padding-top: 0;
    }

    body {
        background: white;
        color: black;
    }
}