/**
 * vocal.css — ChordStar Vocal Pitch Monitor
 * Premium Music Studio Aesthetic (Dark Charcoal & Deep Violet)
 * Completely isolated from tuner.css (.vocal- prefix throughout)
 */

/* ── Modal Overlay & Container ── */
#vocalModal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(10, 8, 18, 0.88);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    padding: 1rem;
    opacity: 0;
    transition: opacity 0.22s ease-out;
}

#vocalModal.open {
    display: flex;
    opacity: 1;
}

.vocal-dialog {
    position: relative;
    width: 100%;
    max-width: 960px;
    max-height: 94vh;
    overflow-y: auto;
    overflow-x: hidden;
    background: linear-gradient(180deg, #161224 0%, #100d1c 100%);
    border: 1px solid rgba(168, 85, 247, 0.24);
    border-radius: 20px;
    box-shadow: 0 24px 64px -12px rgba(0, 0, 0, 0.8),
                0 0 0 1px rgba(255, 255, 255, 0.05),
                0 0 40px -10px rgba(168, 85, 247, 0.15);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.4rem;
    color: #f8fafc;
    font-family: "Space Grotesk", system-ui, -apple-system, sans-serif;
    scrollbar-width: thin;
    scrollbar-color: rgba(168, 85, 247, 0.3) transparent;
}

.vocal-dialog::-webkit-scrollbar {
    width: 6px;
}
.vocal-dialog::-webkit-scrollbar-thumb {
    background: rgba(168, 85, 247, 0.3);
    border-radius: 4px;
}

/* ── Section A: Header ── */
.vocal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.vocal-header-left {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.vocal-brand-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.25) 0%, rgba(217, 70, 239, 0.18) 100%);
    border: 1px solid rgba(192, 132, 252, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #c084fc;
    box-shadow: 0 0 16px -2px rgba(168, 85, 247, 0.3);
}

.vocal-title-wrap h2 {
    font-size: 1.18rem;
    font-weight: 700;
    margin: 0;
    color: #ffffff;
    letter-spacing: -0.01em;
}

.vocal-title-wrap p {
    font-size: 0.78rem;
    margin: 0;
    color: #94a3b8;
}

.vocal-header-right {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.vocal-status-wrap {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 0.3rem 0.65rem;
    border-radius: 20px;
    font-size: 0.75rem;
    color: #cbd5e1;
}

.vocal-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #64748b;
    transition: background 0.2s, box-shadow 0.2s;
}

.vocal-status-dot.listening {
    background: #22c55e;
    box-shadow: 0 0 8px #22c55e;
}

.vocal-status-dot.connecting {
    background: #f59e0b;
    box-shadow: 0 0 8px #f59e0b;
}

.vocal-close-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #cbd5e1;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.vocal-close-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
    color: #ef4444;
}

/* ── Section B: Hero Live Pitch Readout ── */
.vocal-hero {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 1.2rem;
    padding: 1.1rem 1.4rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(168, 85, 247, 0.16);
    border-radius: 16px;
}

.vocal-hero-left {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.vocal-hero-note {
    font-size: 3.2rem;
    font-weight: 800;
    line-height: 1;
    color: #ffffff;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 24px rgba(168, 85, 247, 0.35);
}

.vocal-hero-freq {
    font-size: 1.05rem;
    font-weight: 600;
    color: #c084fc;
    font-variant-numeric: tabular-nums;
}

.vocal-hero-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.45rem;
}

.vocal-hero-cents {
    font-size: 1.45rem;
    font-weight: 700;
    color: #94a3b8;
    font-variant-numeric: tabular-nums;
    transition: color 0.15s ease;
}

.vocal-hero-cents.in-tune {
    color: #22c55e;
    text-shadow: 0 0 14px rgba(34, 197, 94, 0.5);
}
.vocal-hero-cents.close {
    color: #eab308;
}
.vocal-hero-cents.out-tune {
    color: #ef4444;
}

.vocal-state-badge {
    padding: 0.25rem 0.65rem;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: rgba(255, 255, 255, 0.06);
    color: #94a3b8;
}

.vocal-state-badge.voiced {
    background: rgba(34, 197, 94, 0.18);
    color: #4ade80;
    border: 1px solid rgba(74, 222, 128, 0.3);
}

.vocal-state-badge.unvoiced {
    background: rgba(245, 158, 11, 0.18);
    color: #fbbf24;
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.vocal-state-badge.silence {
    background: rgba(255, 255, 255, 0.04);
    color: #64748b;
}

.vocal-hero-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.4rem;
}

.vocal-vu-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #94a3b8;
    font-size: 0.75rem;
}

.vocal-vu-bar-track {
    width: 100px;
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.vocal-vu-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #22c55e 0%, #eab308 65%, #ef4444 100%);
    border-radius: 4px;
    transition: width 0.06s ease;
}

/* ── Section C: Canvas Pitch Graph ── */
.vocal-graph-card {
    position: relative;
    background: #0c0a14;
    border: 1px solid rgba(168, 85, 247, 0.22);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.6);
}

.vocal-graph-toolbar {
    position: absolute;
    top: 10px;
    right: 12px;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.vocal-win-btn-group {
    display: flex;
    background: rgba(18, 14, 30, 0.85);
    border: 1px solid rgba(168, 85, 247, 0.3);
    border-radius: 8px;
    padding: 2px;
    backdrop-filter: blur(8px);
}

.vocal-win-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.25rem 0.55rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.vocal-win-btn:hover {
    color: #ffffff;
}

.vocal-win-btn.active {
    background: rgba(168, 85, 247, 0.35);
    color: #ffffff;
    box-shadow: 0 0 10px -2px rgba(168, 85, 247, 0.5);
}

.vocal-tool-btn {
    background: rgba(18, 14, 30, 0.85);
    border: 1px solid rgba(168, 85, 247, 0.3);
    color: #94a3b8;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.25rem 0.6rem;
    border-radius: 8px;
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: all 0.15s ease;
}

.vocal-tool-btn:hover {
    background: rgba(168, 85, 247, 0.25);
    color: #ffffff;
}

#vocalPitchCanvas {
    display: block;
    width: 100%;
    height: 310px;
    background: #0c0a14;
}

/* ── Section D: Vocal Analysis Dashboard Grid ── */
.vocal-metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.85rem;
}

.vocal-metric-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(168, 85, 247, 0.14);
    border-radius: 14px;
    padding: 0.85rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.vocal-metric-title {
    font-size: 0.74rem;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.vocal-metric-value {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.vocal-metric-value strong {
    font-size: 1.12rem;
    font-weight: 700;
    color: #ffffff;
    font-variant-numeric: tabular-nums;
}

.vocal-stat-sub {
    font-size: 0.72rem;
    color: #c084fc;
}

/* ── Section E: Controls Toolbar ── */
.vocal-controls-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-top: 0.4rem;
}

.vocal-controls-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.vocal-select-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(168, 85, 247, 0.2);
    padding: 0.4rem 0.8rem;
    border-radius: 12px;
    max-width: 280px;
    width: 100%;
}

.vocal-select {
    width: 100%;
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 0.82rem;
    font-weight: 500;
    outline: none;
    cursor: pointer;
}

.vocal-select option {
    background: #161224;
    color: #ffffff;
}

.vocal-controls-center {
    display: flex;
    justify-content: center;
}

#vocalStartBtn {
    background: linear-gradient(135deg, #9333ea 0%, #c026d3 100%);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    font-size: 0.95rem;
    font-weight: 700;
    padding: 0.75rem 2rem;
    border-radius: 30px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    box-shadow: 0 8px 24px -4px rgba(168, 85, 247, 0.5);
    transition: all 0.2s ease;
}

#vocalStartBtn:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 28px -4px rgba(168, 85, 247, 0.65);
}

#vocalStartBtn.active {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    box-shadow: 0 8px 24px -4px rgba(239, 68, 68, 0.5);
}

.vocal-controls-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex: 1;
}

/* ── Section F: Error & Status Banner ── */
.vocal-error-banner {
    display: none;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: #fca5a5;
    font-size: 0.8rem;
    padding: 0.6rem 1rem;
    border-radius: 10px;
    text-align: center;
}

.vocal-error-banner.show {
    display: block;
}

/* ── Responsive Viewport Optimizations ── */
@media (max-width: 900px) {
    .vocal-metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .vocal-dialog {
        padding: 1rem;
        gap: 0.85rem;
    }
    .vocal-hero {
        grid-template-columns: 1fr 1fr;
        gap: 0.8rem;
    }
    .vocal-hero-right {
        grid-column: span 2;
        align-items: flex-start;
    }
    #vocalPitchCanvas {
        height: 250px;
    }
    .vocal-controls-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .vocal-controls-left,
    .vocal-controls-right {
        justify-content: center;
    }
    .vocal-select-wrap {
        max-width: 100%;
    }
    #vocalStartBtn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    #vocalModal {
        padding: 0;
    }
    .vocal-dialog {
        max-height: 100vh;
        height: 100%;
        border-radius: 0;
        border: none;
    }
    .vocal-hero-note {
        font-size: 2.6rem;
    }
    #vocalPitchCanvas {
        height: 220px;
    }
}
