/**
 * Mobile Responsive Styles
 * For phones and tablets
 */

/* ============================================
   COLLAPSIBLE PANELS
   ============================================ */
.panel-toggle {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(0, 200, 255, 0.3);
    border: 1px solid rgba(0, 200, 255, 0.5);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    color: white;
    font-size: 1rem;
    cursor: pointer;
    z-index: 100;
    display: none; /* Hidden on desktop by default */
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.panel-toggle:hover {
    background: rgba(0, 200, 255, 0.5);
    transform: scale(1.1);
}

.panel-toggle:active {
    transform: scale(0.95);
}

/* Collapsed state */
.controls-panel.collapsed .panel-content,
#audio-controls.collapsed .panel-content {
    display: none !important;
}

.controls-panel.collapsed,
#audio-controls.collapsed {
    min-width: auto !important;
    max-width: 40px !important;
    width: 40px !important;
    padding: 4px !important;
    background: transparent !important;
    backdrop-filter: none !important;
    border: none !important;
    box-shadow: none !important;
}

.controls-panel.collapsed .panel-toggle,
#audio-controls.collapsed .panel-toggle {
    position: relative !important;
    top: 0 !important;
    right: 0 !important;
    margin: 0 !important;
}

/* ============================================
   MOBILE NOTICE POPUP
   ============================================ */
.mobile-notice {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    z-index: 10000;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 20px;
    animation: fadeIn 0.3s ease;
    margin: 0 !important;
}

.mobile-notice.hidden {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.mobile-notice-content {
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.95), rgba(162, 155, 254, 0.95));
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 15px;
    padding: 20px;
    max-width: 320px;
    width: 85%;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    position: relative;
    animation: slideUp 0.4s ease;
    margin: auto;
    transform: none !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    bottom: auto !important;
}

.mobile-notice-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    color: white;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001 !important;
    pointer-events: auto !important;
}

.mobile-notice-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.mobile-notice-icon {
    font-size: 2rem;
    margin-bottom: 8px;
    animation: bounce 1s infinite;
}

.mobile-notice h3 {
    color: white;
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 8px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.mobile-notice p {
    color: rgba(255, 255, 255, 0.95);
    font-size: 0.8rem;
    line-height: 1.4;
    margin-bottom: 6px;
}

.mobile-notice-sub {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.7);
    font-style: italic;
    margin-top: 8px;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* ============================================
   TABLETS (768px and below)
   ============================================ */
@media screen and (max-width: 768px) {
    /* Show toggle buttons on mobile */
    .panel-toggle {
        display: flex !important;
    }

    /* Auto-collapse panels on mobile */
    .controls-panel,
    #audio-controls {
        position: relative;
    }

    /* Header */
    .app-header {
        top: 10px;
        left: 10px;
        gap: 10px;
    }

    .logo {
        font-size: 1.2rem;
    }

    .logo-image {
        height: 20px;
    }

    #status-indicator {
        font-size: 0.7rem;
        padding: 3px 8px;
    }

    /* Controls Panel */
    .controls-panel {
        top: 60px !important;
        left: 10px !important;
        padding: 12px !important;
        min-width: 200px !important;
        max-width: 250px !important;
    }

    .control-group label {
        font-size: 0.85rem;
    }

    #speed-slider {
        height: 4px;
    }

    #voice-selector {
        font-size: 0.75rem;
        padding: 6px 10px;
    }

    /* Theme/Mode Selector */
    .theme-selector {
        top: 150px !important;
        right: 10px !important;
        width: auto !important;
    }

    .mode-btn {
        padding: 8px 12px !important;
        font-size: 0.75rem !important;
        min-width: auto !important;
    }

    /* Gesture Guide */
    .gesture-guide {
        bottom: 10px !important;
        right: 10px !important;
        padding: 10px !important;
    }

    .gesture-item {
        font-size: 0.75rem;
    }

    /* Webcam */
    #webcam-container {
        width: 180px !important;
        height: 135px !important;
        top: 320px !important;
        left: 10px !important;
    }

    #webcam-toggle {
        top: 460px !important;
        left: 10px !important;
        font-size: 0.75rem;
        padding: 5px 10px;
    }

    /* Audio Controls */
    #audio-controls {
        top: 500px !important;
        left: 10px !important;
        min-width: 180px !important;
        padding: 10px !important;
    }

    #audio-toggle {
        padding: 8px;
        font-size: 1rem;
    }

    #volume-slider {
        height: 4px;
    }

    #volume-value {
        font-size: 0.75rem;
    }

    /* Chat Interface */
    .chat-container {
        bottom: 10px !important;
        left: 10px !important;
        right: 10px !important;
        width: calc(100% - 20px) !important;
        max-width: 100% !important;
        max-height: 180px !important;
        z-index: 100 !important;
    }

    .chat-messages {
        max-height: 100px !important;
        font-size: 0.75rem;
        padding: 8px !important;
    }

    #chat-input {
        font-size: 0.75rem;
        padding: 8px;
    }

    .chat-input-area {
        padding: 8px !important;
    }

    #mic-btn {
        font-size: 1.2rem !important;
        padding: 8px !important;
    }

    /* Credits - Make mobile-friendly with feedback button */
    .credits {
        font-size: 0.65rem !important;
        opacity: 0.6;
        bottom: 200px !important;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 8px;
        padding: 10px;
    }

    .feedback-btn {
        font-size: 0.7rem !important;
        padding: 6px 12px !important;
        margin: 5px 0 0 0 !important;
    }

    /* Planet Info Panel */
    .planet-info-panel {
        top: auto !important;
        bottom: 220px !important;
        right: 10px !important;
        left: 10px !important;
        width: calc(100% - 20px) !important;
        max-width: 350px !important;
        max-height: 40vh !important;
        margin: 0 auto;
        padding: 12px !important;
    }

    .planet-name {
        font-size: 1.2rem !important;
    }

    .planet-type {
        font-size: 0.65rem !important;
    }

    .planet-info-panel .description {
        font-size: 0.75rem !important;
        margin-bottom: 8px !important;
    }

    .info-item label {
        font-size: 0.7rem;
    }

    .info-item span {
        font-size: 0.75rem;
    }

    .info-grid {
        gap: 8px !important;
    }

    .fun-fact {
        font-size: 0.7rem !important;
        padding: 8px !important;
        margin-top: 8px !important;
    }
}

/* ============================================
   MOBILE PHONES (480px and below)
   ============================================ */
@media screen and (max-width: 480px) {
    /* Header - Smaller */
    .logo {
        font-size: 1rem;
    }

    .logo-image {
        height: 18px;
    }

    #status-indicator {
        font-size: 0.65rem;
        padding: 2px 6px;
    }

    /* Hide or minimize controls for mobile */
    .controls-panel {
        top: 50px !important;
        left: 5px !important;
        padding: 8px !important;
        min-width: 160px !important;
    }

    .control-group label {
        font-size: 0.75rem;
    }

    .control-group button {
        padding: 6px 10px !important;
        font-size: 0.75rem !important;
    }

    #speed-value,
    #volume-value {
        font-size: 0.7rem;
        min-width: 30px;
    }

    #voice-selector {
        font-size: 0.7rem;
        padding: 5px 8px;
    }

    /* Mode Buttons - Stack vertically */
    .theme-selector {
        top: 120px !important;
        right: 5px !important;
        flex-direction: column !important;
        gap: 5px !important;
    }

    .mode-btn {
        padding: 6px 10px !important;
        font-size: 0.7rem !important;
        width: 100% !important;
    }

    /* Gesture Guide - Smaller */
    .gesture-guide {
        bottom: 5px !important;
        right: 5px !important;
        padding: 8px !important;
        gap: 6px !important;
    }

    .gesture-item {
        font-size: 0.65rem;
    }

    .gesture-item .icon {
        font-size: 1rem;
    }

    /* Webcam - Smaller */
    #webcam-container {
        width: 140px !important;
        height: 105px !important;
        top: 280px !important;
        left: 5px !important;
    }

    #webcam-toggle {
        top: 390px !important;
        left: 5px !important;
        font-size: 0.7rem;
        padding: 4px 8px;
    }

    /* Audio Controls - Compact */
    #audio-controls {
        top: 425px !important;
        left: 5px !important;
        min-width: 140px !important;
        padding: 8px !important;
    }

    #audio-toggle {
        padding: 6px;
        font-size: 0.9rem;
    }

    .volume-control {
        gap: 6px;
    }

    .volume-control label {
        font-size: 0.85rem;
    }

    /* Chat Interface - Full width at bottom */
    .chat-container {
        bottom: 5px !important;
        left: 5px !important;
        right: 5px !important;
        width: calc(100% - 10px) !important;
        max-width: 100% !important;
        max-height: 130px !important;
        z-index: 100 !important;
    }

    .chat-messages {
        max-height: 70px !important;
        font-size: 0.7rem;
        padding: 6px !important;
    }

    #chat-input {
        font-size: 0.7rem;
        padding: 6px;
    }

    .chat-input-area {
        padding: 6px !important;
    }

    #mic-btn {
        font-size: 1rem !important;
        padding: 6px !important;
    }

    /* Credits - Very small on phones with feedback button */
    .credits {
        font-size: 0.6rem !important;
        opacity: 0.5;
        bottom: 140px !important;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 6px;
        padding: 8px;
        max-width: 90%;
        left: 50%;
        transform: translateX(-50%);
    }

    .feedback-btn {
        font-size: 0.65rem !important;
        padding: 5px 10px !important;
        margin: 3px 0 0 0 !important;
        white-space: nowrap;
    }

    /* Planet Info - Compact overlay */
    .planet-info-panel {
        top: auto !important;
        bottom: 145px !important;
        left: 5px !important;
        right: 5px !important;
        width: calc(100% - 10px) !important;
        max-height: 35vh !important;
        padding: 10px !important;
    }

    .planet-name {
        font-size: 1rem !important;
    }

    .planet-type {
        font-size: 0.6rem !important;
    }

    .planet-info-panel .description {
        font-size: 0.7rem !important;
        margin-bottom: 6px !important;
    }

    .info-section {
        padding: 8px !important;
    }

    .info-item {
        padding: 5px 0 !important;
    }

    .info-item label {
        font-size: 0.65rem;
    }

    .info-item span {
        font-size: 0.7rem;
    }

    .info-grid {
        gap: 6px !important;
    }

    .fun-fact {
        font-size: 0.65rem !important;
        padding: 8px !important;
        margin-top: 6px !important;
    }

    .panel-close-btn {
        width: 28px !important;
        height: 28px !important;
        font-size: 1rem !important;
    }
}

/* ============================================
   LANDSCAPE MODE (Mobile)
   ============================================ */
@media screen and (max-height: 500px) and (orientation: landscape) {
    /* Hide less important elements in landscape */
    #webcam-container,
    #webcam-toggle,
    .gesture-guide {
        display: none !important;
    }

    .controls-panel {
        top: 10px !important;
        left: 10px !important;
        max-height: 180px !important;
        overflow-y: auto !important;
    }

    #audio-controls {
        top: 200px !important;
    }

    .chat-container {
        max-height: 120px !important;
    }

    .planet-info-panel {
        max-height: 80vh !important;
    }
}

/* ============================================
   TOUCH IMPROVEMENTS
   ============================================ */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    button {
        min-height: 44px;
        min-width: 44px;
    }

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

    input[type="range"] {
        height: 44px;
    }

    /* Better button spacing */
    .control-group button {
        margin: 2px;
    }

    /* Larger close button for planet info */
    .panel-close-btn {
        width: 44px !important;
        height: 44px !important;
        font-size: 1.2rem !important;
    }
}
