/* ============================================================================
   MOBILE RESPONSIVE IMPROVEMENTS
   Optimized for mobile devices (smartphones & tablets)
   Created: 2025-10-10
   ============================================================================ */

/* ============================================================================
   BASE MOBILE OPTIMIZATIONS
   ============================================================================ */

/* Ensure smooth scrolling and proper touch handling */
html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
    -webkit-tap-highlight-color: rgba(230, 199, 14, 0.2);
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Improve touch targets - minimum 44x44px */
button, a, .clickable {
    min-height: 44px;
    min-width: 44px;
}

/* ============================================================================
   ELECTRICAL MONITORING CHART - RESPONSIVE LAYOUT
   Ensures metrics + chart render optimally across devices
   ============================================================================ */

.power-graph-card {
    display: grid !important;
    grid-template-rows: min-content min-content 1fr !important;
    gap: 0 !important;
    width: 100% !important;
    min-height: clamp(540px, 65vh, 720px) !important;
    height: auto !important;
    max-height: none !important;
    box-sizing: border-box !important;
    padding-bottom: 16px !important;
    overflow: visible !important;
}

.power-graph-card .card-header {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 12px !important;
    padding: 16px 24px !important;
}

.power-graph-card .card-header h3 {
    font-size: clamp(16px, 1.8vw, 20px) !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    margin: 0 !important;
}

.power-graph-card .card-controls {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
}

.power-graph-card .control-btn {
    padding: 8px 12px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    font-size: 14px !important;
}

.power-graph-card .stats-row {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)) !important;
    gap: 12px !important;
    padding: 0 24px 18px 24px !important;
    align-items: stretch !important;
}

.power-graph-card .stat-card {
    display: grid !important;
    grid-template-rows: auto auto auto !important;
    gap: 6px !important;
    padding: 12px 16px !important;
    min-height: 100px !important;
    border-radius: 10px !important;
}

.power-graph-card .stat-card i {
    font-size: 20px !important;
    opacity: 0.85 !important;
}

.power-graph-card .stat-label {
    font-size: 13px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
}

.power-graph-card .stat-value {
    font-size: clamp(18px, 2.2vw, 24px) !important;
    font-weight: 600 !important;
}

.power-graph-card .graph-container {
    position: relative !important;
    margin: 0 24px 0 24px !important;
    padding: 18px 20px 32px 20px !important;
    background: rgba(42, 42, 42, 0.32) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 12px !important;
    box-sizing: border-box !important;
    min-height: clamp(300px, 45vh, 520px) !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
}

.power-graph-card .power-chart,
.power-graph-card #powerChart {
    width: 100% !important;
    height: 100% !important;
    min-height: clamp(260px, 40vh, 480px) !important;
    display: block !important;
}

.power-graph-card canvas {
    width: 100% !important;
    height: 100% !important;
    display: block !important;
    margin: 0 !important;
    box-sizing: border-box !important;
}

.power-graph-card .card-header {
    flex-shrink: 0 !important;
    z-index: 2 !important;
}

/* ============================================================================
   HEADER RESPONSIVE FIXES
   ============================================================================ */

@media (max-width: 768px) {
    .header {
        padding: 10px 15px;
        position: sticky;
        top: 0;
        z-index: 1000;
    }
    
    .header-container {
        flex-wrap: wrap;
        gap: 10px;
        justify-content: center;
    }
    
    /* Logo optimization */
    .logo {
        gap: 8px;
        order: 1;
        flex: 1 1 100%;
        justify-content: center;
    }
    
    .logo-icon {
        width: 36px;
        height: 36px;
    }
    
    .logo-text h1 {
        font-size: 16px;
        text-align: center;
    }
    
    .subtitle {
        font-size: 10px;
        text-align: center;
    }
    
    /* Status indicators */
    .header-status {
        order: 2;
        flex: 1 1 100%;
        flex-wrap: wrap;
        gap: 8px;
        justify-content: center;
    }
    
    .connection-indicators {
        flex-wrap: wrap;
        gap: 8px;
        width: 100%;
        justify-content: center;
    }
    
    .status-item {
        padding: 8px 12px;
        min-height: 40px;
        font-size: 11px;
        flex: 0 1 auto;
    }
    
    .system-time {
        font-size: 12px;
    }
    
    /* Logout button */
    .logout-button {
        order: 3;
        padding: 10px 16px;
        min-height: 44px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .header-container {
        gap: 8px;
    }
    
    .logo-text h1 {
        font-size: 14px;
    }
    
    .status-item {
        font-size: 10px;
        padding: 6px 10px;
    }
    
    .status-item span {
        max-width: 100px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* ============================================================================
   DASHBOARD LAYOUT RESPONSIVE
   ============================================================================ */

@media (max-width: 1200px) {
    .dashboard {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        gap: 15px;
        padding: 15px;
        min-height: auto;
    }
    
    .left-panel,
    .center-panel,
    .right-panel {
        height: auto;
        min-height: auto;
        width: 100%;
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    .dashboard {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 12px;
    }
    
    /* Flight map card */
    .flight-path-card {
        height: auto;
        min-height: clamp(360px, 60vh, 640px);
    }
    
    .map-container {
        margin: 10px;
        min-height: clamp(320px, 55vh, 580px);
    }
    
    /* Electrical monitoring - tablet adjustments */
    .power-graph-card {
        min-height: clamp(520px, 75vh, 680px) !important;
        padding-bottom: 12px !important;
    }

    .power-graph-card .card-header {
        padding: 14px 20px !important;
        gap: 10px !important;
    }

    .power-graph-card .stats-row {
        grid-template-columns: repeat(2, minmax(150px, 1fr)) !important;
        gap: 10px !important;
        padding: 0 20px 14px 20px !important;
    }

    .power-graph-card .stat-card {
        min-height: 95px !important;
        padding: 10px 14px !important;
    }

    .power-graph-card .graph-container {
        margin: 0 20px !important;
        padding: 16px 16px 30px 16px !important;
        min-height: clamp(280px, 48vh, 460px) !important;
    }

    .power-graph-card .control-btn {
        padding: 6px 10px !important;
        font-size: 13px !important;
        min-width: 36px !important;
        min-height: 36px !important;
    }
    
    /* Right panel cards */
    .right-panel {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }
    
    .about-card {
        min-height: 200px;
        max-height: 300px;
    }
    
    .system-status-card,
    .activity-log-card {
        flex: 1 1 auto;
        min-height: 220px;
        max-height: none;
    }

    .activity-log-card .activity-log {
        max-height: clamp(170px, 36vh, 300px);
    }
}

/* ============================================================================
   EXTRA SMALL DEVICES (Mobile < 480px)
   ============================================================================ */

@media (max-width: 480px) {
    .dashboard {
        padding: 8px;
        gap: 10px;
    }
    
    .flight-path-card {
        height: auto;
        min-height: clamp(320px, 58vh, 540px);
    }
    
    .map-container {
        margin: 8px;
        min-height: clamp(280px, 52vh, 520px);
    }

    .activity-log-card .activity-log {
        max-height: clamp(160px, 40vh, 260px);
    }
    
    .power-graph-card {
        min-height: clamp(520px, 78vh, 660px) !important;
        padding-bottom: 10px !important;
    }

    .power-graph-card .card-header {
        padding: 12px 16px !important;
        gap: 8px !important;
    }

    .power-graph-card .card-controls {
        gap: 4px !important;
    }

    .power-graph-card .control-btn {
        padding: 5px 8px !important;
        font-size: 12px !important;
        min-width: 32px !important;
        min-height: 32px !important;
    }

    .power-graph-card .stats-row {
        grid-template-columns: repeat(2, minmax(120px, 1fr)) !important;
        gap: 8px !important;
        padding: 0 14px 12px 14px !important;
    }

    .power-graph-card .stat-card {
        min-height: 90px !important;
        padding: 9px 10px !important;
    }

    .power-graph-card .stat-card i {
        font-size: 18px !important;
    }

    .power-graph-card .stat-label {
        font-size: 11px !important;
    }

    .power-graph-card .stat-value {
        font-size: 16px !important;
    }

    .power-graph-card .graph-container {
        margin: 0 14px !important;
        padding: 14px 14px 28px 14px !important;
        min-height: clamp(260px, 52vh, 420px) !important;
    }

    .power-graph-card .power-chart,
    .power-graph-card #powerChart {
        min-height: clamp(220px, 45vh, 380px) !important;
    }
}

/* ============================================================================
   MAP CONTROLS RESPONSIVE
   ============================================================================ */

@media (max-width: 768px) {
    /* Map controls */
    .map-controls {
        top: 10px;
        right: 10px;
        gap: 4px;
    }
    
    .map-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
        /* Larger touch target */
    }
    
    /* Map status */
    .map-status {
        top: 10px;
        left: 10px;
    }
    
    .gps-status {
        padding: 6px 10px;
        font-size: 11px;
        gap: 6px;
    }
    
    /* Map legend */
    .map-legend {
        bottom: 10px;
        left: 10px;
        padding: 10px;
        max-width: calc(100% - 20px);
    }
    
    .legend-item {
        font-size: 11px;
        margin-bottom: 4px;
    }
    
    /* Layer switcher panel */
    .map-layer-panel {
        width: 90%;
        max-width: 320px;
        right: 5%;
        top: 50px;
    }
}

@media (max-width: 480px) {
    .map-btn {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }
    
    .gps-status {
        font-size: 10px;
        padding: 5px 8px;
    }
    
    .map-legend {
        font-size: 10px;
        padding: 8px;
    }
}

/* ============================================================================
   TELEMETRY DATA CARDS RESPONSIVE
   ============================================================================ */

@media (max-width: 768px) {
    .telemetry-data {
        overflow: visible;
    }
    
    .data-row {
        flex-direction: column;
        gap: 10px;
        padding: 15px;
    }
    
    .data-card {
        min-height: 80px;
        padding: 15px 12px;
    }
    
    .data-icon {
        font-size: 20px;
        width: 24px;
    }
    
    .data-label {
        font-size: 11px;
        margin-bottom: 4px;
    }
    
    .data-value {
        font-size: 16px;
    }
    
    /* Stats row */
    .stats-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        margin: 0 15px 15px;
    }
    
    .stat-card {
        padding: 12px;
    }
    
    .stat-card i {
        font-size: 20px;
    }
    
    .stat-value {
        font-size: 16px;
    }
    
    .stat-label {
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .data-row {
        padding: 12px;
        gap: 8px;
    }
    
    .data-card {
        min-height: 70px;
        padding: 12px 10px;
    }
    
    .data-label {
        font-size: 10px;
    }
    
    .data-value {
        font-size: 14px;
    }
    
    .stats-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        margin: 0 12px 12px;
    }
    
    .stat-card {
        padding: 10px;
    }
    
    .stat-value {
        font-size: 14px;
    }
}

/* ============================================================================
   SYSTEM STATUS & ACTIVITY LOG RESPONSIVE
   ============================================================================ */

@media (max-width: 768px) {
    /* System status */
    .status-items {
        padding: 15px;
        gap: 12px;
    }
    
    .status-item.animated-status {
        padding: 12px 14px;
        min-height: 48px;
        grid-template-columns: 1fr auto;
    }
    
    .status-label {
        font-size: 12px;
        min-width: 80px;
    }
    
    .status-value {
        font-size: 12px;
        min-width: 90px;
        max-width: 110px;
    }
    
    /* Activity log */
    .activity-log {
        padding: 0 15px 15px;
        max-height: 180px;
    }
    
    .log-entry {
        font-size: 10px;
        gap: 8px;
        padding: 4px 6px;
    }
    
    .log-time {
        font-size: 10px;
        min-width: 50px;
    }
    
    .log-message {
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .status-items {
        padding: 12px;
        gap: 10px;
    }
    
    .status-item.animated-status {
        padding: 10px 12px;
        grid-template-columns: 1fr;
        text-align: left;
    }
    
    .status-left {
        margin-bottom: 6px;
    }
    
    .status-value {
        justify-content: flex-start;
        min-width: auto;
        max-width: 100%;
    }
    
    .activity-log {
        padding: 0 12px 12px;
        max-height: 150px;
    }
    
    .log-entry {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .log-time {
        min-width: auto;
    }
}

/* ============================================================================
   ABOUT CARD & EMERGENCY BUTTON RESPONSIVE
   ============================================================================ */

@media (max-width: 768px) {
    .about-content {
        padding: 20px 24px;
        gap: 16px;
    }
    
    .team-btn {
        padding: 14px 28px;
        font-size: 15px;
        height: 48px;
        max-width: 220px;
    }
    
    .emergency-section {
        gap: 12px;
        margin-top: -15px;
        margin-bottom: 12px;
    }
    
    .emergency-cutoff {
        width: 120px;
        height: 120px;
        font-size: 12px;
    }
    
    .emergency-icon {
        font-size: 18px;
    }
    
    .emergency-status {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .about-content {
        padding: 15px 20px;
        gap: 12px;
    }
    
    .team-btn {
        padding: 12px 24px;
        font-size: 14px;
        height: 44px;
        max-width: 200px;
    }
    
    .emergency-cutoff {
        width: 100px;
        height: 100px;
        font-size: 11px;
    }
    
    .emergency-icon {
        font-size: 16px;
    }
}

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

@media (max-width: 768px) {
    .modal-content,
    .emergency-modal-content,
    .control-modal {
        width: 95%;
        max-width: 500px;
        margin: 20px;
    }
    
    .control-modal-content {
        padding: 24px;
    }
    
    .modal-icon,
    .success-icon,
    .error-icon {
        width: 70px;
        height: 70px;
        font-size: 28px;
    }
    
    .control-modal h2 {
        font-size: 20px;
    }
    
    .modal-subtitle {
        font-size: 14px;
    }
    
    .modal-actions {
        flex-direction: column;
        gap: 12px;
    }
    
    .btn-ghost,
    .btn-danger,
    .btn-primary {
        width: 100%;
        padding: 14px 20px;
    }
}

@media (max-width: 480px) {
    .modal-content,
    .emergency-modal-content,
    .control-modal {
        width: 98%;
        margin: 10px;
        border-radius: 12px;
    }
    
    .control-modal-content {
        padding: 20px;
    }
    
    .modal-icon,
    .success-icon,
    .error-icon {
        width: 60px;
        height: 60px;
        font-size: 24px;
    }
    
    .control-modal h2 {
        font-size: 18px;
    }
    
    .modal-subtitle {
        font-size: 13px;
    }
}

/* ============================================================================
   TEAM PANEL RESPONSIVE
   ============================================================================ */

@media (max-width: 768px) {
    .team-panel-content {
        width: 90%;
        max-width: 400px;
    }
    
    .team-panel-header {
        padding: 20px;
    }
    
    .team-panel-header h3 {
        font-size: 18px;
    }
    
    .team-panel-body {
        padding: 20px;
    }
    
    .team-identity h4 {
        font-size: 16px;
    }
    
    .team-focus h5,
    .team-activities h5,
    .team-contact h5 {
        font-size: 15px;
    }
}

@media (max-width: 480px) {
    .team-panel-content {
        width: 100%;
        max-width: 100%;
        border-radius: 0;
    }
    
    .team-panel-header {
        padding: 16px;
    }
    
    .team-panel-body {
        padding: 16px;
    }
    
    .team-identity h4 {
        font-size: 15px;
    }
}

/* ============================================================================
   FOOTER RESPONSIVE
   ============================================================================ */

@media (max-width: 768px) {
    .footer {
        padding: 14px 20px;
    }
    
    .footer-content {
        flex-direction: column;
        gap: 10px;
        text-align: center;
        font-size: 11px;
    }
    
    .footer-section {
        justify-content: center !important;
        text-align: center !important;
        width: 100%;
    }
    
    .footer-section:last-child {
        flex-direction: column;
        gap: 8px;
    }
    
    .settings-btn {
        min-width: 44px;
        height: 44px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .footer {
        padding: 12px 15px;
    }
    
    .footer-content {
        font-size: 10px;
        gap: 8px;
    }
    
    .footer-section span {
        font-size: 10px;
    }
}

/* ============================================================================
   CARD HEADERS & CONTROLS RESPONSIVE
   ============================================================================ */

@media (max-width: 768px) {
    .card-header {
        padding: 12px 15px;
    }
    
    .card-header h3,
    .card-header h4 {
        font-size: 14px;
        gap: 6px;
    }
    
    .card-controls {
        gap: 4px;
    }
    
    .control-btn,
    .control-btn-small {
        padding: 8px;
        font-size: 13px;
        min-width: 44px;
        min-height: 44px;
    }
}

@media (max-width: 480px) {
    .card-header {
        padding: 10px 12px;
    }
    
    .card-header h3,
    .card-header h4 {
        font-size: 13px;
    }
    
    .control-btn,
    .control-btn-small {
        padding: 6px;
        font-size: 12px;
    }
}

/* ============================================================================
   TOAST NOTIFICATIONS RESPONSIVE
   ============================================================================ */

@media (max-width: 768px) {
    .toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .toast {
        padding: 14px 16px;
        font-size: 13px;
    }
    
    .toast-icon {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .toast-container {
        top: 8px;
        right: 8px;
        left: 8px;
    }
    
    .toast {
        padding: 12px 14px;
        font-size: 12px;
    }
}

/* ============================================================================
   LANDSCAPE MODE OPTIMIZATIONS (Mobile Horizontal)
   ============================================================================ */

@media (max-width: 900px) and (orientation: landscape) {
    .flight-path-card {
        height: auto;
        min-height: clamp(420px, 72vh, 780px);
    }

    .map-container {
        min-height: clamp(360px, 66vh, 700px);
        margin: 12px;
    }
    
    .power-graph-card {
        min-height: clamp(520px, 82vh, 760px) !important;
        padding-bottom: 8px !important;
    }

    .power-graph-card .card-header {
        padding: 12px 18px !important;
    }

    .power-graph-card .stats-row {
        grid-template-columns: repeat(2, minmax(140px, 1fr)) !important;
        padding: 0 18px 12px 18px !important;
    }

    .power-graph-card .graph-container {
        padding: 14px 18px 26px 18px !important;
        min-height: clamp(260px, 55vh, 520px) !important;
    }
    
    .header {
        padding: 8px 15px;
    }
    
    .logo-text h1 {
        font-size: 14px;
    }
    
    .subtitle {
        display: none;
    }
    
    .status-item {
        padding: 6px 10px;
        font-size: 10px;
    }
}

/* ============================================================================
   LOADING SCREEN RESPONSIVE
   ============================================================================ */

@media (max-width: 768px) {
    .loading-content h2 {
        font-size: 18px;
    }
    
    .loading-content p {
        font-size: 13px;
    }
    
    .loading-spinner {
        width: 80px;
        height: 80px;
        margin-bottom: 20px;
    }
    
    .spinner-plane {
        font-size: 32px;
    }
    
    .loading-progress {
        width: 250px;
    }
}

@media (max-width: 480px) {
    .loading-content h2 {
        font-size: 16px;
    }
    
    .loading-content p {
        font-size: 12px;
    }
    
    .loading-spinner {
        width: 60px;
        height: 60px;
        margin-bottom: 15px;
    }
    
    .spinner-plane {
        font-size: 24px;
    }
    
    .loading-progress {
        width: 200px;
    }
}

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

/* Improve focus visibility */
*:focus-visible {
    outline: 2px solid var(--accent-gold);
    outline-offset: 2px;
}

/* Ensure text remains readable at all sizes */
@media (max-width: 480px) {
    body {
        font-size: 14px;
    }
    
    h1 { font-size: 20px; }
    h2 { font-size: 18px; }
    h3 { font-size: 16px; }
    h4 { font-size: 15px; }
    h5 { font-size: 14px; }
}

/* ============================================================================
   UTILITY CLASSES FOR MOBILE
   ============================================================================ */

.mobile-hide {
    display: none;
}

.mobile-show {
    display: block;
}

@media (min-width: 769px) {
    .mobile-hide {
        display: block;
    }
    
    .mobile-show {
        display: none;
    }
    
    .power-graph-card {
        min-height: clamp(560px, 62vh, 700px) !important;
    }

    .power-graph-card .card-header {
        padding: 18px 24px !important;
    }

    .power-graph-card .stats-row {
        grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)) !important;
        gap: 14px !important;
        padding: 0 24px 18px 24px !important;
    }

    .power-graph-card .stat-card {
        min-height: 110px !important;
    }

    .power-graph-card .graph-container {
        margin: 0 24px !important;
        padding: 20px 24px 34px 24px !important;
        min-height: clamp(320px, 48vh, 520px) !important;
    }
}

/* Extra large screens - ENLARGED for maximum visibility */
@media (min-width: 1400px) {
    .power-graph-card {
        min-height: clamp(620px, 58vh, 760px) !important;
        padding-bottom: 20px !important;
    }

    .power-graph-card .stats-row {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)) !important;
        gap: 16px !important;
        padding: 0 28px 20px 28px !important;
    }

    .power-graph-card .graph-container {
        margin: 0 28px !important;
        padding: 24px 28px 36px 28px !important;
        min-height: clamp(360px, 50vh, 560px) !important;
    }
}

/* Prevent text selection on touch devices */
.no-select {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Improve scrolling on iOS */
.scroll-smooth {
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
}

/* ============================================================================
   END OF MOBILE RESPONSIVE CSS
   ============================================================================ */
