/* ============================================================
   JARVIS AI ASSISTANT — Shared CSS
   All features opt-in via Settings toggles (default: off)
   ============================================================ */

/* ---------- Floating Mic Button ---------- */
.jarvis-mic-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid rgba(0,255,255,0.4);
    background: rgba(10,10,14,0.85);
    color: #00fff2;
    font-size: 26px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 12px rgba(0,255,255,0.2);
    transition: box-shadow 0.3s, border-color 0.3s, transform 0.15s;
}
.jarvis-mic-btn:hover {
    box-shadow: 0 0 20px rgba(0,255,255,0.4);
    border-color: rgba(0,255,255,0.7);
    transform: scale(1.08);
}
.jarvis-mic-btn.listening {
    border-color: #ff4444;
    color: #ff4444;
    box-shadow: 0 0 20px rgba(255,68,68,0.4);
    animation: jarvis-pulse 1.2s ease-in-out infinite;
}

@keyframes jarvis-pulse {
    0%, 100% { box-shadow: 0 0 12px rgba(255,68,68,0.3); }
    50% { box-shadow: 0 0 25px rgba(255,68,68,0.6); }
}

/* ---------- Voice Feedback Overlay ---------- */
.jarvis-voice-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0,0,0,0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}
.jarvis-voice-overlay.active {
    opacity: 1;
    pointer-events: auto;
}
.jarvis-voice-waveform {
    width: 120px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-bottom: 16px;
}
.jarvis-voice-waveform span {
    display: block;
    width: 4px;
    height: 20px;
    background: #00fff2;
    border-radius: 2px;
    animation: jarvis-wave 0.8s ease-in-out infinite;
}
.jarvis-voice-waveform span:nth-child(2) { animation-delay: 0.1s; height: 30px; }
.jarvis-voice-waveform span:nth-child(3) { animation-delay: 0.2s; height: 40px; }
.jarvis-voice-waveform span:nth-child(4) { animation-delay: 0.3s; height: 30px; }
.jarvis-voice-waveform span:nth-child(5) { animation-delay: 0.4s; }
@keyframes jarvis-wave {
    0%, 100% { transform: scaleY(0.4); }
    50% { transform: scaleY(1); }
}
.jarvis-voice-text {
    color: #00fff2;
    font-family: 'Courier New', monospace;
    font-size: 20px;
    max-width: 400px;
    text-align: center;
}

/* ---------- Status Ticker ---------- */
.jarvis-ticker {
    width: 100%;
    height: 28px;
    background: rgba(10,10,14,0.9);
    border-bottom: 1px solid rgba(0,255,255,0.15);
    overflow: hidden;
    position: relative;
    z-index: 100;
}
.jarvis-ticker-inner {
    display: inline-block;
    white-space: nowrap;
    font-family: 'Courier New', monospace;
    font-size: 18px;
    color: #00fff2;
    line-height: 28px;
    padding-left: 100%;
    animation: jarvis-scroll 30s linear infinite;
}
.jarvis-ticker-inner span {
    padding: 0 32px;
}
@keyframes jarvis-scroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-100%); }
}

/* ---------- HUD Widget ---------- */
.jarvis-hud {
    position: fixed;
    bottom: 80px;
    left: 16px;
    z-index: 9998;
    width: 260px;
    background: rgba(10,10,14,0.92);
    border: 1px solid rgba(0,255,255,0.25);
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 17px;
    color: #b0b0b0;
    box-shadow: 0 0 15px rgba(0,255,255,0.1);
    user-select: none;
    cursor: move;
}
.jarvis-hud-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    border-bottom: 1px solid rgba(0,255,255,0.15);
    color: #00fff2;
    font-size: 16px;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.jarvis-hud-collapse {
    background: none;
    border: none;
    color: #00fff2;
    cursor: pointer;
    font-size: 18px;
    padding: 0 2px;
}
.jarvis-hud-body {
    padding: 8px 10px;
    max-height: 200px;
    overflow-y: auto;
    transition: max-height 0.3s, padding 0.3s;
}
.jarvis-hud.collapsed .jarvis-hud-body {
    max-height: 0;
    padding: 0 10px;
    overflow: hidden;
}
.jarvis-hud-row {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.jarvis-hud-label {
    color: #888;
}
.jarvis-hud-value {
    color: #00ff88;
    font-variant-numeric: tabular-nums;
}
.jarvis-hud-value.warning { color: #ffaa00; }
.jarvis-hud-value.critical { color: #ff4444; }

/* ---------- Typewriter Container ---------- */
.jarvis-msg {
    font-family: 'Courier New', monospace;
    font-size: 18px;
    color: #00fff2;
    overflow: hidden;
}
.jarvis-msg .jarvis-cursor {
    display: inline-block;
    width: 7px;
    height: 14px;
    background: #00fff2;
    margin-left: 1px;
    vertical-align: text-bottom;
    animation: jarvis-blink 0.7s step-end infinite;
}
@keyframes jarvis-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* ---------- Color Wash Overlay ---------- */
.jarvis-color-wash {
    position: fixed;
    inset: 0;
    z-index: 9990;
    pointer-events: none;
    opacity: 0;
    transition: opacity 2s, background 2s;
}
.jarvis-color-wash.active { opacity: 1; }
.jarvis-color-wash.status-ok { background: radial-gradient(ellipse at center, rgba(0,255,136,0.04) 0%, transparent 70%); }
.jarvis-color-wash.status-warning { background: radial-gradient(ellipse at center, rgba(255,170,0,0.06) 0%, transparent 70%); }
.jarvis-color-wash.status-critical { background: radial-gradient(ellipse at center, rgba(255,68,68,0.06) 0%, transparent 70%); }

/* ---------- Data Rain Canvas ---------- */
.jarvis-rain-canvas {
    position: fixed;
    inset: 0;
    z-index: 9989;
    pointer-events: none;
    opacity: 0.35;
}

/* ---------- Shift Awareness Modal ---------- */
.jarvis-shift-modal {
    position: fixed;
    inset: 0;
    z-index: 10001;
    background: rgba(0,0,0,0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s;
}
.jarvis-shift-modal.active {
    opacity: 1;
    pointer-events: auto;
}
.jarvis-shift-card {
    background: rgba(10,10,14,0.95);
    border: 1px solid rgba(0,255,255,0.3);
    border-radius: 12px;
    padding: 28px 32px;
    max-width: 420px;
    width: 90%;
    color: #e0e0e0;
    font-family: 'Courier New', monospace;
    box-shadow: 0 0 30px rgba(0,255,255,0.15);
}
.jarvis-shift-card h3 {
    color: #00fff2;
    font-size: 22px;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.jarvis-shift-card p {
    font-size: 19px;
    line-height: 1.6;
    margin-bottom: 8px;
}
.jarvis-shift-card .jarvis-shift-dismiss {
    display: block;
    margin: 16px auto 0;
    padding: 8px 24px;
    background: rgba(0,255,255,0.1);
    border: 1px solid rgba(0,255,255,0.3);
    border-radius: 6px;
    color: #00fff2;
    font-family: 'Courier New', monospace;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.2s;
}
.jarvis-shift-card .jarvis-shift-dismiss:hover {
    background: rgba(0,255,255,0.2);
}

/* ---------- Biometric Auth Visualization ---------- */
.jarvis-bio-overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.4s;
}
.jarvis-bio-overlay.active {
    opacity: 1;
}
.jarvis-bio-ring {
    width: 80px;
    height: 80px;
    border: 3px solid rgba(0,255,255,0.6);
    border-radius: 50%;
    position: relative;
    animation: jarvis-bio-scan 1.5s ease-in-out infinite;
}
.jarvis-bio-ring::before {
    content: '';
    position: absolute;
    inset: 6px;
    border: 2px dashed rgba(0,255,255,0.3);
    border-radius: 50%;
    animation: jarvis-bio-rotate 2s linear infinite;
}
.jarvis-bio-ring::after {
    content: '\1F5B6'; /* fingerprint emoji */
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 34px;
    filter: drop-shadow(0 0 6px rgba(0,255,255,0.5));
}
@keyframes jarvis-bio-scan {
    0%, 100% { box-shadow: 0 0 10px rgba(0,255,255,0.2); }
    50% { box-shadow: 0 0 25px rgba(0,255,255,0.5); }
}
@keyframes jarvis-bio-rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.jarvis-bio-overlay.success .jarvis-bio-ring {
    border-color: #00ff88;
    animation: none;
    box-shadow: 0 0 30px rgba(0,255,136,0.5);
}
.jarvis-bio-overlay.success .jarvis-bio-ring::before {
    border-color: rgba(0,255,136,0.3);
    animation: none;
}
.jarvis-bio-overlay.fail .jarvis-bio-ring {
    border-color: #ff4444;
    animation: none;
    box-shadow: 0 0 30px rgba(255,68,68,0.5);
}
.jarvis-bio-overlay.fail .jarvis-bio-ring::before {
    border-color: rgba(255,68,68,0.3);
    animation: none;
}

/* ---------- Settings Section ---------- */
.jarvis-settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 20px;
}
.jarvis-settings-grid .flex {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ---------- Portal-specific overrides ---------- */

/* NVR — dark only, align with NVR styles */
#nvrApp .jarvis-hud {
    border-color: rgba(0,255,255,0.2);
}
#nvrApp .jarvis-ticker {
    background: rgba(18,18,22,0.95);
}
#nvrApp .jarvis-mic-btn {
    bottom: 16px;
    right: 16px;
}

/* Situation Room — align with SR tactical theme */
#appShell.sr-app .jarvis-hud,
.sr-app .jarvis-hud {
    border-color: rgba(0,255,242,0.2);
}
.sr-app .jarvis-mic-btn {
    bottom: 16px;
    right: 16px;
}

/* Light theme adjustments (User/Admin only) */
[data-theme="light"] .jarvis-ticker {
    background: rgba(245,245,248,0.95);
    border-bottom-color: rgba(0,100,120,0.15);
}
[data-theme="light"] .jarvis-ticker-inner {
    color: #006878;
}
[data-theme="light"] .jarvis-hud {
    background: rgba(245,245,248,0.95);
    border-color: rgba(0,100,120,0.2);
    color: #333;
}
[data-theme="light"] .jarvis-hud-header {
    color: #006878;
    border-bottom-color: rgba(0,100,120,0.15);
}
[data-theme="light"] .jarvis-hud-collapse {
    color: #006878;
}
[data-theme="light"] .jarvis-hud-label { color: #666; }
[data-theme="light"] .jarvis-hud-value { color: #008855; }
[data-theme="light"] .jarvis-hud-value.warning { color: #bb7700; }
[data-theme="light"] .jarvis-hud-value.critical { color: #cc3333; }
[data-theme="light"] .jarvis-mic-btn {
    background: rgba(245,245,248,0.95);
    border-color: rgba(0,100,120,0.3);
    color: #006878;
}
[data-theme="light"] .jarvis-mic-btn:hover {
    border-color: rgba(0,100,120,0.6);
    box-shadow: 0 0 15px rgba(0,100,120,0.2);
}
[data-theme="light"] .jarvis-msg { color: #006878; }
[data-theme="light"] .jarvis-msg .jarvis-cursor { background: #006878; }
