/**
 * Retro Arcade Web Theme
 * Giao diện tối giản, cổ điển, phong cách tủ máy game thùng thập niên 80-90
 */

:root {
    --bg-dark: #07090e;
    --bg-panel: #0d121c;
    --bg-card: #131b29;
    --border-color: #24334d;
    --neon-cyan: #00f0ff;
    --neon-pink: #ff0055;
    --neon-gold: #ffb700;
    --neon-lime: #39ff14;
    --text-primary: #e6edf8;
    --text-muted: #7e91ad;
    --cabinet-gold: #e5a93c;
    --cabinet-red: #d92027;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: 'Courier New', Courier, Consolas, Monaco, monospace;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    background-image: 
        radial-gradient(circle at 50% 0%, rgba(0, 240, 255, 0.08) 0%, transparent 60%),
        linear-gradient(to bottom, #090c14, #05070a);
}

/* ==================== MARQUEE BANNER TRÊN CÙNG ==================== */
.arcade-header {
    background: linear-gradient(180deg, #182236 0%, #0d131f 100%);
    border-bottom: 2px solid var(--neon-cyan);
    box-shadow: 0 4px 15px rgba(0, 240, 255, 0.25);
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    position: relative;
    z-index: 50;
}

.arcade-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-badge {
    background: var(--neon-pink);
    color: #fff;
    font-size: 11px;
    font-weight: 900;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 1px;
    box-shadow: 0 0 8px var(--neon-pink);
    text-transform: uppercase;
}

.logo-title {
    font-size: 16px;
    font-weight: 900;
    letter-spacing: 2px;
    color: #ffffff;
    text-shadow: 
        0 0 5px var(--neon-cyan),
        0 0 10px rgba(0, 240, 255, 0.5);
    text-transform: uppercase;
}

/* Thanh nút điều hướng trên Menu */
.header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.arcade-nav-btn {
    background: #151d2d;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.15s ease;
}

.arcade-nav-btn:hover {
    border-color: var(--neon-cyan);
    color: var(--neon-cyan);
    box-shadow: 0 0 8px rgba(0, 240, 255, 0.4);
    transform: translateY(-1px);
}

.arcade-nav-btn:active {
    transform: translateY(1px);
}

.arcade-nav-btn.primary {
    background: linear-gradient(135deg, #0088cc, #005588);
    border-color: var(--neon-cyan);
    color: #ffffff;
}

.arcade-nav-btn.gold {
    background: linear-gradient(135deg, #b37700, #805500);
    border-color: var(--neon-gold);
    color: #ffffff;
}

/* ==================== KHU VỰC TRUNG TÂM / MÀN HÌNH MÁY ==================== */
.main-stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px;
    position: relative;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

.screen-wrapper {
    position: relative;
    width: 100%;
    max-width: 800px;
    aspect-ratio: 4 / 3;
    background: #000;
    border-radius: 14px;
    box-shadow: 
        0 15px 35px rgba(0, 0, 0, 0.8),
        0 0 25px rgba(0, 240, 255, 0.15);
}

/* Khi màn hình quá cao hoặc trên di động xoay ngang */
@media (max-height: 600px) {
    .screen-wrapper {
        max-width: 600px;
    }
}

.screen-container {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: 12px;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Canvas của minigame tự dựng */
#retro-canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    display: block;
}

/* Iframe của EmulatorJS */
.emulator-iframe {
    width: 100%;
    height: 100%;
    border: none;
    outline: none;
    background: #000;
    display: block;
}

/* ==================== THANH TRẠNG THÁI STATUS BAR ==================== */
.arcade-status-bar {
    width: 100%;
    max-width: 800px;
    margin-top: 8px;
    background: #0d121c;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 6px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--text-muted);
}

.status-left {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--neon-lime);
    box-shadow: 0 0 6px var(--neon-lime);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 0.5; }
    50% { opacity: 1; }
    100% { opacity: 0.5; }
}

.status-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.badge-tag {
    background: #182236;
    color: var(--neon-cyan);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
    border: 1px solid rgba(0, 240, 255, 0.3);
}

/* ==================== MODALS / HỘP THOẠI RETRO ==================== */
.retro-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(4, 7, 12, 0.85);
    backdrop-filter: blur(5px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1200;
    padding: 16px;
}

.retro-modal-backdrop.open {
    display: flex;
}

.retro-modal {
    background: #0d121c;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 
        0 15px 40px rgba(0, 0, 0, 0.9),
        0 0 20px rgba(0, 240, 255, 0.2);
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalPop 0.18s ease-out;
}

@keyframes modalPop {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-header {
    background: #151d2e;
    border-bottom: 1px solid var(--border-color);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 14px;
    font-weight: 900;
    color: var(--neon-cyan);
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    font-weight: bold;
    padding: 4px 8px;
    line-height: 1;
}

.modal-close-btn:hover {
    color: var(--neon-pink);
}

.modal-body {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
}

/* ==================== BẢNG DANH SÁCH ROM TRONG KHO ==================== */
.rom-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.rom-item-card {
    background: #121824;
    border: 1px solid #1f2c42;
    border-radius: 8px;
    padding: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    transition: all 0.15s ease;
}

.rom-item-card:hover {
    border-color: var(--neon-cyan);
    background: #172030;
}

.rom-info {
    flex: 1;
    overflow: hidden;
}

.rom-title {
    font-weight: bold;
    font-size: 13px;
    color: #fff;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rom-meta {
    display: flex;
    gap: 8px;
    font-size: 10px;
    color: var(--text-muted);
    align-items: center;
    flex-wrap: wrap;
}

.rom-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-play-rom {
    background: linear-gradient(135deg, #00c853, #009624);
    border: 1px solid #69f0ae;
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 200, 83, 0.4);
}

.btn-play-rom:hover {
    filter: brightness(1.2);
    transform: translateY(-1px);
}

.btn-del-rom {
    background: #2a1520;
    border: 1px solid #5a1c32;
    color: var(--neon-pink);
    padding: 6px 8px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 11px;
    cursor: pointer;
}

.btn-del-rom:hover {
    background: var(--neon-pink);
    color: #fff;
}

/* Khu vực Kéo thả file ROM */
.dropzone-box {
    border: 2px dashed #2d4166;
    background: rgba(18, 25, 38, 0.5);
    border-radius: 10px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 16px;
}

.dropzone-box:hover, .dropzone-box.drag-over {
    border-color: var(--neon-cyan);
    background: rgba(0, 240, 255, 0.05);
}

.dropzone-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.dropzone-text {
    font-size: 12px;
    color: #c0d0e6;
    margin-bottom: 6px;
}

.dropzone-hint {
    font-size: 10px;
    color: var(--text-muted);
}

/* ==================== FORM FIELDS ==================== */
.form-group {
    margin-bottom: 14px;
}

.form-label {
    display: block;
    font-size: 11px;
    font-weight: bold;
    color: var(--neon-cyan);
    margin-bottom: 5px;
}

.form-input, .form-select {
    width: 100%;
    background: #090c14;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 12px;
    color: #fff;
    font-family: inherit;
    font-size: 12px;
    outline: none;
}

.form-input:focus, .form-select:focus {
    border-color: var(--neon-cyan);
    box-shadow: 0 0 6px rgba(0, 240, 255, 0.4);
}

/* ==================== SAVE SLOTS UI ==================== */
.save-slots-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.save-slot-card {
    background: #111724;
    border: 1px solid #1f2c42;
    border-radius: 8px;
    padding: 10px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.save-slot-card.has-data {
    border-color: rgba(0, 240, 255, 0.4);
}

.slot-name {
    font-weight: bold;
    font-size: 12px;
    color: var(--neon-gold);
}

.slot-time {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 3px;
}

.slot-btn-group {
    display: flex;
    gap: 6px;
}

/* ==================== TOAST NOTIFICATION ==================== */
.arcade-toast {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: rgba(14, 20, 32, 0.95);
    border: 2px solid var(--neon-cyan);
    color: #ffffff;
    padding: 10px 20px;
    border-radius: 30px;
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 0.5px;
    box-shadow: 
        0 6px 20px rgba(0, 0, 0, 0.8),
        0 0 15px rgba(0, 240, 255, 0.4);
    z-index: 2000;
    pointer-events: none;
    opacity: 0;
    transition: all 0.25s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.arcade-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ==================== LOADING OVERLAY ==================== */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(5, 7, 12, 0.9);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: 12px;
}

.loading-overlay.active {
    display: flex;
}

.retro-spinner {
    width: 44px;
    height: 44px;
    border: 4px solid #1a273d;
    border-top-color: var(--neon-cyan);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 12px;
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.5);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    font-size: 12px;
    font-weight: bold;
    color: var(--neon-cyan);
    letter-spacing: 1px;
}

/* ==================== SYSTEM FILTER BAR (NES, SNES, GBA, NDS, N64, DOS, 3DS, MAME) ==================== */
.system-filter-bar {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 8px;
    margin-bottom: 12px;
    scrollbar-width: thin;
    scrollbar-color: var(--neon-cyan) #0d121c;
}

.system-filter-bar::-webkit-scrollbar {
    height: 4px;
}
.system-filter-bar::-webkit-scrollbar-thumb {
    background: var(--neon-cyan);
    border-radius: 4px;
}

.system-filter-chip {
    background: #111724;
    border: 1px solid #1f2d45;
    color: var(--text-muted);
    padding: 4px 10px;
    border-radius: 14px;
    font-size: 10px;
    font-weight: bold;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
}

.system-filter-chip:hover {
    color: #fff;
    border-color: var(--neon-cyan);
}

.system-filter-chip.active {
    background: #00f0ff;
    color: #000;
    border-color: #00f0ff;
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.6);
}

/* ==================== TABS & GOOGLE DRIVE CLOUD UI ==================== */
.tab-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.tab-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    padding: 6px 14px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.15s ease;
}

.tab-btn:hover {
    color: #fff;
}

.tab-btn.active {
    background: #182438;
    border-color: var(--neon-cyan);
    color: var(--neon-cyan);
    box-shadow: 0 0 8px rgba(0, 240, 255, 0.3);
}

.tab-content {
    display: none;
}

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

.gdrive-sync-box {
    background: rgba(14, 20, 32, 0.7);
    border: 1px solid #1f2d45;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 14px;
}

.gdrive-file-card {
    background: #101622;
    border: 1px solid #1c273a;
    border-radius: 6px;
    padding: 10px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    transition: all 0.15s ease;
}

.gdrive-file-card:hover {
    border-color: var(--neon-gold);
    background: #151d2d;
}

/* ==================== RESPONSIVE CHO MÀN HÌNH NHỎ ==================== */
@media (max-width: 600px) {
    .arcade-header {
        padding: 6px 10px;
    }
    .logo-title {
        font-size: 13px;
        letter-spacing: 1px;
    }
    .arcade-nav-btn {
        padding: 5px 8px;
        font-size: 11px;
    }
    .main-stage {
        padding: 6px;
    }
    .arcade-status-bar {
        font-size: 10px;
        padding: 4px 8px;
    }
}

@media (max-width: 600px) and (orientation: portrait) {
    .main-stage {
        padding: 6px;
        padding-bottom: 215px; /* Chừa không gian thoáng cho bàn điều khiển ảo ở dưới */
        justify-content: flex-start;
    }
    .screen-wrapper {
        margin-top: 8px;
    }
}

