/* ========================================
   Comprehensive Responsive Styles
   ======================================== */

/* ===== Mobile Language Switcher (hidden by default) ===== */
.lang-switcher-mobile {
    display: none;
}

/* ===== Mobile Bottom Navigation ===== */
.nav-bottom {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(180deg, #1e2a3a, #1a252f);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 10px 0;
    padding-bottom: env(safe-area-inset-bottom, 10px);
    z-index: 1000;
    justify-content: space-evenly;
    align-items: center;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
}

.bottom-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    max-width: 80px;
    padding: 6px 4px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.5);
    transition: all 0.2s ease;
    gap: 3px;
}

.bottom-tab.active {
    color: var(--accent-primary);
}

.bottom-tab.active .bottom-icon {
    transform: scale(1.1);
}

.bottom-tab:active {
    transform: scale(0.95);
}

.bottom-icon {
    font-size: 1.4rem;
    line-height: 1;
}

.bottom-label {
    font-size: 0.6rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

/* ===== Mobile User Bar ===== */
.mobile-user-bar {
    display: none;
    position: fixed;
    bottom: 60px;
    left: 0;
    right: 0;
    background: linear-gradient(180deg, #2a3a4a, #1e2a3a);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding: 8px 16px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    z-index: 999;
    justify-content: space-between;
    align-items: center;
}

.mobile-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mobile-user-icon {
    font-size: 1.2rem;
    opacity: 0.8;
}

.mobile-user-details {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.mobile-user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
}

.mobile-user-role {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.6);
}

.mobile-logout-btn {
    background: rgba(255, 100, 100, 0.15);
    border: 1px solid rgba(255, 100, 100, 0.3);
    color: #ff8888;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mobile-logout-btn:active {
    background: rgba(255, 100, 100, 0.25);
    transform: scale(0.95);
}

/* ===== Extra Large Screens (> 1400px) ===== */
@media (min-width: 1401px) {
    .app-container {
        max-width: 1600px;
    }

    .cards-grid {
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    }
}

/* ===== Large Screens (1200px - 1400px) ===== */
@media (max-width: 1400px) {
    .cards-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }

    .sport-charts-section,
    .reading-charts-section {
        grid-template-columns: 1fr;
    }

    .modal-charts {
        grid-template-columns: 1fr;
    }
}

/* ===== Medium Screens (992px - 1199px) ===== */
@media (max-width: 1199px) {
    .header {
        flex-direction: column;
        gap: var(--spacing-md);
        text-align: center;
    }

    .header-left {
        justify-content: center;
    }

    .header-right {
        width: 100%;
        justify-content: center;
    }

    .filters-section {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-groups {
        justify-content: center;
        flex-wrap: wrap;
    }

    .search-box {
        max-width: 100%;
    }

    .cards-grid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
        gap: var(--spacing-md);
    }

    /* Tables become scrollable */
    .academic-table-container,
    .reading-table-container,
    .sport-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .academic-table,
    .reading-table {
        min-width: 900px;
    }

    .sport-table {
        min-width: 1400px;
    }
}

/* ===== Tablet (768px - 991px) ===== */
@media (max-width: 991px) {
    .app-container {
        padding: var(--spacing-md);
    }

    .title {
        font-size: 1.5rem;
        letter-spacing: 2px;
    }

    .subtitle {
        font-size: 0.85rem;
    }

    .logo-icon {
        font-size: 2.5rem;
    }

    /* Navigation */
    .nav-tabs {
        gap: var(--spacing-xs);
        padding: var(--spacing-sm);
    }

    .tab-btn {
        padding: var(--spacing-sm) var(--spacing-md);
        font-size: 0.85rem;
    }

    .tab-icon {
        font-size: 1rem;
    }

    /* Cards */
    .cards-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    }

    .student-card {
        min-height: 350px;
    }

    /* Summary bars */
    .academic-summary-bar,
    .reading-summary-bar,
    .sport-summary-bar {
        flex-wrap: wrap;
        gap: var(--spacing-md);
        justify-content: center;
    }

    .summary-item {
        min-width: 100px;
    }

    /* Modal */
    .modal-content {
        margin: var(--spacing-md);
        max-height: calc(100vh - 32px);
        width: calc(100% - 32px);
    }

    .modal-student-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: var(--spacing-md);
    }

    .modal-photo {
        width: 140px;
        height: 140px;
    }

    .modal-name {
        font-size: 1.6rem;
    }

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

    .modal-stats-overview {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ===== Mobile Landscape (576px - 767px) ===== */
@media (max-width: 767px) {
    .app-container {
        padding: var(--spacing-sm);
        padding-bottom: 120px; /* Space for bottom nav + user bar */
    }

    /* Show mobile user bar, hide header user info */
    .mobile-user-bar {
        display: flex;
    }

    .header-right {
        display: none !important;
    }

    /* Show mobile language switcher */
    .lang-switcher-mobile {
        display: flex;
        gap: 2px;
        margin-left: auto;
        background: rgba(255, 255, 255, 0.1);
        border-radius: var(--radius-md);
        padding: 2px;
    }

    .lang-switcher-mobile .lang-btn {
        padding: 4px 8px;
        font-size: 0.7rem;
    }

    /* Header - stacked: logo/title on top, user info below */
    .header {
        padding: var(--spacing-sm);
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-sm);
    }

    .header-left {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: var(--spacing-xs);
        width: 100%;
    }

    .header-right {
        width: 100%;
    }

    .header-titles {
        text-align: left;
        min-width: 0;
        flex: 1;
    }

    .title {
        font-size: 0.9rem;
        letter-spacing: 0.5px;
    }

    .subtitle {
        font-size: 0.65rem;
        opacity: 0.7;
    }

    .logo-icon {
        font-size: 1.8rem;
        padding: 4px 8px;
    }

    /* Hide desktop navigation, show bottom nav */
    .nav-desktop {
        display: none !important;
    }

    .nav-bottom {
        display: flex;
    }

    /* Filters */
    .filters-section {
        gap: var(--spacing-sm);
    }

    .filter-groups {
        flex-direction: column;
        width: 100%;
    }

    .filter-group {
        width: 100%;
    }

    .filter-group select {
        width: 100%;
    }

    /* Compact sync controls */
    .filter-actions {
        flex-direction: row;
        gap: 8px;
        width: 100%;
    }

    .refresh-btn {
        padding: 6px 10px;
        font-size: 0.75rem;
        flex: 0 0 auto;
    }

    .refresh-btn .btn-text {
        display: none;
    }

    .sync-status {
        font-size: 0.65rem;
        gap: 4px;
        padding: 4px 8px;
    }

    .sync-status .status-icon {
        font-size: 0.5rem;
    }

    /* Cards */
    .cards-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: var(--spacing-sm);
    }

    .student-card {
        min-height: 320px;
    }

    .card-rating {
        padding: var(--spacing-sm);
    }

    .rating-value {
        font-size: 2.5rem;
    }

    /* Section headers */
    .section-header h2 {
        font-size: 1.3rem;
    }

    .section-header p {
        font-size: 0.85rem;
    }

    /* Tables */
    .academic-table,
    .reading-table {
        min-width: 700px;
        font-size: 0.8rem;
    }

    .sport-table {
        min-width: 1200px;
        font-size: 0.75rem;
    }

    /* Modal - Mobile Optimized */
    .modal-content {
        margin: 0;
        padding: var(--spacing-md);
        max-height: 100vh;
        width: 100%;
        border-radius: 0;
        overflow-y: auto;
    }

    .modal-close {
        top: 10px;
        right: 10px;
        width: 36px;
        height: 36px;
        font-size: 1.2rem;
        background: rgba(0, 0, 0, 0.5);
        border-radius: 50%;
        z-index: 10;
    }

    .modal-student-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: var(--spacing-md);
        padding-bottom: var(--spacing-md);
    }

    .modal-photo {
        width: 100px;
        height: 100px;
        border-width: 3px;
    }

    .modal-info {
        width: 100%;
    }

    .modal-name {
        font-size: 1.3rem;
        line-height: 1.2;
    }

    .modal-details {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-sm);
        text-align: left;
    }

    .detail-label {
        font-size: 0.7rem;
    }

    .detail-value {
        font-size: 1rem;
    }

    .modal-stats-overview {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .modal-stat {
        padding: 10px 6px;
    }

    .modal-stat-value {
        font-size: 1.4rem;
    }

    .modal-stat-label {
        font-size: 0.6rem;
    }

    .modal-stat-rank {
        font-size: 0.6rem;
    }

    .modal-charts {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
    }

    .modal-chart {
        padding: var(--spacing-md);
    }

    .modal-chart h4 {
        font-size: 0.9rem;
    }

    /* Leadership section mobile */
    .modal-leadership-section {
        padding: var(--spacing-md);
    }

    .leadership-breakdown {
        flex-direction: column;
        gap: var(--spacing-md);
    }

    .leadership-total {
        width: 100%;
        text-align: center;
    }

    .leadership-categories {
        width: 100%;
        flex-wrap: wrap;
        justify-content: center;
    }

    /* Breakdown row mobile (Career Dev + Behavior) */
    .modal-breakdown-row {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
    }

    .breakdown-card {
        padding: var(--spacing-md);
    }

    .breakdown-card-content {
        flex-direction: row;
    }

    .breakdown-score-value {
        font-size: 1.8rem;
    }

    .breakdown-item-value {
        font-size: 1rem;
    }

    /* Charts */
    .sport-chart-card,
    .reading-chart-card {
        padding: var(--spacing-md);
    }

    .chart-container {
        height: 200px;
    }
}

/* ===== Mobile Portrait (< 576px) ===== */
@media (max-width: 575px) {
    :root {
        --spacing-lg: 16px;
        --spacing-xl: 20px;
    }

    .app-container {
        padding: var(--spacing-xs);
        padding-bottom: 115px; /* Space for bottom nav + user bar */
    }

    /* Compact mobile user bar */
    .mobile-user-bar {
        bottom: 55px;
        padding: 6px 12px;
    }

    .mobile-user-name {
        font-size: 0.8rem;
    }

    .mobile-user-role {
        font-size: 0.65rem;
    }

    .mobile-logout-btn {
        padding: 5px 10px;
        font-size: 0.7rem;
    }

    .header {
        padding: var(--spacing-xs) var(--spacing-sm);
        gap: var(--spacing-xs);
    }

    .logo-icon {
        font-size: 1.5rem;
        padding: 3px 6px;
    }

    /* Compact mobile language switcher */
    .lang-switcher-mobile .lang-btn {
        padding: 3px 6px;
        font-size: 0.65rem;
    }

    .title {
        font-size: 0.8rem;
    }

    .subtitle {
        font-size: 0.6rem;
    }

    /* Bottom nav adjustments for small screens */
    .bottom-icon {
        font-size: 1.3rem;
    }

    .bottom-label {
        font-size: 0.55rem;
    }

    /* Cards - single column */
    .cards-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-sm);
    }

    .student-card {
        min-height: 300px;
    }

    .card-header {
        padding: var(--spacing-sm);
    }

    .rating-value {
        font-size: 2.2rem;
    }

    .rating-label {
        font-size: 0.6rem;
    }

    .card-photo-section {
        padding: var(--spacing-sm);
    }

    .card-stats {
        padding: var(--spacing-sm);
    }

    /* Summary bars - vertical */
    .academic-summary-bar,
    .reading-summary-bar,
    .sport-summary-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .summary-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: var(--spacing-sm);
        background: rgba(255, 255, 255, 0.05);
        border-radius: var(--radius-md);
    }

    .summary-value {
        font-size: 1.2rem;
    }

    .summary-label {
        font-size: 0.75rem;
    }

    /* Section headers */
    .section-header {
        padding: var(--spacing-sm) 0;
    }

    .section-header h2 {
        font-size: 1.1rem;
    }

    .section-header p {
        font-size: 0.75rem;
    }

    /* Tables */
    .academic-table th,
    .academic-table td,
    .reading-table th,
    .reading-table td {
        padding: 8px 6px;
        font-size: 0.75rem;
    }

    .student-col {
        min-width: 150px;
    }

    .student-avatar {
        width: 32px;
        height: 32px;
    }

    .student-name {
        font-size: 0.8rem;
    }

    .student-class {
        font-size: 0.65rem;
    }

    /* Modal - Small Mobile */
    .modal-content {
        margin: 0;
        border-radius: 0;
        max-height: 100vh;
        width: 100%;
        padding: var(--spacing-sm);
    }

    .modal-close {
        top: 8px;
        right: 8px;
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }

    .modal-student-header {
        gap: var(--spacing-sm);
        padding-bottom: var(--spacing-sm);
        margin-bottom: var(--spacing-sm);
    }

    .modal-photo {
        width: 80px;
        height: 80px;
        border-width: 2px;
    }

    .modal-name {
        font-size: 1.1rem;
    }

    .modal-details {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .detail-label {
        font-size: 0.6rem;
    }

    .detail-value {
        font-size: 0.85rem;
    }

    .modal-stats-overview {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
        margin-bottom: var(--spacing-md);
    }

    .modal-stat {
        padding: 8px 4px;
    }

    .modal-stat-value {
        font-size: 1.2rem;
    }

    .modal-stat-label {
        font-size: 0.55rem;
    }

    .modal-stat-rank {
        font-size: 0.5rem;
    }

    .modal-chart {
        padding: var(--spacing-sm);
    }

    .modal-chart h4 {
        font-size: 0.8rem;
        margin-bottom: var(--spacing-sm);
    }

    .modal-chart canvas {
        max-height: 150px;
    }

    .modal-leadership-section {
        padding: var(--spacing-sm);
        margin-top: var(--spacing-md);
    }

    .leadership-title {
        font-size: 0.9rem;
        margin-bottom: var(--spacing-sm);
    }

    /* Breakdown row small mobile */
    .modal-breakdown-row {
        margin-top: var(--spacing-md);
        gap: var(--spacing-sm);
    }

    .breakdown-card {
        padding: var(--spacing-sm);
    }

    .breakdown-card-title {
        font-size: 0.85rem;
        margin-bottom: var(--spacing-xs);
    }

    .breakdown-card-content {
        flex-direction: column;
        gap: var(--spacing-sm);
    }

    .breakdown-score {
        min-width: auto;
        width: 100%;
        padding: var(--spacing-sm);
        flex-direction: row;
        justify-content: center;
        gap: var(--spacing-sm);
    }

    .breakdown-score-value {
        font-size: 1.5rem;
    }

    .breakdown-score-label {
        font-size: 0.7rem;
        margin-top: 0;
    }

    .breakdown-items {
        width: 100%;
    }

    .careerdev-card .breakdown-items {
        grid-template-columns: repeat(3, 1fr);
    }

    .behavior-card .breakdown-items {
        grid-template-columns: repeat(3, 1fr);
    }

    .breakdown-item {
        padding: 8px 6px;
        min-width: auto;
    }

    .breakdown-item-value {
        font-size: 1rem;
    }

    .breakdown-item-label {
        font-size: 0.6rem;
    }

    .stat-value {
        font-size: 1.3rem;
    }

    .stat-label {
        font-size: 0.6rem;
    }

    /* Charts */
    .chart-container {
        height: 180px;
    }

    .sport-charts-section,
    .reading-charts-section {
        gap: var(--spacing-sm);
    }
}

/* ===== Touch Device Optimizations ===== */
@media (hover: none) and (pointer: coarse) {
    .student-card:hover {
        transform: none;
    }

    .tab-btn:hover {
        background: transparent;
    }

    .academic-table tr:hover,
    .reading-table tr:hover,
    .sport-table tr:hover {
        background: transparent;
    }

    /* Larger touch targets */
    .tab-btn {
        min-height: 44px;
    }

    .filter-group select {
        min-height: 44px;
    }

    .refresh-btn {
        min-height: 44px;
    }

    .modal-close {
        width: 44px;
        height: 44px;
        font-size: 1.5rem;
    }
}

/* ===== Print Styles ===== */
@media print {
    .header,
    .nav-tabs,
    .filters-section,
    .refresh-btn,
    .modal {
        display: none !important;
    }

    .app-container {
        max-width: 100%;
        padding: 0;
    }

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

    .student-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }

    .academic-table-container,
    .reading-table-container,
    .sport-table-container {
        overflow: visible;
    }

    .academic-table,
    .reading-table,
    .sport-table {
        min-width: auto;
        font-size: 10pt;
    }
}

/* ===== Landscape Orientation ===== */
@media (max-height: 500px) and (orientation: landscape) {
    .modal-content {
        max-height: 100vh;
        overflow-y: auto;
    }

    .modal-student-header {
        flex-direction: row;
    }

    .modal-photo {
        width: 80px;
        height: 80px;
    }
}

/* ===== High DPI Screens ===== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .student-card,
    .modal-content {
        border-width: 0.5px;
    }
}
