/**
 * Responsive Design Utilities for Phase 2 Auto-Selection Engine
 * Breakpoints: Mobile (<768px), Tablet (768px-1024px), Desktop (>1024px)
 */

:root {
    --breakpoint-mobile: 768px;
    --breakpoint-tablet: 1024px;
}

/* ============================================
   RESPONSIVE GRID SYSTEM
   ============================================ */

.responsive-grid {
    display: grid;
    gap: calc(var(--spacing-unit) * 2);
}

/* Desktop: 3 columns */
@media (min-width: 1024px) {
    .responsive-grid-3 {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .responsive-grid-2 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Tablet: 2 columns */
@media (min-width: 768px) and (max-width: 1023px) {
    .responsive-grid-3,
    .responsive-grid-2 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile: 1 column */
@media (max-width: 767px) {
    .responsive-grid-3,
    .responsive-grid-2 {
        grid-template-columns: 1fr;
    }
}

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

.responsive-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 767px) {
    .responsive-table {
        display: block;
        width: 100%;
    }
    
    .responsive-table thead {
        display: none;
    }
    
    .responsive-table tbody,
    .responsive-table tr,
    .responsive-table td {
        display: block;
        width: 100%;
    }
    
    .responsive-table tr {
        margin-bottom: calc(var(--spacing-unit) * 2);
        border: 1px solid var(--neutral-200);
        border-radius: 8px;
        padding: calc(var(--spacing-unit) * 2);
        background: white;
    }
    
    .responsive-table td {
        text-align: left !important;
        padding: calc(var(--spacing-unit)) 0 !important;
        border: none !important;
        position: relative;
        padding-left: 50% !important;
    }
    
    .responsive-table td:before {
        content: attr(data-label);
        position: absolute;
        left: 0;
        width: 45%;
        padding-right: calc(var(--spacing-unit));
        font-weight: 600;
        color: var(--neutral-700);
    }
}

/* ============================================
   RESPONSIVE CARDS
   ============================================ */

.card {
    background: white;
    border-radius: 8px;
    padding: calc(var(--spacing-unit) * 3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

@media (max-width: 767px) {
    .card {
        padding: calc(var(--spacing-unit) * 2);
        border-radius: 6px;
    }
}

/* ============================================
   COLLAPSIBLE SECTIONS (Mobile)
   ============================================ */

.collapsible-section {
    border: 1px solid var(--neutral-200);
    border-radius: 8px;
    margin-bottom: calc(var(--spacing-unit) * 2);
    overflow: hidden;
}

.collapsible-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: calc(var(--spacing-unit) * 2);
    background: var(--neutral-50);
    cursor: pointer;
    user-select: none;
}

.collapsible-header:hover {
    background: var(--neutral-100);
}

.collapsible-content {
    padding: calc(var(--spacing-unit) * 2);
    display: none;
}

.collapsible-content.active {
    display: block;
}

.collapsible-icon {
    transition: transform 0.3s ease;
}

.collapsible-icon.active {
    transform: rotate(180deg);
}

@media (min-width: 768px) {
    .collapsible-section {
        border: none;
        border-radius: 0;
    }
    
    .collapsible-header {
        background: transparent;
        cursor: default;
        padding: 0;
        margin-bottom: calc(var(--spacing-unit) * 2);
    }
    
    .collapsible-header:hover {
        background: transparent;
    }
    
    .collapsible-content {
        display: block !important;
        padding: 0;
    }
    
    .collapsible-icon {
        display: none;
    }
}

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

.btn-group {
    display: flex;
    gap: calc(var(--spacing-unit) * 2);
    flex-wrap: wrap;
}

@media (max-width: 767px) {
    .btn-group {
        flex-direction: column;
    }
    
    .btn-group .btn {
        width: 100%;
        justify-content: center;
    }
}

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

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: calc(var(--spacing-unit) * 2);
}

.modal-content {
    background: white;
    border-radius: 8px;
    padding: calc(var(--spacing-unit) * 4);
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

@media (max-width: 767px) {
    .modal {
        padding: calc(var(--spacing-unit));
    }
    
    .modal-content {
        max-width: 100%;
        max-height: 95vh;
        padding: calc(var(--spacing-unit) * 2);
        border-radius: 6px;
    }
}

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

.form-row {
    display: grid;
    gap: calc(var(--spacing-unit) * 2);
    margin-bottom: calc(var(--spacing-unit) * 3);
}

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

.form-row-3 {
    grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 767px) {
    .form-row-2,
    .form-row-3 {
        grid-template-columns: 1fr;
    }
}

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

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 calc(var(--spacing-unit) * 2);
}

@media (max-width: 767px) {
    .container {
        padding: 0 calc(var(--spacing-unit) * 1.5);
    }
}

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

h1 {
    font-size: 32px;
    font-weight: 700;
}

h2 {
    font-size: 24px;
    font-weight: 600;
}

h3 {
    font-size: 18px;
    font-weight: 600;
}

@media (max-width: 767px) {
    h1 {
        font-size: 24px;
    }
    
    h2 {
        font-size: 20px;
    }
    
    h3 {
        font-size: 16px;
    }
}

/* ============================================
   RESPONSIVE UTILITIES
   ============================================ */

/* Hide on mobile */
.hide-mobile {
    display: block;
}

@media (max-width: 767px) {
    .hide-mobile {
        display: none !important;
    }
}

/* Hide on tablet */
.hide-tablet {
    display: block;
}

@media (min-width: 768px) and (max-width: 1023px) {
    .hide-tablet {
        display: none !important;
    }
}

/* Hide on desktop */
.hide-desktop {
    display: none;
}

@media (min-width: 1024px) {
    .hide-desktop {
        display: none !important;
    }
}

/* Show only on mobile */
.show-mobile {
    display: none;
}

@media (max-width: 767px) {
    .show-mobile {
        display: block !important;
    }
}

/* Show only on tablet */
.show-tablet {
    display: none;
}

@media (min-width: 768px) and (max-width: 1023px) {
    .show-tablet {
        display: block !important;
    }
}

/* Show only on desktop */
.show-desktop {
    display: none;
}

@media (min-width: 1024px) {
    .show-desktop {
        display: block !important;
    }
}

/* ============================================
   RESPONSIVE SCORE CARDS
   ============================================ */

.score-card {
    display: flex;
    align-items: center;
    gap: calc(var(--spacing-unit) * 2);
    padding: calc(var(--spacing-unit) * 2);
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

@media (max-width: 767px) {
    .score-card {
        flex-direction: column;
        text-align: center;
        gap: calc(var(--spacing-unit));
    }
}

/* ============================================
   RESPONSIVE FILTERS
   ============================================ */

.filter-bar {
    display: flex;
    gap: calc(var(--spacing-unit) * 2);
    align-items: end;
    flex-wrap: wrap;
}

@media (max-width: 767px) {
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-bar > * {
        width: 100%;
    }
}

/* ============================================
   RESPONSIVE STATS GRID
   ============================================ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: calc(var(--spacing-unit) * 2);
}

@media (max-width: 767px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   RESPONSIVE PROGRESS BARS
   ============================================ */

.progress-bar-container {
    width: 100%;
    height: 24px;
    background: var(--neutral-100);
    border-radius: 12px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    border-radius: 12px;
    transition: width 0.3s ease;
}

@media (max-width: 767px) {
    .progress-bar-container {
        height: 20px;
    }
}

/* ============================================
   RESPONSIVE REASONING CHIPS
   ============================================ */

.reasoning-chips {
    display: flex;
    gap: calc(var(--spacing-unit) * 0.5);
    flex-wrap: wrap;
}

@media (max-width: 767px) {
    .reasoning-chips {
        justify-content: center;
    }
}

/* ============================================
   RESPONSIVE COMPARISON VIEW
   ============================================ */

.comparison-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: calc(var(--spacing-unit) * 3);
}

@media (max-width: 767px) {
    .comparison-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   RESPONSIVE OVERFLOW HANDLING
   ============================================ */

.overflow-scroll-mobile {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 767px) {
    .overflow-scroll-mobile {
        margin: 0 calc(var(--spacing-unit) * -1.5);
        padding: 0 calc(var(--spacing-unit) * 1.5);
    }
}

/* ============================================
   RESPONSIVE TEXT ALIGNMENT
   ============================================ */

@media (max-width: 767px) {
    .text-center-mobile {
        text-align: center !important;
    }
    
    .text-left-mobile {
        text-align: left !important;
    }
}
