/* ============================================================
   Key Signature Finder — Tool Styles
   FrequencyDetector.com
   ============================================================ */

/* ── Mode Tabs ─────────────────────────────────────────────── */
.mode-tabs {
    display: flex;
    gap: 2px;
    margin-bottom: var(--space-md);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.mode-tab {
    flex: 1;
    padding: var(--space-sm) var(--space-md);
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    white-space: nowrap;
}

.mode-tab:hover {
    color: var(--color-text);
    background: rgba(0, 255, 65, 0.05);
}

.mode-tab--active {
    color: var(--color-primary);
    background: rgba(0, 255, 65, 0.1);
    border-bottom: 2px solid var(--color-primary);
    font-weight: 600;
}

/* ── Mode Panels ───────────────────────────────────────────── */
.mode-panel {
    display: none;
}

.mode-panel--active {
    display: block;
}

/* ── Key Display (Large, Neon Glow) ────────────────────────── */
.key-display {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 8vw, 4.5rem);
    font-weight: 900;
    color: var(--color-primary);
    text-shadow: 0 0 24px rgba(0, 255, 65, 0.5), 0 0 48px rgba(0, 255, 65, 0.2);
    line-height: 1.1;
    letter-spacing: 0.03em;
    text-align: center;
    padding: var(--space-sm) 0;
    transition: color 0.3s ease, text-shadow 0.3s ease;
    animation: keyPulse 2s ease-in-out infinite;
}

.key-display--idle {
    color: var(--color-text-muted);
    text-shadow: none;
    animation: none;
}

@keyframes keyPulse {
    0%, 100% {
        text-shadow: 0 0 24px rgba(0, 255, 65, 0.5), 0 0 48px rgba(0, 255, 65, 0.2);
    }
    50% {
        text-shadow: 0 0 36px rgba(0, 255, 65, 0.7), 0 0 72px rgba(0, 255, 65, 0.3);
    }
}

/* ── Confidence Bar ────────────────────────────────────────── */
.confidence-row {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    margin-top: var(--space-xs);
}

.confidence-label {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
    white-space: nowrap;
}

.confidence-bar {
    flex: 1;
    height: 8px;
    background: var(--color-surface);
    border-radius: var(--radius-full);
    border: 1px solid var(--color-border);
    overflow: hidden;
}

.confidence-bar__fill {
    height: 100%;
    background: linear-gradient(90deg, #00ff41, #00e5ff);
    border-radius: var(--radius-full);
    transition: width 0.4s ease;
    box-shadow: 0 0 8px rgba(0, 255, 65, 0.4);
}

.confidence-value {
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
    color: var(--color-primary);
    font-weight: 600;
    min-width: 3em;
    text-align: right;
}

/* ── Results Panel ─────────────────────────────────────────── */
.results-panel {
    margin-top: var(--space-md);
}

.results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.result-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
}

.result-card--key {
    text-align: center;
}

.result-card__label {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: var(--space-xs);
}

/* ── Key Signature Info ────────────────────────────────────── */
.key-sig-info {
    font-family: var(--font-mono);
    font-size: var(--fs-md);
    color: var(--color-text);
    margin-bottom: var(--space-sm);
    min-height: 1.5em;
}

.staff-canvas {
    width: 100%;
    max-width: 280px;
    height: 100px;
    display: block;
    border-radius: var(--radius-sm);
}

/* ── Related Keys ──────────────────────────────────────────── */
.related-keys {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.related-key-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-xs) 0;
    border-bottom: 1px solid var(--color-border);
}

.related-key-item:last-child {
    border-bottom: none;
}

.related-key-item__label {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
}

.related-key-item__value {
    font-family: var(--font-display);
    font-size: var(--fs-md);
    color: var(--color-secondary);
    font-weight: 700;
    text-shadow: 0 0 8px rgba(0, 229, 255, 0.3);
}

/* ── Chord Chips ───────────────────────────────────────────── */
.chord-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    margin-top: var(--space-sm);
}

.chord-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    background: rgba(0, 255, 65, 0.08);
    border: 1px solid rgba(0, 255, 65, 0.25);
    border-radius: var(--radius-full);
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
    color: var(--color-primary);
    transition: all 0.2s ease;
}

.chord-chip--diatonic {
    background: rgba(0, 255, 65, 0.15);
    border-color: rgba(0, 255, 65, 0.4);
    color: #00ff41;
}

.chord-chip--secondary {
    background: rgba(0, 229, 255, 0.1);
    border-color: rgba(0, 229, 255, 0.3);
    color: var(--color-secondary);
}

.chord-chip--foreign {
    background: rgba(255, 23, 68, 0.1);
    border-color: rgba(255, 23, 68, 0.3);
    color: var(--color-error);
}

/* ── Diatonic Chords ───────────────────────────────────────── */
.diatonic-section {
    margin-bottom: var(--space-md);
}

.diatonic-chords {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: var(--space-xs);
}

.diatonic-chord {
    text-align: center;
    padding: var(--space-sm) var(--space-xs);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.diatonic-chord:hover {
    border-color: var(--color-primary);
    box-shadow: 0 0 12px rgba(0, 255, 65, 0.15);
}

.diatonic-chord__roman {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
    margin-bottom: 2px;
}

.diatonic-chord__name {
    font-family: var(--font-display);
    font-size: var(--fs-md);
    font-weight: 700;
    color: var(--color-primary);
    text-shadow: 0 0 8px rgba(0, 255, 65, 0.3);
}

.diatonic-chord__quality {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--color-text-muted);
    margin-top: 2px;
}

.diatonic-placeholder {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--color-text-muted);
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
    padding: var(--space-md);
}

/* ── Capo Table ────────────────────────────────────────────── */
.capo-section {
    margin-bottom: var(--space-md);
}

.capo-table-wrap {
    overflow-x: auto;
}

.capo-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
}

.capo-table th {
    text-align: left;
    padding: var(--space-xs) var(--space-sm);
    background: var(--color-surface);
    border-bottom: 2px solid var(--color-primary);
    color: var(--color-primary);
    font-weight: 600;
    white-space: nowrap;
}

.capo-table td {
    padding: var(--space-xs) var(--space-sm);
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text);
}

.capo-table tr:hover td {
    background: rgba(0, 255, 65, 0.04);
}

.capo-table tr.capo-row--easy td {
    color: var(--color-primary);
    font-weight: 600;
}

.capo-table tr.capo-row--easy td:first-child::after {
    content: ' *';
    color: var(--color-secondary);
}

.capo-placeholder {
    text-align: center;
    color: var(--color-text-muted);
    padding: var(--space-md) !important;
}

/* ── All Keys Ranked ───────────────────────────────────────── */
.all-keys-details {
    margin-bottom: var(--space-md);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.all-keys-summary {
    padding: var(--space-sm) var(--space-md);
    background: var(--color-surface);
    color: var(--color-text);
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
}

.all-keys-summary:hover {
    background: rgba(0, 255, 65, 0.06);
}

.all-keys-list {
    padding: var(--space-sm) var(--space-md);
    max-height: 400px;
    overflow-y: auto;
}

.all-key-row {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 4px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.all-key-row:first-child {
    font-weight: 600;
    color: var(--color-primary);
}

.all-key-row__rank {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
    width: 2em;
    text-align: right;
}

.all-key-row__name {
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
    min-width: 8em;
}

.all-key-row__bar {
    flex: 1;
    height: 6px;
    background: var(--color-surface);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.all-key-row__bar-fill {
    height: 100%;
    background: var(--color-primary);
    border-radius: var(--radius-full);
    transition: width 0.3s ease;
}

.all-key-row:first-child .all-key-row__bar-fill {
    background: linear-gradient(90deg, #00ff41, #00e5ff);
    box-shadow: 0 0 6px rgba(0, 255, 65, 0.4);
}

.all-key-row__pct {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
    min-width: 3.5em;
    text-align: right;
}

/* ── Histogram ─────────────────────────────────────────────── */
.histogram-panel {
    margin-bottom: var(--space-md);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
}

.histogram {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 120px;
}

.histogram-bar {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    position: relative;
}

.histogram-bar__label {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--color-text-muted);
    position: absolute;
    bottom: 0;
    text-align: center;
}

.histogram-bar__fill {
    width: 100%;
    background: linear-gradient(180deg, #00ff41, rgba(0, 255, 65, 0.3));
    border-radius: 2px 2px 0 0;
    position: absolute;
    bottom: 18px;
    min-height: 0;
    transition: height 0.15s ease;
}

.histogram-bar__value {
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--color-text-muted);
    position: absolute;
    top: 0;
}

/* ── Note Checkboxes ───────────────────────────────────────── */
.note-checkboxes {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: var(--space-xs);
}

.note-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.note-checkbox input[type="checkbox"] {
    accent-color: var(--color-primary);
    width: 18px;
    height: 18px;
}

.note-checkbox__key {
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
    color: var(--color-text);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    transition: all 0.2s ease;
    min-width: 50px;
    text-align: center;
}

.note-checkbox__key--black {
    background: rgba(0, 0, 0, 0.6);
    color: var(--color-text-muted);
}

.note-checkbox input:checked + .note-checkbox__key {
    border-color: var(--color-primary);
    background: rgba(0, 255, 65, 0.12);
    color: var(--color-primary);
    box-shadow: 0 0 8px rgba(0, 255, 65, 0.2);
}

/* ── Chord Input ───────────────────────────────────────────── */
.chords-input-section {
    margin-bottom: var(--space-sm);
}

.chords-input-row {
    display: flex;
    gap: var(--space-xs);
    margin-top: var(--space-xs);
}

.chords-input-row .input {
    flex: 1;
}

.input-hint {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
    margin-top: 4px;
}

/* ── Panel Title ───────────────────────────────────────────── */
.panel-title {
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
    color: var(--color-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: var(--space-sm);
}

/* ── Session Stats ─────────────────────────────────────────── */
.stats-row {
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.stat-item__value {
    font-family: var(--font-display);
    font-size: var(--fs-lg);
    font-weight: 700;
    color: var(--color-primary);
}

.stat-item__label {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
}

/* ── Export Row ─────────────────────────────────────────────── */
.export-row {
    display: flex;
    gap: var(--space-xs);
    margin-top: var(--space-md);
}

/* ── File Drop Zone ────────────────────────────────────────── */
.file-drop-zone {
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    text-align: center;
    color: var(--color-text-muted);
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
    transition: all 0.2s ease;
    margin-top: var(--space-md);
    cursor: pointer;
}

.file-drop-zone:hover,
.file-drop-zone--dragover {
    border-color: var(--color-primary);
    background: rgba(0, 255, 65, 0.04);
}

/* ── Steps Grid ────────────────────────────────────────────── */
.steps-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-md);
}

.step-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    text-align: center;
}

.step-card__number {
    font-family: var(--font-display);
    font-size: var(--fs-xl);
    font-weight: 900;
    color: var(--color-primary);
    text-shadow: 0 0 12px rgba(0, 255, 65, 0.4);
    margin-bottom: var(--space-xs);
}

.step-card__title {
    font-size: var(--fs-md);
    margin-bottom: var(--space-xs);
}

.step-card__text {
    font-size: var(--fs-sm);
    color: var(--color-text-muted);
    line-height: 1.5;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 900px) {
    .results-grid {
        grid-template-columns: 1fr;
    }

    .diatonic-chords {
        grid-template-columns: repeat(4, 1fr);
    }

    .steps-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .note-checkboxes {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 600px) {
    .mode-tab {
        font-size: var(--fs-xs);
        padding: var(--space-xs) var(--space-sm);
    }

    .key-display {
        font-size: clamp(2rem, 12vw, 3.5rem);
    }

    .diatonic-chords {
        grid-template-columns: repeat(3, 1fr);
    }

    .steps-grid {
        grid-template-columns: 1fr;
    }

    .note-checkboxes {
        grid-template-columns: repeat(3, 1fr);
    }

    .stats-row {
        flex-direction: column;
        align-items: center;
    }

    .chords-input-row {
        flex-direction: column;
    }

    .export-row {
        flex-direction: column;
    }
}
