/* ChatUni - Responsive CSS */
/* Media queries per mobile e tablet */

/* ═══════════════════════════════════════════════════════════════
   COMPACT AUDIO PLAYER - Desktop base styles
   ═══════════════════════════════════════════════════════════════ */
.compact-audio-player {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(0, 242, 255, 0.25);
    border-radius: 8px;
    width: 100%;
    box-sizing: border-box;
}

.ap-play-btn {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 6px;
    border: 1px solid #00f2ff;
    background: rgba(0, 242, 255, 0.1);
    color: #00f2ff;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
}

.ap-play-btn:hover {
    background: rgba(0, 242, 255, 0.25);
    box-shadow: 0 0 8px rgba(0, 242, 255, 0.4);
}

.ap-play-btn.playing {
    border-color: #ff00ff;
    color: #ff00ff;
    background: rgba(255, 0, 255, 0.15);
}

.ap-volume-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
}

.ap-icon {
    font-size: 0.85rem;
    cursor: pointer;
    flex-shrink: 0;
    user-select: none;
}

.ap-volume-slider {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    height: 4px;
    background: rgba(0, 242, 255, 0.2);
    border-radius: 4px;
    outline: none;
    cursor: pointer;
    min-width: 0;
}

.ap-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #00f2ff;
    cursor: pointer;
    box-shadow: 0 0 6px rgba(0, 242, 255, 0.5);
}

.ap-volume-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #00f2ff;
    cursor: pointer;
    border: none;
    box-shadow: 0 0 6px rgba(0, 242, 255, 0.5);
}

.ap-level {
    font-size: 0.55rem;
    color: #00f2ff;
    font-family: 'Orbitron', sans-serif;
    letter-spacing: 1px;
    min-width: 28px;
    text-align: right;
    flex-shrink: 0;
}

/* Hide old knob volume on desktop */
.volume-knob-container { display: none !important; }

/* TABLET LANDSCAPE */
@media (max-width: 1024px) {
    .grid-layout-wrapper {
        flex-direction: column;
        gap: 30px;
        height: auto;
        padding: 20px;
        overflow-y: auto;
    }

    .sidebar-controls {
        width: 100%;
        max-width: 500px;
        flex-direction: column;
        justify-content: center;
        gap: 15px;
    }

    .exit-wrapper {
        flex-direction: row;
        width: 100%;
        justify-content: center;
        gap: 20px;
    }

    .cyber-exit-btn {
        writing-mode: horizontal-tb;
        text-orientation: mixed;
        padding: 10px 30px;
        letter-spacing: 2px;
    }

    .grid-container {
        grid-template-columns: repeat(4, 1fr);
        grid-template-rows: auto;
        width: 100%;
        height: auto;
        opacity: 1;
    }
    
    .main-wrapper {
        flex-direction: column;
        gap: 20px;
    }
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE PORTRAIT - Compact sidebar, player in footer
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    /* Show hamburger button */
    .hamburger-btn {
        display: flex !important;
        position: relative;
        z-index: 1100;
        flex-shrink: 0;
        order: -1;
    }

    /* Top bar */
    .top-bar {
        justify-content: flex-start !important;
        gap: 10px;
    }

    .top-bar-left {
        display: none !important;
    }

    .top-bar-center,
    .top-bar-right {
        display: none !important;
    }

    /* Mobile menu */
    .mobile-menu {
        display: flex !important;
        flex-direction: column;
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
        z-index: 1050;
        background: rgba(0, 0, 0, 0.95);
        backdrop-filter: blur(10px);
        border-bottom: 2px solid rgba(0, 242, 255, 0.3);
        padding: 0 10px;
    }

    .mobile-menu.active {
        max-height: 80vh;
        opacity: 1;
        visibility: visible;
        padding: 15px 10px;
        overflow-y: auto;
    }

    .mobile-menu-btn:nth-child(1) { --menu-index: 0; }
    .mobile-menu-btn:nth-child(2) { --menu-index: 1; }
    .mobile-menu-btn:nth-child(3) { --menu-index: 2; }
    .mobile-menu-btn:nth-child(4) { --menu-index: 3; }
    .mobile-menu-btn:nth-child(5) { --menu-index: 4; }
    .mobile-menu-btn:nth-child(6) { --menu-index: 5; }
    .mobile-menu-btn:nth-child(7) { --menu-index: 6; }

    /* Grid layout wrapper - column with footer space */
    .grid-layout-wrapper {
        flex-direction: column !important;
        height: 100vh;
        gap: 0;
        padding-top: 70px !important;
        justify-content: flex-start !important;
        padding-bottom: 56px !important; /* space for footer player */
    }

    /* Sidebar: only nav arrows + search + buttons grid */
    .sidebar-controls {
        order: 1;
        width: 100% !important;
        flex-direction: column !important;
        padding: 8px 12px !important;
        gap: 6px !important;
        background: rgba(0, 0, 0, 0.7);
        border-radius: 0;
        border-top: none;
        box-sizing: border-box;
        margin-top: 0 !important;
        max-height: none;
        overflow: visible;
    }

    /* Hide compact audio player inside sidebar on mobile (it goes to footer) */
    .sidebar-controls .compact-audio-player {
        display: none !important;
    }

    /* Sector name - compact */
    .grid-header-sidebar {
        order: -2;
        width: 100% !important;
        border-bottom: none !important;
        padding: 0 !important;
    }

    #sector-name {
        font-size: 0.9rem !important;
        text-align: center;
        margin: 0;
        padding: 4px 0;
    }

    .sector-nav-arrows {
        gap: 8px;
    }

    .sector-nav-btn {
        width: 28px;
        height: 28px;
        font-size: 0.9rem;
    }

    /* Search bar */
    .search-bar-sidebar {
        width: 100% !important;
        order: 1;
    }

    .search-input-wrapper {
        justify-content: center !important;
        width: 100% !important;
        gap: 6px !important;
    }

    #sector-search-input {
        border-left: none !important;
        border-bottom: 2px solid #00f2ff !important;
        text-align: center;
        padding: 8px !important;
        font-size: 0.8rem;
    }

    #sector-search-btn {
        padding: 6px 12px !important;
        font-size: 0.7rem !important;
    }

    /* Sidebar buttons grid - compact */
    .sidebar-buttons-grid {
        order: 2;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 5px !important;
    }

    .sidebar-btn {
        min-height: 32px !important;
        padding: 4px 4px !important;
        font-size: 0.55rem !important;
    }

    /* Exit wrapper */
    .exit-wrapper {
        order: 2;
        width: 100%;
    }

    .cyber-exit-btn {
        writing-mode: horizontal-tb !important;
        text-orientation: mixed !important;
        width: 100% !important;
        padding: 8px !important;
        letter-spacing: 8px !important;
        font-size: 0.65rem !important;
        clip-path: none !important;
        border-radius: 6px !important;
        margin-bottom: 0 !important;
        height: auto !important;
    }

    /* Grid container */
    .grid-container {
        order: 4;
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
        grid-rows: auto !important;
        gap: 6px !important;
        width: 100%;
        overflow-y: auto !important;
        padding: 6px 6px 10px 6px;
        flex-grow: 1;
        max-height: none;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
    }

    .grid-item {
        height: 60px !important;
        width: 100% !important;
        overflow: hidden !important;
        display: flex !important;
        flex-direction: column !important;
        padding: 4px !important;
    }

    .occupied-info {
        width: 100% !important;
        overflow: hidden !important;
    }

    .locked-label {
        font-size: 0.6rem !important;
        width: 100% !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .locked-date {
        display: none !important;
    }

    .square-number {
        font-size: 0.8rem !important;
        color: rgba(0, 242, 255, 1) !important;
        font-weight: bold !important;
        top: 2px !important;
        left: 2px !important;
        text-shadow: 0 0 5px rgba(0, 242, 255, 0.8);
    }

    /* Toggle buttons */
    .toggle-buttons-container {
        order: 3;
        margin-top: 6px;
        margin-bottom: 0;
        position: relative;
        top: auto;
        display: flex;
        justify-content: center;
        gap: 6px;
        flex-wrap: wrap;
        width: 100%;
        padding: 0 6px;
    }

    #toggle-window-btn {
        order: 10;
    }

    .toggle-window-btn {
        flex: 0 1 auto;
        min-width: 70px;
        height: 30px;
        font-size: 0.6rem;
        padding: 4px 6px;
        letter-spacing: 0.3px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Modals */
    .modal-content {
        width: 95% !important;
        padding: 15px !important;
    }

    /* Nav arrows */
    .nav-arrow {
        font-size: 1.5rem !important;
        bottom: 60px !important;
        background: rgba(0, 0, 0, 0.5);
        border-radius: 50%;
        padding: 8px !important;
    }

    /* Timer */
    .cyber-timer {
        flex-direction: row !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 5px !important;
        position: fixed !important;
        bottom: 56px !important;
        left: 0 !important;
        transform: none !important;
        width: 100% !important;
        background: rgba(0, 0, 0, 0.8) !important;
        backdrop-filter: blur(5px) !important;
        padding: 6px 0 !important;
        border-top: 1px solid rgba(0, 242, 255, 0.3) !important;
        z-index: 2000 !important;
    }

    /* ═══════════════════════════════════════════════════════════
       FOOTER AUDIO PLAYER - Mobile only
       ═══════════════════════════════════════════════════════════ */
    .mobile-audio-footer {
        display: flex !important;
    }
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE FOOTER AUDIO PLAYER
   ═══════════════════════════════════════════════════════════════ */
.mobile-audio-footer {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1100;
    background: rgba(5, 5, 15, 0.95);
    border-top: 1px solid rgba(0, 242, 255, 0.3);
    padding: 6px 12px;
    align-items: center;
    gap: 8px;
    backdrop-filter: blur(8px);
}

.mobile-audio-footer .ap-play-btn {
    width: 34px;
    height: 34px;
    min-width: 34px;
}

.mobile-audio-footer .ap-volume-wrap {
    flex: 1;
}

.mobile-audio-footer .ap-volume-slider {
    height: 4px;
}

.mobile-audio-footer .ap-level {
    font-size: 0.5rem;
}

/* VERY SMALL DEVICES */
@media (max-width: 600px) {
    .grid-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .sidebar-controls {
        padding: 6px 8px;
    }

    #sector-name {
        font-size: 0.8rem;
    }

    .modal-content {
        width: 95%;
        padding: 15px;
    }

    textarea {
        height: 100px;
    }

    .cyber-exit-btn {
        font-size: 0.6rem;
        padding: 6px 15px;
    }

    .sidebar-btn {
        min-height: 28px !important;
        font-size: 0.5rem !important;
    }
}

/* ─── SIDEBAR BUTTONS GRID - uniform on all viewports ─────────────── */
.sidebar-buttons-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
    width: 100% !important;
}

.sidebar-btn {
    width: 100% !important;
    min-height: 44px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    padding: 8px 4px !important;
    font-size: 0.6rem !important;
    white-space: normal !important;
    word-break: break-word !important;
    line-height: 1.2 !important;
    box-sizing: border-box !important;
}