/* ═══════════════════════════════════════════════════════════════
   AI Mobile & Planning Panel Styles
   Sprint 13B-E: Planning Assistant Panel
   Sprint 13B-F: Voice Command & Mobile Optimization
   Uses CSS custom properties from main.css
   ═══════════════════════════════════════════════════════════════ */

/* ── Planning Panel (Side Panel) ────────────────────────────── */

.planning-panel {
    position: fixed;
    right: 0;
    top: 0;
    width: 400px;
    height: 100vh;
    background: var(--bg-white, #ffffff);
    box-shadow: -2px 0 16px rgba(0, 0, 0, 0.12);
    z-index: 900;
    flex-direction: column;
    font-family: inherit;
    display: flex;
}

.planning-panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-light, #f8fafc);
    flex-shrink: 0;
}

.planning-panel-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-dark, #1e293b);
}

.planning-panel-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: var(--text-light, #64748b);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm, 4px);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

.planning-panel-close:hover {
    background: var(--bg-hover, #f1f5f9);
    color: var(--text-dark, #1e293b);
}

.planning-chat {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.planning-input-area {
    padding: 16px;
    border-top: 1px solid var(--border-color, #e2e8f0);
    background: var(--bg-light, #f8fafc);
    flex-shrink: 0;
}

.planning-input-row {
    display: flex;
    gap: 8px;
}

.planning-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: var(--radius-md, 6px);
    font-size: 14px;
    color: var(--text-dark, #1e293b);
    background: var(--bg-white, #ffffff);
    outline: none;
    transition: border-color 0.15s;
}

.planning-input:focus {
    border-color: var(--primary-color, #2563eb);
    box-shadow: 0 0 0 2px var(--primary-light, rgba(37, 99, 235, 0.08));
}

.planning-input:disabled {
    background: var(--bg-light, #f8fafc);
    opacity: 0.6;
}

.planning-send-btn {
    padding: 10px 20px;
    background: var(--primary-color, #2563eb);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-md, 6px);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.planning-send-btn:hover {
    background: var(--primary-dark, #1e40af);
}

.planning-send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ── Chat Messages ──────────────────────────────────────────── */

.planning-message {
    padding: 10px 14px;
    border-radius: var(--radius-lg, 8px);
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.planning-message-user {
    background: var(--primary-light, rgba(37, 99, 235, 0.08));
    color: var(--primary-dark, #1e40af);
    align-self: flex-end;
    max-width: 85%;
}

.planning-message-assistant {
    background: var(--bg-light, #f8fafc);
    color: var(--text-dark, #1e293b);
    border: 1px solid var(--border-color, #e2e8f0);
    align-self: flex-start;
    max-width: 90%;
}

.planning-message-error {
    background: var(--danger-light, #fef2f2);
    color: var(--danger-color, #ef4444);
    align-self: flex-start;
    max-width: 90%;
}

.planning-message-system {
    background: var(--info-light, #eff6ff);
    color: var(--text-light, #64748b);
    align-self: center;
    text-align: center;
    font-size: 13px;
    max-width: 90%;
}

.planning-message-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    opacity: 0.7;
}

.planning-message-content {
    line-height: 1.6;
}

.planning-message-content strong {
    font-weight: 600;
}

/* ── Typing Indicator ───────────────────────────────────────── */

.planning-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 14px;
}

.planning-typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-light, #64748b);
    animation: planning-dot-pulse 1.4s infinite ease-in-out both;
}

.planning-typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.planning-typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
.planning-typing-indicator span:nth-child(3) { animation-delay: 0s; }

@keyframes planning-dot-pulse {
    0%, 80%, 100% { transform: scale(0.5); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ── Convert to Tasks Button ────────────────────────────────── */

.planning-convert-wrapper {
    text-align: center;
    padding: 12px 0;
}

.planning-convert-btn {
    padding: 10px 24px;
    background: var(--success-color, #10b981);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-md, 6px);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

.planning-convert-btn:hover {
    background: var(--success-hover, #059669);
}

/* ═══════════════════════════════════════════════════════════════
   Mobile Command Bar
   ═══════════════════════════════════════════════════════════════ */

.voice-mobile-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: auto;
    background: linear-gradient(135deg, var(--primary-color, #2563eb) 0%, var(--admin-color, #7c3aed) 100%);
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.2);
    z-index: 999;
    padding: 12px 16px;
    border-radius: 20px 20px 0 0;
    display: none;
    font-family: inherit;
}

.voice-mobile-collapsed {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px;
    cursor: pointer;
}

.voice-mobile-label {
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
}

.voice-mobile-expand-btn {
    background: #ffffff;
    color: var(--primary-color, #2563eb);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    transition: transform 0.2s;
}

.voice-mobile-expand-btn:active {
    transform: scale(0.92);
}

.voice-mobile-expanded {
    padding-bottom: 8px;
}

.voice-mobile-input-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.voice-mobile-input {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: var(--radius-pill, 9999px);
    font-size: 16px; /* Prevents iOS zoom */
    color: var(--text-dark, #1e293b);
    background: #ffffff;
    outline: none;
}

.voice-mobile-input:focus {
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3);
}

.voice-mobile-mic-btn {
    background: #ffffff;
    color: var(--primary-color, #2563eb);
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
    flex-shrink: 0;
}

.voice-mobile-mic-btn:active {
    transform: scale(0.92);
}

.voice-btn-active {
    background: var(--danger-color, #ef4444) !important;
    color: #ffffff !important;
    animation: voice-pulse 1.5s infinite;
}

@keyframes voice-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

/* ── Waveform ───────────────────────────────────────────────── */

.voice-waveform-container {
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-xl, 12px);
    padding: 12px;
    margin-bottom: 12px;
}

.voice-waveform-status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #ffffff;
    font-size: 12px;
    margin-bottom: 8px;
}

.voice-confidence-label {
    font-size: 10px;
    opacity: 0.8;
}

.voice-waveform-canvas {
    width: 100%;
    display: block;
    border-radius: var(--radius-lg, 8px);
}

/* ── Recording Indicator ────────────────────────────────────── */

.voice-recording-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--danger-color, #ef4444) 0%, var(--warning-color, #f59e0b) 100%);
    z-index: 1000;
    animation: voice-indicator-pulse 1s infinite;
}

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

/* ── Recent Commands ────────────────────────────────────────── */

.voice-recent-commands {
    color: #ffffff;
    font-size: 12px;
}

.voice-recent-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.7;
    margin-bottom: 6px;
}

.voice-recent-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.voice-recent-btn {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-xl, 12px);
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.voice-recent-btn:active {
    background: rgba(255, 255, 255, 0.4);
}

/* ═══════════════════════════════════════════════════════════════
   Responsive Breakpoints
   ═══════════════════════════════════════════════════════════════ */

/* Mobile: show mobile bar, adjust planning panel */
@media (max-width: 768px) {
    .voice-mobile-bar {
        display: block;
    }

    .planning-panel {
        width: 100vw;
        border-radius: 0;
    }

    .planning-panel-header h3 {
        font-size: 15px;
    }

    .planning-chat {
        padding: 12px;
        gap: 10px;
    }

    .planning-message {
        max-width: 95%;
    }

    .planning-input-area {
        padding: 12px;
    }

    /* Ensure body has padding for sticky bar */
    body {
        padding-bottom: 80px;
    }
}

/* Desktop: hide mobile bar */
@media (min-width: 769px) {
    .voice-mobile-bar {
        display: none !important;
    }
}

/* ── Focus States (Accessibility) ───────────────────────────── */

.planning-input:focus-visible,
.planning-send-btn:focus-visible,
.planning-panel-close:focus-visible,
.voice-mobile-input:focus-visible,
.voice-mobile-mic-btn:focus-visible,
.voice-mobile-expand-btn:focus-visible {
    outline: 2px solid var(--primary-color, #2563eb);
    outline-offset: 2px;
}

.planning-convert-btn:focus-visible {
    outline: 2px solid var(--success-color, #10b981);
    outline-offset: 2px;
}
