/**
 * Pitch Detector Styles
 * Dedicated styles for the pitch detector page
 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    color-scheme: dark;
    --primary-color: #6366f1;
    --secondary-color: #8b5cf6;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-light: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --accent-happy: #10b981;
    --accent-sad: #3b82f6;
    --accent-dark: #8b5cf6;
    --accent-energetic: #f59e0b;
    --accent-dreamy: #ec4899;
    --accent-tense: #ef4444;
    --border-radius: 16px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.4);
}

html {
    background: #0f172a;
    color-scheme: dark;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Navigation */
.main-nav {
    display: flex;
    gap: 10px;
    justify-content: center;
    padding: 20px 20px;
    margin: 0 auto 20px auto;
    max-width: 1200px;
    border-bottom: 2px solid var(--surface-light);
    flex-wrap: wrap;
}

.nav-link {
    padding: 10px 20px;
    background: var(--surface-light);
    color: var(--text-primary);
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.nav-link.active {
    background: var(--primary-color);
    color: white;
}

.nav-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(99, 102, 241, 0.3);
}

.back-nav {
    margin-bottom: 30px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    padding: 8px 16px;
    border-radius: 8px;
    background: var(--surface);
}

.back-link:hover {
    color: var(--primary-color);
    background: var(--surface-light);
    transform: translateX(-4px);
}

/* Header */
header {
    text-align: center;
    margin-bottom: 40px;
    animation: fadeInDown 0.6s ease;
}

.header-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    animation: float 3s ease-in-out infinite;
}

h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 12px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color), var(--accent-dreamy));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary);
}

/* Main Card */
.main-card {
    background: var(--surface);
    border-radius: var(--border-radius);
    padding: 40px;
    box-shadow: var(--shadow-xl);
    animation: fadeInUp 0.6s ease;
}

/* Instructions */
.instructions {
    background: var(--surface-light);
    border-radius: 12px;
    padding: 20px;
    margin-top: 24px;
    margin-bottom: 24px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.instructions h3 {
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-size: 1.1rem;
}

.instructions ol {
    margin-left: 20px;
    margin-bottom: 12px;
}

.instructions li {
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.note-hint {
    background: var(--background);
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-left: 3px solid var(--text-secondary);
}

/* Controls Section */
.controls-section {
    text-align: center;
    margin-bottom: 32px;
}

.pitch-button {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 18px 48px;
    font-size: 1.3rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
    max-width: 300px;
}

.pitch-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

.pitch-button:hover::before {
    left: 100%;
}

.pitch-button:hover:not(:disabled) {
    transform: translateY(-3px) scale(1.05);
    box-shadow: var(--shadow-xl);
}

.pitch-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.pitch-button.listening {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    animation: pulse 2s ease-in-out infinite;
}

.button-icon {
    font-size: 1.5rem;
}

.status-text {
    margin-top: 16px;
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-weight: 500;
    min-height: 28px;
}

/* Pitch Display */
.pitch-display {
    animation: fadeIn 0.5s ease;
}

.note-container {
    text-align: center;
    background: linear-gradient(135deg, var(--surface-light), var(--surface));
    border-radius: 16px;
    padding: 40px;
    margin-bottom: 32px;
    border: 2px solid rgba(99, 102, 241, 0.3);
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.3);
}

.note-label {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.note-name {
    font-size: 4.5rem;
    font-weight: 900;
    font-family: 'Courier New', monospace;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-dreamy));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 8px;
    transition: transform 0.15s ease;
    display: inline-block;
    text-shadow: 0 0 30px rgba(99, 102, 241, 0.5);
    line-height: 1.2;
}

.note-hint-text {
    margin-top: 16px;
    font-size: 1rem;
    color: var(--accent-happy);
    font-weight: 500;
    min-height: 24px;
}

.metrics-status {
    margin-top: 12px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-family: 'Courier New', monospace;
    text-align: center;
}

/* Metrics Grid (DEPRECATED - keeping for backwards compatibility) */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.metric-card {
    background: var(--surface-light);
    border-radius: 8px;
    padding: 12px 16px;
    text-align: center;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.metric-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary-color);
    box-shadow: var(--shadow);
}

.metric-icon {
    font-size: 1.2rem;
    margin-bottom: 6px;
}

.metric-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 1rem;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    color: var(--text-primary);
}

.confidence-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.confidence-bar-bg {
    width: 100%;
    height: 8px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 4px;
    overflow: hidden;
}

.confidence-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-sad), var(--primary-color), var(--accent-happy));
    border-radius: 6px;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
}

/* Visual Indicator */
.visual-indicator {
    background: var(--background);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
}

#waveform {
    width: 100%;
    height: 150px;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.5);
}

/* Error Display */
.pitch-error {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(220, 38, 38, 0.1));
    border: 2px solid var(--accent-tense);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
    color: var(--accent-tense);
    font-size: 1rem;
    line-height: 1.6;
    text-align: center;
    font-weight: 500;
}

/* Note History Section */
.note-history-section {
    background: var(--surface-light);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    animation: fadeIn 0.5s ease;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.history-header h3 {
    color: var(--text-primary);
    font-size: 1.3rem;
    margin: 0;
}

.history-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.sort-toggle {
    display: flex;
    gap: 8px;
    background: var(--background);
    padding: 4px;
    border-radius: 8px;
}

.sort-option {
    display: flex;
    align-items: center;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.85rem;
    color: var(--text-secondary);
    user-select: none;
}

.sort-option:hover {
    background: var(--surface-light);
}

.sort-option input[type="radio"] {
    display: none;
}

.sort-option input[type="radio"]:checked + span {
    color: var(--text-primary);
    font-weight: 600;
}

.sort-option input[type="radio"]:checked {
    background: var(--primary-color);
}

.sort-option:has(input[type="radio"]:checked) {
    background: var(--primary-color);
    color: white;
}

.sort-option:has(input[type="radio"]:checked) span {
    color: white;
}

.clear-button {
    padding: 8px 16px;
    background: var(--accent-tense);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.clear-button:hover {
    background: #dc2626;
    transform: translateY(-2px);
}

.sort-info {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
}

.note-history {
    overflow-x: auto;
}

.history-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.95rem;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.history-table thead {
    background: var(--background);
    position: sticky;
    top: 0;
    z-index: 10;
}

.history-table th {
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.8rem;
    border-bottom: 2px solid var(--primary-color);
}

.history-table th:first-child {
    border-top-left-radius: 8px;
}

.history-table th:last-child {
    border-top-right-radius: 8px;
}

.history-table td {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.history-table tbody tr:last-child td {
    border-bottom: none;
}

.history-table tbody tr:last-child td:first-child {
    border-bottom-left-radius: 8px;
}

.history-table tbody tr:last-child td:last-child {
    border-bottom-right-radius: 8px;
}

.history-row {
    background: var(--background);
    transition: all 0.2s ease;
}

.history-row:hover {
    background: rgba(99, 102, 241, 0.1);
    transform: scale(1.01);
}

.history-row.top-1 {
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.15), var(--background));
}

.history-row.top-1:hover {
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.25), rgba(99, 102, 241, 0.1));
}

.history-row.top-2 {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.15), var(--background));
}

.history-row.top-2:hover {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.25), rgba(99, 102, 241, 0.1));
}

.history-row.top-3 {
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.15), var(--background));
}

.history-row.top-3:hover {
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.25), rgba(99, 102, 241, 0.1));
}

.rank-cell {
    font-weight: 700;
    color: var(--primary-color);
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
}

.note-cell {
    font-weight: 700;
    font-family: 'Courier New', monospace;
}

.note-link {
    text-decoration: none;
    display: inline-block;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.note-link:hover {
    background: rgba(99, 102, 241, 0.2);
    transform: scale(1.05);
}

.note-name-cell {
    font-size: 1.3rem;
    color: var(--text-primary);
}

.octave-cell {
    color: var(--text-secondary);
    font-family: 'Courier New', monospace;
}

.duration-cell {
    font-family: 'Courier New', monospace;
    color: var(--text-primary);
    font-weight: 600;
}

.confidence-cell {
    min-width: 150px;
}

.confidence-bar-cell {
    position: relative;
    height: 28px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
    overflow: hidden;
}

.confidence-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--accent-sad), var(--primary-color), var(--accent-happy));
    transition: width 0.3s ease;
    border-radius: 6px;
}

.confidence-text {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-primary);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    z-index: 1;
}

.count-cell {
    font-family: 'Courier New', monospace;
    color: var(--text-secondary);
    font-weight: 600;
}

.score-cell {
    font-weight: 700;
    font-size: 1.2rem;
    font-family: 'Courier New', monospace;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-dreamy));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: right;
}

.action-cell {
    text-align: center;
}

.action-button {
    display: inline-block;
    padding: 8px 16px;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.action-button:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(99, 102, 241, 0.3);
}

/* Browser Support */
.browser-support {
    background: var(--surface-light);
    border-radius: 12px;
    padding: 20px;
    margin-top: 24px;
}

.browser-support h4 {
    color: var(--text-primary);
    margin-bottom: 12px;
    font-size: 1.1rem;
}

.browser-support p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 6px;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.9;
        transform: scale(0.98);
    }
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .main-nav {
        gap: 8px;
        padding: 15px 10px;
    }

    .nav-link {
        padding: 8px 12px;
        font-size: 0.9rem;
    }

    h1 {
        font-size: 2.5rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .main-card {
        padding: 24px;
    }

    .instructions {
        padding: 20px;
    }

    .pitch-button {
        padding: 16px 36px;
        font-size: 1.1rem;
    }

    .note-name {
        font-size: 3.5rem;
    }

    .metrics-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .metric-card {
        padding: 10px 14px;
    }

    .history-table {
        font-size: 0.85rem;
    }

    .history-table th,
    .history-table td {
        padding: 12px 10px;
    }

    .note-name-cell {
        font-size: 1.1rem;
    }

    .score-cell {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    body {
        padding: 12px;
    }

    .main-nav {
        gap: 6px;
        padding: 10px 5px;
    }

    .nav-link {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    h1 {
        font-size: 2rem;
    }

    .header-icon {
        font-size: 3rem;
    }

    .main-card {
        padding: 20px;
    }

    .instructions {
        padding: 16px;
    }

    .pitch-button {
        padding: 14px 24px;
        font-size: 1rem;
    }

    .note-container {
        padding: 30px 20px;
    }

    .note-name {
        font-size: 3rem;
        letter-spacing: 4px;
    }

    #waveform {
        height: 100px;
    }

    .note-history-section {
        padding: 16px;
    }

    .history-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .history-controls {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .sort-toggle {
        width: 100%;
        justify-content: center;
    }

    .sort-option {
        flex: 1;
        justify-content: center;
        font-size: 0.8rem;
        padding: 8px 10px;
    }

    .clear-button {
        width: 100%;
    }

    .note-history {
        margin: 0 -16px;
        padding: 0 16px;
    }

    .history-table {
        font-size: 0.75rem;
    }

    .history-table th,
    .history-table td {
        padding: 10px 8px;
    }

    .history-table th {
        font-size: 0.7rem;
    }

    .rank-cell {
        font-size: 0.9rem;
    }

    .note-name-cell {
        font-size: 1rem;
    }

    .confidence-cell {
        min-width: 100px;
    }

    .confidence-bar-cell {
        height: 24px;
    }

    .confidence-text {
        font-size: 0.75rem;
    }

    .score-cell {
        font-size: 0.95rem;
    }

    .action-button {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
}
