/* ============================================================
   Frequency Comparison Tool — Tool Styles
   ============================================================ */

/* ── Visualization canvas wrappers ── */
.viz-canvas-wrap {
    width: 100%;
    height: 150px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    position: relative;
}

.viz-canvas-wrap--tall {
    height: 200px;
}

.viz-canvas-wrap canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* ── A/B Recording Panels ── */
.ab-panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

@media (max-width: 640px) {
    .ab-panels {
        grid-template-columns: 1fr;
    }
}

.ab-panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    position: relative;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.ab-panel--a {
    border-left: 3px solid #00ff41;
}

.ab-panel--b {
    border-left: 3px solid #00e5ff;
}

.ab-panel--a.ab-panel--active {
    border-color: #00ff41;
    box-shadow: 0 0 20px rgba(0, 255, 65, 0.15), inset 0 0 20px rgba(0, 255, 65, 0.03);
}

.ab-panel--b.ab-panel--active {
    border-color: #00e5ff;
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.15), inset 0 0 20px rgba(0, 229, 255, 0.03);
}

.ab-panel--a.ab-panel--ready {
    border-color: #00ff41;
}

.ab-panel--b.ab-panel--ready {
    border-color: #00e5ff;
}

.ab-panel__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-sm);
}

.ab-panel__label {
    font-family: var(--font-display);
    font-size: var(--fs-lg);
    font-weight: 700;
    letter-spacing: 0.05em;
}

.ab-panel--a .ab-panel__label {
    color: #00ff41;
}

.ab-panel--b .ab-panel__label {
    color: #00e5ff;
}

.ab-panel__status {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
    padding: 2px 8px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg);
}

.ab-panel__status--recording {
    color: #ff4444;
    border-color: #ff4444;
    animation: pulse-status 1s ease-in-out infinite;
}

.ab-panel__status--ready {
    color: #00ff41;
    border-color: #00ff41;
}

@keyframes pulse-status {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.ab-panel__actions {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}

.ab-panel__actions .btn {
    flex: 1;
}

.ab-upload-label {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

/* Color-coded record buttons */
.ab-btn--a {
    background: #00ff41 !important;
    color: #0a0a0a !important;
    border-color: #00ff41 !important;
}

.ab-btn--a:hover {
    background: #00cc34 !important;
    box-shadow: 0 0 15px rgba(0, 255, 65, 0.4);
}

.ab-btn--b {
    background: #00e5ff !important;
    color: #0a0a0a !important;
    border-color: #00e5ff !important;
}

.ab-btn--b:hover {
    background: #00b8cc !important;
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.4);
}

.ab-btn--recording {
    animation: pulse-btn 0.8s ease-in-out infinite;
}

@keyframes pulse-btn {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.85; transform: scale(0.98); }
}

/* ── Playback section ── */
.ab-panel__playback {
    margin-bottom: var(--space-sm);
}

/* ── Controls Grid ── */
.controls-grid {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: var(--space-sm);
    align-items: end;
}

@media (max-width: 640px) {
    .controls-grid {
        grid-template-columns: 1fr;
    }
}

/* ── Progress Bar ── */
.ab-panel__progress {
    width: 100%;
    height: 4px;
    background: var(--color-bg);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: var(--space-xs);
}

.ab-panel__progress-bar {
    height: 100%;
    width: 0%;
    border-radius: var(--radius-full);
    transition: width 0.1s linear;
}

.ab-panel--a .ab-panel__progress-bar {
    background: #00ff41;
    box-shadow: 0 0 6px rgba(0, 255, 65, 0.5);
}

.ab-panel--b .ab-panel__progress-bar {
    background: #00e5ff;
    box-shadow: 0 0 6px rgba(0, 229, 255, 0.5);
}

.ab-panel__info {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
}

/* ── Compare Actions ── */
.compare-actions {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
    justify-content: center;
}

/* ── Match Percentage Display ── */
.match-display {
    text-align: center;
    padding: var(--space-lg) var(--space-md);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    position: relative;
    overflow: hidden;
}

.match-display__value {
    font-family: var(--font-display);
    font-size: 4rem;
    font-weight: 900;
    line-height: 1;
    display: inline-block;
    transition: color 0.3s ease;
}

.match-display__unit {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text-muted);
    vertical-align: super;
}

.match-display__label {
    display: block;
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
    margin-top: var(--space-xs);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* Match percentage color coding */
.match-display--excellent .match-display__value {
    color: #00ff41;
    text-shadow: 0 0 20px rgba(0, 255, 65, 0.5);
}

.match-display--good .match-display__value {
    color: #b8ff00;
    text-shadow: 0 0 20px rgba(184, 255, 0, 0.4);
}

.match-display--moderate .match-display__value {
    color: #ffcc00;
    text-shadow: 0 0 20px rgba(255, 204, 0, 0.4);
}

.match-display--low .match-display__value {
    color: #ff8800;
    text-shadow: 0 0 20px rgba(255, 136, 0, 0.4);
}

.match-display--poor .match-display__value {
    color: #ff4444;
    text-shadow: 0 0 20px rgba(255, 68, 68, 0.4);
}

/* Match display glow ring */
.match-display--excellent {
    border-color: rgba(0, 255, 65, 0.3);
    box-shadow: inset 0 0 30px rgba(0, 255, 65, 0.05);
}

.match-display--good {
    border-color: rgba(184, 255, 0, 0.3);
    box-shadow: inset 0 0 30px rgba(184, 255, 0, 0.05);
}

.match-display--moderate {
    border-color: rgba(255, 204, 0, 0.3);
    box-shadow: inset 0 0 30px rgba(255, 204, 0, 0.05);
}

.match-display--low {
    border-color: rgba(255, 136, 0, 0.3);
    box-shadow: inset 0 0 30px rgba(255, 136, 0, 0.05);
}

.match-display--poor {
    border-color: rgba(255, 68, 68, 0.3);
    box-shadow: inset 0 0 30px rgba(255, 68, 68, 0.05);
}

/* ── Frequency Differences Table ── */
.freq-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.freq-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
}

.freq-table th,
.freq-table td {
    padding: 6px 10px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

.freq-table th {
    color: var(--color-text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: var(--fs-xs);
    letter-spacing: 0.05em;
}

.freq-table td {
    color: var(--color-text);
}

.freq-table .delta-positive {
    color: #00e5ff;
}

.freq-table .delta-negative {
    color: #00ff41;
}

/* ── Stats Row ── */
.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-sm);
    margin-top: var(--space-sm);
}

.stat-box {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: var(--space-sm);
    text-align: center;
}

.stat-box__label {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.stat-box__value {
    font-family: var(--font-display);
    font-size: var(--fs-lg);
    font-weight: 700;
    color: var(--color-primary);
}

/* ── History Table ── */
.history-wrap {
    max-height: 180px;
    overflow-y: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg);
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
}

.history-table th,
.history-table td {
    padding: 4px 8px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.history-table th {
    color: var(--color-text-muted);
    font-weight: 600;
    position: sticky;
    top: 0;
    background: var(--color-surface);
    z-index: 1;
}

/* ── Export Actions ── */
.export-actions {
    display: flex;
    gap: var(--space-sm);
    margin-top: var(--space-sm);
}

/* ── Keyboard Hints ── */
.kbd-hints {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
    justify-content: center;
}

.kbd-hint {
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
}

.kbd-hint kbd {
    display: inline-block;
    padding: 1px 6px;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 3px;
    margin-right: 2px;
}

/* ── Freeze Badge ── */
.freeze-badge {
    display: inline-block;
    padding: 2px 10px;
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    font-weight: 700;
    color: #00e5ff;
    background: rgba(0, 229, 255, 0.12);
    border: 1px solid #00e5ff;
    border-radius: var(--radius-full);
    letter-spacing: 0.08em;
    vertical-align: middle;
    animation: freeze-pulse 1.5s ease-in-out infinite;
}

@keyframes freeze-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .match-display__value {
        font-size: 3rem;
    }

    .match-display__unit {
        font-size: 1.2rem;
    }

    .viz-canvas-wrap--tall {
        height: 160px;
    }

    .stats-row {
        grid-template-columns: 1fr;
    }

    .compare-actions {
        flex-direction: column;
    }
}
