/* =========================================
   ARSimulation.css - Main AR HUD and Canvas
   ========================================= */

/* Shared variables and body base styles live in css/base.css, loaded by
   templates/head_content.php on every page. */

/* --- AR-SPECIFIC STYLES --- */

main {
    padding: 24px 18px 48px;
}

h1 {
    color: var(--text-strong);
    font-weight: 800;
    font-size: clamp(1.75rem, 6vw, 2.5rem);
    letter-spacing: -0.02em;
    margin: 1rem 0 2rem;
    text-align: center;
    width: 100%;
}

.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 --- 
   Mounted inside #scenario-select-wrapper (see ARSceneManager.setupARButton),
   centered directly below the version selector.
   Using 'body' to increase specificity instead of !important 
*/
body #ARButton, body #ar-session-error button {
    /* Flex centering: Chrome mis-centers wrapped text inside plain buttons. */
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px auto 0;
    text-align: center;
    background: var(--ar-btn-color); 
    color: var(--primary-contrast); 
    border: none;
    border-radius: 12px; 
    padding: 14px 28px; 
    font-weight: 800;
    text-transform: uppercase; 
    letter-spacing: 0.06em;
    box-shadow: 0 10px 30px rgba(56, 189, 248, 0.35);
    cursor: pointer;
    transition: all 0.3s ease;
}

body #ARButton:hover, body #ar-session-error button:hover { 
    background: var(--ar-btn-hover); 
    transform: scale(1.05); 
    box-shadow: 0 12px 35px rgba(125, 211, 252, 0.45);
}

body #ARButton:disabled, body #ar-session-error button:disabled { 
    color: #94a3b8; 
    opacity: 0.5; 
    pointer-events: none; 
    box-shadow: none; 
}

#ar-session-error {
    margin: 14px auto 0;
    max-width: 340px;
    text-align: center;
    color: #fca5a5;
    font-size: 0.9rem;
}

/* --- SCENARIO SELECTION UI --- */
#scenario-select-wrapper {
    position: relative; 
    z-index: 2; 
    max-width: 400px; 
    margin: 40px auto; 
    text-align: center;
    background: var(--card-bg); 
    backdrop-filter: blur(10px); 
    padding: 2rem; 
    border-radius: 16px; 
    border: 1px solid var(--card-border); 
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.2); 
}

#scenario-select-wrapper select option {
    background-color: #0f1d2e;
    color: var(--text-color);
}

#scenario-select-wrapper label { 
    display: block; 
    font-size: 1.05rem; 
    font-weight: 600;
    color: var(--text-strong); 
    margin-bottom: 15px; 
}

#scenario-select-wrapper select, 
#ai-chat-input {
    width: 100%; 
    padding: 11px 15px; 
    background: rgba(7, 17, 31, 0.6); 
    box-sizing: border-box;
    color: var(--text-color); 
    border: 1px solid var(--card-border); 
    border-radius: 10px; 
    font: inherit; 
    transition: all var(--transition);
}

#scenario-select-wrapper select:hover, 
#ai-chat-input:hover { 
    border-color: #35506b; 
}

#scenario-select-wrapper select:focus, 
#ai-chat-input:focus { 
    border-color: var(--primary-color); 
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2); 
    outline: none; 
}

#scenario-wrapper {
    margin-top: 20px;
}

.ar-help {
    margin: 14px 0 0;
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.6;
}

/* --- DEVICE NOT SUPPORTED WARNING --- */
#ar-not-supported {
    max-width: 400px;
    margin: 20px auto;
    padding: 22px;
    text-align: center;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.2);
}

#ar-not-supported p {
    color: var(--text-muted);
    line-height: 1.6;
}

#qr-code {
    display: block;
    margin: 0 auto;
    max-width: 250px;
    padding: 12px;
    background: #f8fafc;
    border-radius: 16px;
}

/* --- 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(7, 17, 31, 0.6); 
    border: 1px solid rgba(125, 211, 252, 0.25); 
    border-radius: 12px;
    color: var(--text-color); 
    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: 12px;
    max-height: calc(100% - 24px);
    overflow-y: auto;
    box-sizing: border-box;
    left: 6%; 
    right: 6%; 
    z-index: 9999;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.08));
    -webkit-backdrop-filter: blur(22px) saturate(180%);
    backdrop-filter: blur(22px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.32);
    border-radius: 22px;
    padding: 14px;
    box-shadow:
        0 18px 45px rgba(0, 0, 0, 0.28),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
    display: flex; 
    flex-direction: column; 
    gap: 10px;
}


#hide-ai-btn {
    position: absolute; 
    top: 8px;
    right: 8px;
    width: 26px; 
    height: 26px; 
    z-index: 10002;
    background: rgba(255, 255, 255, 0.55);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.65);
    border-radius: 50%; 
    color: #111827;
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    display: flex; 
    align-items: center; 
    justify-content: center; 
    cursor: pointer; 
    transition: background 0.2s;
}

#hide-ai-btn:hover { 
    background: rgba(255, 255, 255, 0.8);
}

#ai-response {
    margin: 24px 0 0; 
    min-height: 50px; 
    max-height: 200px; 
    overflow-y: auto; 
    white-space: pre-wrap;
    background: #fff;
    color: #111827; 
    border: 1px solid rgba(255, 255, 255, 0.65);
    border-radius: 14px; 
    padding: 12px 14px; 
    font-size: 14px; 
    line-height: 1.5;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

#ai-chat-input {
    background: #fff;
    color: #111827;
    border: 1px solid rgba(255, 255, 255, 0.65);
    border-radius: 14px;
    padding: 10px 14px;
    font-size: 16px;
    flex-shrink: 0;
    resize: none; 
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

#ai-chat-input::placeholder {
    color: #6b7280;
}

#ai-chat-input:hover {
    border-color: rgba(255, 255, 255, 0.9);
}

#ai-chat-input:focus {
    border-color: rgba(255, 255, 255, 0.95);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.28);
    outline: none;
}

.ai-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

#ai-submit-btn, 
#stt-btn {
    flex: 1 1 0;
    min-width: 0;
    border-radius: 12px; 
    padding: 11px 12px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer; 
    transition: background var(--transition), border-color var(--transition); 
    width: auto; 
    margin: 0; 
    display: block;
}

#ai-submit-btn {
    background: var(--primary-color); 
    color: #000;
    border: 1px solid var(--primary-color);
}

#stt-btn {
    background: rgba(255, 255, 255, 0.55); 
    color: #111827;
    border: 1px solid rgba(255, 255, 255, 0.65);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

#tts-toggle-btn {
    flex: 0 0 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin: 0;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.65);
    border-radius: 50%;
    color: #111827;
    background: rgba(255, 255, 255, 0.55);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
}

#tts-toggle-btn[aria-pressed="true"] {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: var(--primary-contrast);
}

#tts-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.8);
}

#ai-submit-btn:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

#stt-btn:hover {
    background: rgba(255, 255, 255, 0.78);
}

/* --- 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:disabled,
#stt-btn:disabled,
#tts-toggle-btn:disabled {
    color: rgba(17, 24, 39, 0.45);
}

#ai-submit-btn.loading { 
    background: #26374b; 
    cursor: wait; 
}
