/* ===== QuestCity V4 - Styles UI Avancés ===== */
/* Optimisé Meta Quest 3 : gros boutons, contraste élevé, glassmorphism,
   panneau d'inspection, tutoriel interactif V4, missions, niveau de ville,
   barre d'outils avec cadenas, animations de récompense */

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-user-select: none; user-select: none; }

html, body {
    width: 100%; height: 100%; overflow: hidden;
    background: #000; font-family: 'Arial', 'Helvetica', sans-serif; color: #fff;
}

#game-container { position: fixed; top: 0; left: 0; width: 100%; height: 100%; }
#game-container canvas { display: block; }

/* ===== Panels ===== */
.ui-panel {
    position: fixed;
    background: rgba(15, 20, 35, 0.85);
    border: 1.5px solid rgba(100, 150, 255, 0.35);
    border-radius: 12px;
    padding: 10px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
    z-index: 100;
}

/* ===== Info panel (haut centre) ===== */
#info-panel {
    top: 12px; left: 50%; transform: translateX(-50%);
    display: flex; gap: 16px; padding: 8px 16px;
    flex-wrap: wrap; justify-content: center; max-width: 95vw;
}

.info-item { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.info-label { font-size: 16px; }
.info-value { font-size: 14px; font-weight: bold; text-shadow: 0 2px 4px rgba(0,0,0,0.9); transition: transform 0.15s, color 0.15s; }

#info-loan { color: #ffa500; font-size: 12px; }
#info-event { color: #ff6600; font-size: 13px; font-weight: bold; animation: pulse 1s infinite; }

/* V4 : Animation argent */
.info-value.money-gain { animation: moneyGain 0.8s ease; }
.info-value.money-loss { animation: moneyLoss 0.8s ease; }
@keyframes moneyGain { 0% { transform: scale(1); color: #00ff66; } 50% { transform: scale(1.2); color: #00ff66; } 100% { transform: scale(1); } }
@keyframes moneyLoss { 0% { transform: scale(1); color: #ff3333; } 50% { transform: scale(1.2); color: #ff3333; } 100% { transform: scale(1); } }

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

/* ===== Boutons flottants ===== */
#floating-buttons {
    position: fixed; top: 12px; right: 12px;
    display: flex; flex-direction: column; gap: 6px; z-index: 100;
}

.float-btn {
    background: rgba(15, 20, 35, 0.85);
    border: 1.5px solid rgba(100, 150, 255, 0.35);
    border-radius: 10px;
    color: #fff; padding: 10px; cursor: pointer;
    font-size: 20px; width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s; backdrop-filter: blur(10px);
}

.float-btn:hover { background: rgba(50, 80, 120, 0.9); border-color: rgba(100, 200, 255, 0.7); transform: scale(1.05); }

/* ===== Mini-carte ===== */
#minimap-container {
    position: fixed; top: 12px; left: 12px;
    padding: 4px; border-radius: 8px;
}

#minimap { display: block; border-radius: 4px; }

/* ===== Catégories ===== */
#category-bar {
    bottom: 80px; left: 50%; transform: translateX(-50%);
    display: flex; gap: 4px; padding: 4px;
}

.cat-btn {
    background: rgba(30, 40, 60, 0.9);
    border: 1px solid rgba(100, 150, 255, 0.2);
    border-radius: 8px;
    color: #fff; padding: 8px 12px; cursor: pointer;
    font-size: 18px; transition: all 0.2s;
    min-width: 40px; min-height: 40px;
}

.cat-btn:hover { background: rgba(50, 80, 120, 0.9); }
.cat-btn.active { background: rgba(60, 120, 200, 0.9); border-color: #6ad; box-shadow: 0 0 10px rgba(80, 160, 255, 0.4); }

/* ===== Toolbar ===== */
#toolbar {
    bottom: 12px; left: 50%; transform: translateX(-50%);
    display: flex; gap: 6px; padding: 8px;
    max-width: 95vw; flex-wrap: wrap; justify-content: center;
}

.tool-btn {
    background: rgba(30, 40, 60, 0.9);
    border: 1.5px solid rgba(100, 150, 255, 0.25);
    border-radius: 10px; color: #fff;
    padding: 8px 10px; cursor: pointer; font-size: 20px;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    transition: all 0.2s; min-width: 60px; min-height: 60px;
}

.tool-btn span { font-size: 10px; font-weight: bold; text-shadow: 0 1px 2px rgba(0,0,0,0.8); }

/* V4 : Coût de l'outil en bas du bouton */
.tool-cost { font-size: 9px !important; color: #ffdd44; opacity: 0.8; }

/* V4 : Outil verrouillé */
.tool-btn.locked { opacity: 0.4; filter: grayscale(0.7); }
.tool-btn.locked:hover { background: rgba(60, 30, 30, 0.9); border-color: rgba(200, 50, 50, 0.4); }

.tool-btn:hover { background: rgba(50, 80, 120, 0.9); border-color: rgba(100, 200, 255, 0.6); }
.tool-btn.active { background: rgba(60, 120, 200, 0.9); border-color: #6ad; box-shadow: 0 0 12px rgba(80, 160, 255, 0.5); }

/* ===== Contrôles temps ===== */
#time-controls {
    bottom: 12px; right: 12px;
    display: flex; gap: 4px; padding: 4px;
}

.time-btn {
    background: rgba(30, 40, 60, 0.9);
    border: 1.5px solid rgba(100, 150, 255, 0.25);
    border-radius: 8px; color: #fff;
    padding: 8px 10px; cursor: pointer; font-size: 16px;
    transition: all 0.2s; min-width: 44px; min-height: 44px;
}

.time-btn:hover { background: rgba(50, 80, 120, 0.9); }
.time-btn.active { background: rgba(60, 120, 200, 0.9); border-color: #6ad; }

/* ===== Panels (taxes, budget, stats, advisor) ===== */
#tax-panel, #budget-panel, #stats-panel, #advisor-panel {
    top: 70px; right: 12px; width: 300px; max-height: 80vh; overflow-y: auto;
}

.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.panel-header h3 { font-size: 16px; }

.close-btn {
    background: rgba(200, 50, 50, 0.8); border: none; border-radius: 6px;
    color: #fff; width: 28px; height: 28px; font-size: 14px; cursor: pointer;
}

.tax-row, .budget-row { margin-bottom: 12px; }
.tax-row label, .budget-row label { display: block; font-size: 14px; margin-bottom: 6px; }

.tax-slider {
    width: 100%; height: 30px; -webkit-appearance: none; appearance: none;
    background: rgba(50, 60, 80, 0.6); border-radius: 8px; outline: none;
}

.tax-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 26px; height: 26px; background: #4a90d9; border-radius: 50%; cursor: pointer; border: 2px solid #fff; }
.tax-slider::-moz-range-thumb { width: 26px; height: 26px; background: #4a90d9; border-radius: 50%; cursor: pointer; border: 2px solid #fff; }

.panel-divider { height: 1px; background: rgba(100, 150, 255, 0.2); margin: 12px 0; }

.loan-row { display: flex; gap: 8px; }
.action-btn {
    flex: 1; background: rgba(50, 80, 120, 0.9); border: 1px solid rgba(100, 150, 255, 0.3);
    border-radius: 8px; color: #fff; padding: 10px; cursor: pointer; font-size: 13px;
}
.action-btn:hover { background: rgba(60, 100, 140, 0.9); }

/* ===== Stats ===== */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
.stat-row { display: flex; justify-content: space-between; font-size: 13px; padding: 2px 0; }
.stat-row span:first-child { color: #aacccc; }
.stat-row span:last-child { font-weight: bold; }
.stat-row .danger { color: #ff4444; }

.chart-container { background: rgba(0,0,0,0.3); border-radius: 6px; padding: 4px; }
.pie-container { display: flex; justify-content: center; padding: 4px; }

/* ===== Conseiller ===== */
.advisor-text { font-size: 14px; line-height: 1.4; padding: 8px; background: rgba(50, 70, 100, 0.3); border-radius: 8px; }

/* ===== Messages ===== */
#message-log {
    position: fixed; top: 80px; left: 170px; z-index: 100;
    display: flex; flex-direction: column; gap: 6px; max-width: 300px;
}

.game-message {
    background: rgba(15, 20, 35, 0.92);
    border-left: 3px solid #4a90d9; border-radius: 8px;
    padding: 8px 12px; font-size: 13px; color: #fff;
    backdrop-filter: blur(8px);
    animation: slideIn 0.3s ease, fadeOut 0.5s ease 5.5s forwards;
    display: flex; align-items: center; gap: 6px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

.msg-icon { font-size: 16px; }
.game-message.warning { border-left-color: #ffa500; }
.game-message.success { border-left-color: #00ff66; }
.game-message.danger { border-left-color: #ff3333; }

/* V4 : Notification de mission (fond doré) */
.game-message.mission {
    border-left-color: #ffd700;
    background: rgba(35, 25, 5, 0.92);
    animation: slideIn 0.3s ease, missionPulse 0.5s ease 0s 3, fadeOut 0.5s ease 6s forwards;
}
@keyframes missionPulse { 0%,100% { box-shadow: 0 0 5px rgba(255,215,0,0.3); } 50% { box-shadow: 0 0 20px rgba(255,215,0,0.7); } }

/* V4 : Notification d'incendie (fond rouge clignotant) */
.game-message.fire-alert {
    border-left-color: #ff3333;
    background: rgba(40, 10, 10, 0.92);
    animation: slideIn 0.3s ease, fireBlink 0.5s ease 0s 6, fadeOut 0.5s ease 6s forwards;
}
@keyframes fireBlink { 0%,100% { background: rgba(40,10,10,0.92); } 50% { background: rgba(80,20,20,0.92); } }

@keyframes slideIn { from { transform: translateX(-120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; transform: translateX(-20%); } }

/* ===== Tooltip ===== */
.tooltip {
    position: fixed; pointer-events: none; z-index: 200;
    background: rgba(0, 0, 0, 0.85); color: #fff; padding: 4px 10px;
    border-radius: 6px; font-size: 12px; display: none;
    border: 1px solid rgba(100, 150, 255, 0.4); white-space: nowrap;
}

/* ===== Panneau d'inspection ===== */
#inspection-panel {
    top: 70px; left: 12px; width: 280px; max-height: 70vh; overflow-y: auto;
}

.inspect-content { padding: 4px; }
.inspect-grid { display: grid; grid-template-columns: 1fr; gap: 4px; }

/* ===== V4 : Tutoriel interactif ===== */
.tutorial-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.4); z-index: 500;
    pointer-events: auto;
}

.tutorial-highlight {
    position: fixed;
    border: 3px solid #ffcc00;
    border-radius: 12px;
    box-shadow: 0 0 20px rgba(255, 204, 0, 0.6);
    z-index: 501;
    pointer-events: none;
    animation: highlightPulse 1.5s ease infinite;
}

.tutorial-highlight-tool {
    border-color: #00ff66;
    box-shadow: 0 0 25px rgba(0, 255, 100, 0.7);
}

@keyframes highlightPulse {
    0%, 100% { box-shadow: 0 0 20px rgba(255, 204, 0, 0.6); }
    50% { box-shadow: 0 0 35px rgba(255, 204, 0, 0.9); }
}

/* V4 : Flèche animée pointant vers l'outil */
.tutorial-arrow {
    position: fixed;
    z-index: 502;
    font-size: 30px;
    pointer-events: none;
    animation: arrowBounce 0.8s ease infinite;
}
.tutorial-arrow::before {
    content: '⬇️';
    display: block;
}

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

/* V4 : Bouton "Passer" en haut à droite */
.tutorial-skip-btn {
    position: fixed;
    top: 15px; right: 15px;
    z-index: 503;
    background: rgba(200, 50, 50, 0.85);
    border: 1.5px solid rgba(255, 100, 100, 0.5);
    border-radius: 10px;
    color: #fff;
    padding: 10px 16px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    backdrop-filter: blur(10px);
    transition: all 0.2s;
}
.tutorial-skip-btn:hover { background: rgba(220, 60, 60, 1); transform: scale(1.05); }

/* V4 : Bulle de tutoriel en bas-centre */
.tutorial-bubble-bottom {
    position: fixed;
    bottom: 130px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 20, 35, 0.95);
    border: 2px solid #ffcc00;
    border-radius: 14px;
    padding: 16px 24px;
    max-width: 500px;
    z-index: 502;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 30px rgba(0,0,0,0.8);
    text-align: center;
}

.tutorial-bubble-bottom p {
    font-size: 16px; line-height: 1.5; margin-bottom: 10px; color: #fff;
}

.tutorial-step-num {
    font-size: 12px; color: #ffcc00; font-weight: bold; margin-bottom: 6px;
}

.tutorial-hint {
    font-size: 13px; color: #aaa; font-style: italic;
}

.tutorial-actions {
    margin-top: 8px;
}

/* Ancien style tutoriel (compatibilité) */
.tutorial-bubble {
    position: fixed;
    background: rgba(15, 20, 35, 0.95);
    border: 2px solid #ffcc00;
    border-radius: 12px;
    padding: 16px;
    max-width: 350px;
    z-index: 502;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 30px rgba(0,0,0,0.8);
}

.tutorial-bubble p {
    font-size: 14px; line-height: 1.5; margin-bottom: 12px; color: #fff;
}

.tutorial-next-btn {
    background: rgba(60, 120, 200, 0.9);
    border: 1px solid rgba(100, 150, 255, 0.5);
    border-radius: 8px; color: #fff;
    padding: 10px 20px; cursor: pointer; font-size: 14px; font-weight: bold;
}
.tutorial-next-btn:hover { background: rgba(80, 140, 220, 1); transform: scale(1.05); }

/* ===== V4 : Panneau des missions ===== */
.mission-panel {
    top: 70px; right: 12px;
    width: 260px;
    max-height: 60vh;
    overflow-y: auto;
}

#mission-list {
    display: flex; flex-direction: column; gap: 8px;
}

.mission-item {
    background: rgba(30, 40, 60, 0.6);
    border: 1px solid rgba(100, 150, 255, 0.2);
    border-radius: 8px;
    padding: 8px;
    transition: all 0.3s;
}

.mission-item:hover {
    border-color: rgba(255, 204, 0, 0.4);
}

.mission-all-done {
    text-align: center;
    color: #88ff88;
    font-size: 13px;
    padding: 12px;
}

.mission-header {
    display: flex; align-items: center; gap: 6px;
    margin-bottom: 6px;
}

.mission-icon { font-size: 16px; }
.mission-text { font-size: 13px; color: #fff; }

.mission-bar {
    height: 6px;
    background: rgba(50, 60, 80, 0.6);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 4px;
}

.mission-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #ffcc00, #ffd700);
    border-radius: 3px;
    transition: width 0.5s ease;
}

.mission-reward {
    font-size: 11px;
    color: #ffd700;
    font-weight: bold;
}

/* ===== V4 : Indicateur de niveau de ville ===== */
.city-level-indicator {
    position: fixed;
    top: 12px;
    left: 175px;
    z-index: 100;
    background: rgba(15, 20, 35, 0.85);
    border: 1.5px solid rgba(255, 204, 0, 0.4);
    border-radius: 10px;
    padding: 6px 12px;
    font-size: 14px;
    font-weight: bold;
    color: #ffd700;
    backdrop-filter: blur(10px);
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
    transition: all 0.3s;
}

.city-level-indicator:hover {
    border-color: rgba(255, 204, 0, 0.8);
    box-shadow: 0 0 15px rgba(255, 204, 0, 0.3);
}

/* ===== FPS ===== */
#fps-counter {
    position: fixed; bottom: 70px; left: 60px;
    background: rgba(0, 0, 0, 0.7); color: #0f0;
    padding: 4px 8px; font-family: monospace; font-size: 12px; border-radius: 6px;
    z-index: 100;
}

/* ===== Loading ===== */
#loading-screen {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(135deg, #0a1525, #1a2a4a, #0a1525);
    display: flex; align-items: center; justify-content: center; z-index: 9999;
    transition: opacity 0.5s;
}

#loading-screen.hidden { opacity: 0; pointer-events: none; }
.loading-content { text-align: center; }
.loading-content h1 { font-size: 42px; margin-bottom: 16px; text-shadow: 0 0 20px rgba(100, 150, 255, 0.6); }
.loading-content p { font-size: 16px; margin-bottom: 16px; color: #888; }

.loading-bar { width: 280px; height: 6px; background: rgba(50, 80, 120, 0.4); border-radius: 3px; overflow: hidden; margin: 0 auto; }
.loading-progress { width: 0%; height: 100%; background: linear-gradient(90deg, #4a90d9, #66ccff); border-radius: 3px; transition: width 0.3s; }

/* ===== Hidden ===== */
.hidden { display: none !important; }

/* ===== Responsive ===== */
@media (max-width: 1280px) {
    .tool-btn { min-width: 50px; min-height: 50px; font-size: 16px; }
    .info-value { font-size: 12px; } .info-label { font-size: 14px; }
    .float-btn { width: 38px; height: 38px; font-size: 16px; }
    #minimap { width: 120px; height: 120px; }
    .mission-panel { width: 220px; }
    .city-level-indicator { font-size: 12px; padding: 4px 8px; }
}

@media (max-width: 800px) {
    #toolbar { gap: 3px; padding: 4px; }
    .tool-btn { min-width: 44px; min-height: 44px; font-size: 14px; padding: 4px 6px; }
    .tool-btn span { font-size: 8px; }
    .tool-cost { font-size: 7px !important; }
    #info-panel { gap: 8px; padding: 6px 8px; }
    .info-value { font-size: 11px; } .info-label { font-size: 12px; }
    #minimap { width: 100px; height: 100px; }
    #tax-panel, #budget-panel, #stats-panel, #advisor-panel { width: 260px; }
    #message-log { left: 110px; max-width: 200px; font-size: 11px; }
    .cat-btn { min-width: 36px; min-height: 36px; font-size: 14px; padding: 6px; }
    #inspection-panel { width: 240px; }
    .tutorial-bubble { max-width: 280px; padding: 12px; }
    .tutorial-bubble p { font-size: 12px; }
    .tutorial-bubble-bottom { max-width: 90vw; padding: 12px 16px; }
    .tutorial-bubble-bottom p { font-size: 14px; }
    .mission-panel { width: 200px; top: 60px; }
    .city-level-indicator { left: 110px; font-size: 11px; }
}