/* ai.css - Cybernetic Gemini AI DJ Takeover HUD */

/* Header Trigger Button (Matches website's exact .header-action-btn.nav-tab-item standard) */
#ai-takeover-toggle-btn.nav-tab-item.engaged {
    border-color: #10b981;
    color: #a7f3d0;
    box-shadow: 0 0 14px rgba(16, 185, 129, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

#ai-takeover-toggle-btn.nav-tab-item.engaged .nav-tab-icon svg {
    stroke: #10b981;
    filter: drop-shadow(0 0 6px rgba(16, 185, 129, 0.8));
    animation: pulseIcon 1.5s infinite ease-in-out;
}

@keyframes pulseIcon {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.18); }
}

/* Inline API Key Card in AI Takeover HUD */
.ai-key-badge-header {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.6px;
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(6, 182, 212, 0.15);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.35);
}

.ai-key-badge-header.active {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border-color: rgba(16, 185, 129, 0.4);
}

.ai-key-card {
    background: rgba(2, 6, 23, 0.65);
    border: 1px solid rgba(56, 189, 248, 0.25);
    border-radius: 12px;
    padding: 14px 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ai-key-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-key-status-text {
    font-size: 10.5px;
    font-weight: 700;
    color: #94a3b8;
}

.ai-key-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.ai-key-field {
    flex: 1;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 8px 12px;
    color: #f8fafc;
    font-family: 'SF Mono', 'Courier New', monospace;
    font-size: 11.5px;
    outline: none;
    transition: border-color 0.2s;
}

.ai-key-field:focus {
    border-color: #38bdf8;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.25);
}

.ai-key-btn-primary {
    background: linear-gradient(135deg, #0284c7 0%, #2563eb 100%);
    border: none;
    color: #fff;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: 0.6px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.ai-key-btn-primary:hover {
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.4);
    transform: translateY(-1px);
}

.ai-key-btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.16);
    color: #cbd5e1;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 10.5px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.ai-key-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.ai-key-btn-danger {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: #f87171;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 10.5px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.ai-key-btn-danger:hover {
    background: rgba(239, 68, 68, 0.3);
}

.ai-key-feedback {
    font-size: 11px;
    font-weight: 600;
    min-height: 14px;
}

/* AI Command Center Drawer & Overlay */
.ai-takeover-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    z-index: 99999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.ai-takeover-drawer.closed {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.ai-takeover-drawer.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.ai-hud-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(3, 5, 8, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.ai-hud-panel {
    position: relative;
    width: 92%;
    max-width: 880px;
    max-height: 88vh;
    max-height: 88dvh;
    background: linear-gradient(180deg, var(--bg-surface-elevated, #131b29) 0%, var(--bg-surface, #0d121c) 100%);
    border: 1px solid var(--border-medium, rgba(255, 255, 255, 0.16));
    border-top: 1px solid var(--border-bright, rgba(0, 242, 254, 0.4));
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.85), 0 0 35px rgba(0, 242, 254, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: var(--text-primary, #ffffff);
    font-family: 'Rajdhani', var(--font-sans);
    z-index: 10;
}

/* Header */
.ai-hud-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 22px;
    background: rgba(2, 6, 23, 0.7);
    border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
    flex-shrink: 0;
}

.ai-hud-title-wrap {
    display: flex;
    align-items: center;
    gap: 14px;
}

.ai-pulse-core {
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--neon-cyan, #00f2fe) 0%, #2563eb 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 15px rgba(0, 242, 254, 0.6);
}

.ai-pulse-core.active .ai-pulse-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid var(--neon-cyan, #00f2fe);
    animation: ringExpand 2s infinite cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes ringExpand {
    0% { transform: scale(1); opacity: 0.9; }
    100% { transform: scale(2.2); opacity: 0; }
}

.ai-core-icon {
    font-size: 16px;
}

.ai-hud-title {
    font-family: 'Orbitron', 'Rajdhani', sans-serif;
    font-size: 16px;
    font-weight: 900;
    letter-spacing: 1.5px;
    background: linear-gradient(90deg, var(--neon-cyan, #00f2fe), var(--neon-magenta, #f72585));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.ai-hud-subtitle {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 2px;
}

.ai-hud-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-key-btn {
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #cbd5e1;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-key-btn:hover {
    border-color: #38bdf8;
    color: #f8fafc;
}

.ai-close-btn {
    background: var(--bg-surface, #0d121c);
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
    color: var(--text-secondary, #a0aec0);
    font-size: 14px;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.ai-close-btn:hover {
    background: rgba(255, 0, 85, 0.2);
    border-color: var(--neon-crimson, #ff0055);
    color: #fff;
}

/* Body */
.ai-hud-body {
    padding: 20px 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.ai-section-label {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1px;
    color: #38bdf8;
    margin-bottom: 8px;
}

/* Status Card */
.ai-status-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    background: rgba(2, 6, 23, 0.55);
    border: 1px solid rgba(56, 189, 248, 0.2);
    border-radius: 12px;
}

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

.ai-status-label {
    font-size: 11px;
    font-weight: 800;
    color: #64748b;
}

.ai-status-val {
    font-size: 13px;
    font-weight: 800;
    color: #38bdf8;
}

.ai-engage-main-btn {
    background: linear-gradient(135deg, #0284c7 0%, #2563eb 100%);
    border: none;
    color: #ffffff;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.8px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.35);
}

.ai-engage-main-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(2, 132, 199, 0.5);
}

.ai-engage-main-btn.engaged {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.4);
}

/* Prompt Section */
.ai-prompt-input-group {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.ai-prompt-input {
    flex: 1;
    background: rgba(2, 6, 23, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    padding: 10px 14px;
    color: #f8fafc;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}

.ai-prompt-input:focus {
    border-color: #38bdf8;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.2);
}

.ai-prompt-submit-btn {
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid rgba(56, 189, 248, 0.4);
    color: #38bdf8;
    padding: 0 18px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.8px;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-prompt-submit-btn:hover {
    background: rgba(56, 189, 248, 0.2);
    border-color: #38bdf8;
}

.ai-prompt-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ai-chip {
    font-size: 11px;
    font-weight: 600;
    color: #cbd5e1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 5px 11px;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-chip:hover {
    background: rgba(56, 189, 248, 0.15);
    border-color: rgba(56, 189, 248, 0.4);
    color: #38bdf8;
}

/* Presets Grid */
.ai-presets-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.ai-preset-card {
    background: rgba(2, 6, 23, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-preset-card:hover {
    background: rgba(15, 23, 42, 0.8);
    border-color: rgba(56, 189, 248, 0.35);
    transform: translateY(-2px);
}

.ai-preset-card.active {
    background: rgba(6, 182, 212, 0.12);
    border-color: #38bdf8;
    box-shadow: 0 0 14px rgba(6, 182, 212, 0.2);
}

.preset-name {
    font-size: 12px;
    font-weight: 800;
    color: #f8fafc;
    margin-bottom: 4px;
}

.preset-desc {
    font-size: 10.5px;
    color: #94a3b8;
    line-height: 1.35;
    margin-bottom: 6px;
}

.preset-bpm {
    font-size: 10px;
    font-weight: 700;
    color: #38bdf8;
}

/* Thought Log Stream */
.ai-thought-log {
    background: rgba(2, 6, 23, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    height: 170px;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-family: 'SF Mono', 'Courier New', monospace;
}

.log-empty {
    font-size: 11px;
    color: #64748b;
    font-style: italic;
    text-align: center;
    margin-top: 60px;
}

.ai-thought-item {
    display: flex;
    align-items: baseline;
    gap: 10px;
    font-size: 11px;
    line-height: 1.4;
    animation: fadeInLog 0.25s ease;
}

@keyframes fadeInLog {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.ai-thought-time {
    color: #64748b;
    font-size: 10px;
}

.ai-agent-badge {
    font-size: 9.5px;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.badge-conductor {
    background: rgba(147, 51, 234, 0.25);
    color: #c084fc;
    border: 1px solid rgba(147, 51, 234, 0.4);
}

.badge-dsp {
    background: rgba(6, 182, 212, 0.25);
    color: #38bdf8;
    border: 1px solid rgba(6, 182, 212, 0.4);
}

.badge-hype {
    background: rgba(249, 115, 22, 0.25);
    color: #fb923c;
    border: 1px solid rgba(249, 115, 22, 0.4);
}

.ai-thought-msg {
    color: #cbd5e1;
    word-break: break-word;
}

/* API Key Modal */
.ai-key-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(2, 6, 23, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 50;
}

.ai-key-modal-content {
    width: 90%;
    max-width: 440px;
    background: #0f172a;
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-radius: 14px;
    padding: 20px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7);
}

.ai-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.ai-modal-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 800;
    color: #f8fafc;
}

.ai-modal-close {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 14px;
    cursor: pointer;
}

.ai-modal-desc {
    font-size: 11.5px;
    color: #94a3b8;
    line-height: 1.45;
    margin-bottom: 14px;
}

.ai-key-input {
    width: 100%;
    box-sizing: border-box;
    background: rgba(2, 6, 23, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 10px 12px;
    color: #f8fafc;
    font-size: 12px;
    margin-bottom: 14px;
    outline: none;
}

.ai-key-input:focus {
    border-color: #38bdf8;
}

.ai-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.ai-save-key-btn {
    background: #0284c7;
    border: none;
    color: #fff;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 800;
    cursor: pointer;
}

.ai-clear-key-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #cbd5e1;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 11px;
    cursor: pointer;
}

/* Responsive Mobile Rules */
@media (max-width: 768px) {
    .ai-hud-panel {
        width: 96%;
        max-height: 94vh;
        max-height: 94dvh;
    }
    .ai-presets-grid {
        grid-template-columns: 1fr;
    }
    .ai-status-card {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
        text-align: center;
    }
    .ai-status-left {
        justify-content: center;
    }
    .ai-prompt-input-group {
        flex-direction: column;
    }
    .ai-prompt-submit-btn {
        padding: 10px;
    }
}

/* Landscape Mode on Phones (Fit to Canvas) */
@media (max-height: 520px) and (orientation: landscape) {
    .ai-hud-panel {
        max-height: 94dvh;
        width: 96%;
        max-width: 780px;
    }
    .ai-hud-header {
        padding: 8px 16px;
    }
    .ai-pulse-core {
        width: 26px;
        height: 26px;
    }
    .ai-core-icon {
        font-size: 13px;
    }
    .ai-hud-title {
        font-size: 13px;
    }
    .ai-hud-subtitle {
        display: none;
    }
    .ai-hud-body {
        padding: 10px 14px;
        gap: 10px;
    }
    .ai-status-card {
        padding: 8px 12px;
    }
    .ai-key-card {
        padding: 8px 12px;
        gap: 6px;
    }
    .ai-presets-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }
    .ai-preset-card {
        padding: 6px 8px;
    }
    .preset-desc {
        display: none;
    }
    .ai-thought-log {
        height: 80px;
    }
}
