/* Minimal custom styles for Healthcare AI Assistant */

/* Smooth scrolling in chat */
#messages {
    scroll-behavior: smooth;
}

/* Line clamp for search results */
.line-clamp-4 {
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Prose styling for markdown in chat */
.prose h1, .prose h2, .prose h3 { font-weight: 600; }
.prose h1 { font-size: 1.25rem; margin: 0.5rem 0; }
.prose h2 { font-size: 1.125rem; margin: 0.4rem 0; }
.prose h3 { font-size: 1rem; margin: 0.3rem 0; }
.prose p { margin: 0.25rem 0; }
.prose ul, .prose ol { margin: 0.25rem 0; padding-left: 1.5rem; }
.prose li { margin: 0.125rem 0; }
.prose code {
    background: rgba(0,0,0,0.06);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.85em;
}
.prose pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin: 0.5rem 0;
}
.prose pre code {
    background: none;
    padding: 0;
    color: inherit;
}
.prose a { color: #2563eb; text-decoration: underline; }
.prose blockquote {
    border-left: 3px solid #e2e8f0;
    padding-left: 0.75rem;
    color: #64748b;
    margin: 0.5rem 0;
}

/* ============================================================
 * Voice I/O — Premium UI (post-redesign)
 * Layout uses Tailwind utilities inline. This file styles only:
 *   - Toggle switches (need :checked pseudo-class on hidden input)
 *   - Modal slide-up animation
 *   - Custom select chevron
 *   - Section card layout
 *   - Recording / hands-free badge animations
 * ============================================================ */

/* Generic icon-button style for mic, speaker, settings */
.voice-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 0.5rem;
    cursor: pointer;
    color: #64748b;
    transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.voice-btn:hover {
    background: #f1f5f9;
    color: #0f172a;
}
.voice-btn:focus-visible {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.35);
}
.voice-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ---------- Voice Settings modal — section/card layout ---------- */
.vs-section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #475569;
    margin-bottom: 0.625rem;
    padding-left: 0.125rem;
}

.vs-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 0.875rem;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.vs-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.875rem 1rem;
    min-height: 3.5rem;
}

.vs-row-divider {
    border-top: 1px solid #f1f5f9;
}

.vs-row-text {
    flex: 1;
    min-width: 0;
}

.vs-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: #0f172a;
    line-height: 1.25;
}

.vs-help {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 0.1875rem;
    line-height: 1.4;
}

/* ---------- Custom select (replaces ugly browser default) ---------- */
.vs-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.625rem;
    padding: 0.5rem 2rem 0.5rem 0.875rem;
    font-size: 0.8125rem;
    color: #0f172a;
    cursor: pointer;
    min-width: 9.5rem;
    max-width: 12.5rem;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%2364748b' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.75' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.625rem center;
    background-size: 1.125rem 1.125rem;
}
.vs-select:hover {
    background-color: #ffffff;
    border-color: #cbd5e1;
}
.vs-select:focus {
    outline: none;
    border-color: #2563eb;
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}
.vs-select:disabled,
.vs-select option:disabled {
    color: #94a3b8;
    cursor: not-allowed;
}

/* ---------- iOS-style toggle switch ---------- */
.vs-toggle {
    position: relative;
    display: inline-block;
    width: 2.875rem;
    height: 1.625rem;
    flex-shrink: 0;
    cursor: pointer;
}
.vs-toggle input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}
.vs-toggle-slider {
    position: absolute;
    inset: 0;
    background: #cbd5e1;
    border-radius: 9999px;
    transition: background 0.2s ease;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.08);
}
.vs-toggle-slider::before {
    content: "";
    position: absolute;
    width: 1.25rem;
    height: 1.25rem;
    left: 0.1875rem;
    top: 0.1875rem;
    background: #ffffff;
    border-radius: 9999px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.18), 0 1px 2px rgba(15, 23, 42, 0.08);
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}
.vs-toggle input:checked + .vs-toggle-slider {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
}
.vs-toggle input:checked + .vs-toggle-slider::before {
    transform: translateX(1.25rem);
}
.vs-toggle input:focus-visible + .vs-toggle-slider {
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.08), 0 0 0 3px rgba(37, 99, 235, 0.35);
}

/* ---------- Modal entrance animation ---------- */
@keyframes vs-slide-up {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.96);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (prefers-reduced-motion: reduce) {
    #voice-settings-panel {
        animation: none !important;
    }
    .vs-toggle-slider,
    .vs-toggle-slider::before {
        transition: none;
    }
}

/* Mic button — shares voice-btn but sized to match send button */
#mic-btn {
    width: 2.75rem;
    height: 2.75rem;
    flex-shrink: 0;
    border-radius: 0.75rem;
    background: #e2e8f0;
    color: #475569;
}
#mic-btn:hover {
    background: #cbd5e1;
    color: #0f172a;
}
#mic-btn.recording {
    background: #dc2626;
    color: #ffffff;
    animation: mic-pulse 1.1s ease-in-out infinite;
}
#mic-btn.recording:hover {
    background: #b91c1c;
}

@keyframes mic-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.55); }
    50%      { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
}

/* Recording badge — appears above input when mic is active */
#recording-badge {
    display: none;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.875rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 0.75rem;
    color: #b91c1c;
    font-size: 0.8125rem;
    font-weight: 500;
    margin: 0 1rem 0.5rem 1rem;
}
#recording-badge.active {
    display: inline-flex;
}
#recording-badge .dot {
    width: 0.625rem;
    height: 0.625rem;
    border-radius: 9999px;
    background: #dc2626;
    animation: badge-pulse 1.1s ease-in-out infinite;
}
@keyframes badge-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.45; transform: scale(0.85); }
}

/* Speaker button on assistant message bubbles */
.speaker-btn {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 0.5rem;
    margin-left: 0.5rem;
    align-self: flex-end;
    flex-shrink: 0;
    background: rgba(241, 245, 249, 0.8);
    color: #475569;
}
.speaker-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}
.speaker-btn.playing {
    background: #2563eb;
    color: #ffffff;
    animation: speaker-wave 1s ease-in-out infinite;
}
@keyframes speaker-wave {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.08); }
}

/* Hands-free indicator badge in chat header */
.hands-free-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    background: rgba(34, 197, 94, 0.18);
    border: 1px solid rgba(34, 197, 94, 0.45);
    color: #ffffff;
    font-size: 0.6875rem;
    font-weight: 600;
    border-radius: 9999px;
    margin-left: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.hands-free-badge .dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 9999px;
    background: #4ade80;
    animation: hands-free-pulse 1.4s ease-in-out infinite;
}
@keyframes hands-free-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.55; transform: scale(0.85); }
}
@media (prefers-reduced-motion: reduce) {
    .hands-free-badge .dot { animation: none; }
}

/* Settings gear button in chat header */
#voice-settings-btn {
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    color: rgba(255, 255, 255, 0.85);
    margin-left: auto;
}
#voice-settings-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

/* NOTE: Modal overlay (#voice-settings-overlay) and panel layout are now
 * controlled by Tailwind utility classes inline in index.html plus the
 * .vs-* classes defined above. The old #voice-settings-panel rules and
 * .toggle-switch class were removed in favor of .vs-toggle / .vs-card. */

/* WCAG: Respect prefers-reduced-motion — disable pulsing animations */
@media (prefers-reduced-motion: reduce) {
    #mic-btn.recording,
    #recording-badge .dot,
    .speaker-btn.playing {
        animation: none;
    }
    #mic-btn.recording {
        outline: 3px solid #fca5a5;
        outline-offset: 2px;
    }
}

/* WCAG: Focus indicator for keyboard users */
.voice-btn:focus-visible,
#mic-btn:focus-visible,
.speaker-btn:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

/* Screen-reader-only utility class */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
