/* =========================================
   ARSimulation.css - Main AR HUD and Canvas
   ========================================= */

/* --- VARIABLES --- */
:root {
    --bg-color: #0f172a; 
    --text-color: #f8fafc; 
    --primary-color: #0ea5e9; 
    --ar-btn-color: #2563eb;
    --ar-btn-hover: #1d4ed8; 
    --danger-color: #ef4444;
    --glass-bg: rgba(15, 23, 42, 0.85);
    --transition: 0.2s ease;
}

/* --- BASE STYLES --- */
body {
    background: var(--bg-color); 
    color: var(--text-color);
    font-family: 'Segoe UI', sans-serif; 
    margin: 0; 
    overflow-x: hidden;
}

h1 {
    font-weight: 300; 
    letter-spacing: 2px; 
    margin-bottom: 2rem;
    text-shadow: 0 0 10px rgba(14, 165, 233, 0.5); 
    width: 100%; 
    text-align: center;
}

.hidden { 
    display: none !important; 
}

/* --- WEBXR / THREE.JS CANVAS --- */
canvas { 
    position: fixed; 
    top: 0; 
    left: 0; 
    z-index: 1; 
    width: 100%; 
    height: 100%; 
    outline: none; 
}

/* --- THREE.JS AR BUTTON --- 
   Using 'body' to increase specificity instead of !important 
*/
body #ARButton {
    background: var(--ar-btn-color); 
    color: #ffffff; 
    border: none;
    border-radius: 8px; 
    padding: 14px 28px; 
    font-weight: bold;
    text-transform: uppercase; 
    box-shadow: 0 0 20px rgba(37, 99, 235, 0.6);
    position: absolute; 
    bottom: 50px; 
    left: 50%; 
    transform: translateX(-50%); 
    z-index: 100;
    cursor: pointer;
    transition: all 0.3s ease;
}

body #ARButton:hover { 
    background: var(--ar-btn-hover); 
    transform: translateX(-50%) scale(1.05); 
    box-shadow: 0 0 25px rgba(29, 78, 216, 0.8);
}

body #ARButton:disabled { 
    color: #94a3b8; 
    opacity: 0.5; 
    pointer-events: none; 
    box-shadow: none; 
}

/* --- SCENARIO SELECTION UI --- */
#scenario-select-wrapper {
    position: relative; 
    z-index: 2; 
    max-width: 400px; 
    margin: 40px auto; 
    text-align: center;
    background: var(--glass-bg); 
    backdrop-filter: blur(10px); 
    padding: 2rem; 
    border-radius: 12px; 
    border: 1px solid rgba(255, 255, 255, 0.15); 
}

#scenario-select-wrapper select option {
    background-color: var(--bg-color);
    color: var(--text-color);
}

#scenario-select-wrapper label { 
    display: block; 
    font-size: 1.1rem; 
    color: #cbd5e1; 
    margin-bottom: 15px; 
}

#scenario-select-wrapper select, 
#ai-chat-input {
    width: 100%; 
    padding: 10px 15px; 
    background: rgba(255, 255, 255, 0.05); 
    box-sizing: border-box;
    color: var(--text-color); 
    border: 1px solid #334155; 
    border-radius: 8px; 
    font: inherit; 
    transition: all var(--transition);
}

#scenario-select-wrapper select:focus, 
#ai-chat-input:focus { 
    border-color: var(--primary-color); 
    box-shadow: 0 0 10px rgba(14, 165, 233, 0.3); 
    outline: none; 
}

#scenario-wrapper {
    margin-top: 20px;
}

/* --- DEVICE NOT SUPPORTED WARNING --- */
#ar-not-supported {
    text-align: center;
    margin-top: 20px;
}

#qr-code {
    display: block;
    margin: 0 auto;
    max-width: 250px;
}

/* --- FULLSCREEN AR HUD CONTAINER --- */
#ar-container { 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100vw; 
    height: 100vh; 
    pointer-events: none; 
    z-index: 1000; 
}

#ar-container > * { 
    pointer-events: auto;
} 

#exit-ar-btn {
    position: absolute; 
    top: 80px; 
    right: 20px; 
    z-index: 1001; 
    width: 40px; 
    height: 40px;
    background: rgba(0, 0, 0, 0.6); 
    border: 1px solid rgba(255, 255, 255, 0.2); 
    border-radius: 8px;
    color: #cbd5e1; 
    font: 300 24px/1 inherit; 
    display: flex; 
    align-items: center; 
    justify-content: center;
    cursor: pointer; 
    backdrop-filter: blur(4px); 
    transition: all 0.3s ease;
}

#exit-ar-btn:hover { 
    background: rgba(220, 38, 38, 0.8); 
    border-color: #dc2626; 
    color: #fff; 
    box-shadow: 0 0 15px rgba(220, 38, 38, 0.6); 
    transform: rotate(90deg); 
}

/* --- AI CHAT CONTAINER --- */
#ai-container {
    position: absolute; 
    bottom: 30px; 
    left: 6%; 
    right: 6%; 
    z-index: 9999;
    background: var(--glass-bg); 
    border: 1px solid rgba(255, 255, 255, 0.15); 
    border-radius: 12px;
    backdrop-filter: blur(12px); 
    padding: 1.5rem; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.5); 
    display: flex; 
    flex-direction: column; 
    gap: 10px;
    transition: transform 0.3s ease-out; 
}

#ai-container.keyboard-open {
    transform: translateY(-310px); 
}

#hide-ai-btn {
    position: absolute; 
    top: -15px; 
    right: -10px; 
    width: 30px; 
    height: 30px; 
    z-index: 10002;
    background: #475569; 
    border: 1px solid #94a3b8; 
    border-radius: 50%; 
    color: #fff;
    font: bold 14px inherit; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    cursor: pointer; 
    transition: background 0.2s;
}

#hide-ai-btn:hover { 
    background: #64748b; 
}

#ai-response {
    margin: 10px 0 5px; 
    min-height: 50px; 
    max-height: 200px; 
    overflow-y: auto; 
    white-space: pre-wrap;
    background: rgba(0, 0, 0, 0.3); 
    color: #e2e8f0; 
    border-left: 3px solid var(--primary-color);
    border-radius: 8px; 
    padding: 12px; 
    font-size: 14px; 
    line-height: 1.5;
}

#ai-chat-input { 
    resize: none; 
}

#ai-submit-btn, 
#stt-btn {
    background: var(--primary-color); 
    color: #fff; 
    border: none; 
    border-radius: 8px; 
    padding: 10px;
    font: bold 15px inherit; 
    cursor: pointer; 
    transition: background 0.2s; 
    width: 60%; 
    margin: 8px auto 0; 
    display: block;
}

#ai-submit-btn:hover, 
#stt-btn:hover { 
    background: #0284c7; 
}

/* --- BUTTON LOADING STATES --- */
button:disabled, 
input:disabled, 
textarea:disabled { 
    opacity: 0.6; 
    cursor: not-allowed; 
    background: rgba(255,255,255,0.1) !important; 
}

#ai-submit-btn.loading { 
    background: #334155; 
    cursor: wait; 
}

/* --- VIRTUAL KEYBOARD --- */
body #keyboard-wrapper {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100vw;
    height: auto;
    display: none;
    z-index: 9999;
    background: #ececec;
    box-sizing: border-box;
    padding-bottom: env(safe-area-inset-bottom);
}

.fake-input {
    width: 100%;
    height: 40px;
    background: white;
    border: 1px solid #ccc;
    border-radius: 5px;
    padding: 10px;
    font-family: sans-serif;
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    text-align: left;
    appearance: none;
    touch-action: manipulation;
}

.fake-input:active {
    background-color: #f4f4f4;
}

/* Keyboard overrides using specificity */
body .simple-keyboard {
    font-size: 24px !important;
    height: auto; 
    box-sizing: border-box;
}

body #keyboard-wrapper, 
body .hg-theme-default, 
body .hg-button {
    color: #000000;
    font-family: sans-serif;
}

body .hg-button {
    height: 65px !important;
    margin: 2px !important;
    display: flex;
    align-items: center; 
    justify-content: center;
}

body .hg-row {
    height: auto; 
    display: flex;
}

body .simple-keyboard .hg-button-space {
    flex-grow: 4 !important;
}