/* CSS Variables */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --danger-color: #ef4444;
    --danger-hover: #dc2626;
    --success-color: #22c55e;
    --success-hover: #16a34a;
    --warning-color: #f59e0b;
    --warning-hover: #d97706;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-hover: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #334155;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4), 0 4px 6px -4px rgb(0 0 0 / 0.4);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.2s ease;
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Base Styles */
html {
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* Container */
.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 2rem 1rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--primary-color), #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

/* Main Content */
main {
    flex: 1;
}

/* Waveform Container */
.waveform-container {
    position: relative;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
    overflow: hidden;
}

#waveform {
    width: 100%;
    height: 120px;
    display: block;
}

.waveform-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.7);
    color: var(--text-secondary);
    font-size: 0.9rem;
    transition: var(--transition);
}

.waveform-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Timer Container */
.timer-container {
    text-align: center;
    margin-bottom: 1.5rem;
}

#timer {
    font-size: 3rem;
    font-weight: 700;
    font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
    letter-spacing: 0.05em;
    display: block;
    margin-bottom: 0.5rem;
}

.status {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--surface);
    color: var(--text-secondary);
}

.status.recording {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger-color);
    animation: pulse 1.5s infinite;
}

.status.paused {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning-color);
}

.status.stopped {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success-color);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Controls */
.controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

/* Buttons */
.btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    background: var(--surface);
    color: var(--text-primary);
}

.btn:hover:not(:disabled) {
    background: var(--surface-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn:active:not(:disabled) {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn .icon {
    width: 24px;
    height: 24px;
}

/* Button Variants */
.btn-record {
    background: var(--danger-color);
}

.btn-record:hover:not(:disabled) {
    background: var(--danger-hover);
}

.btn-record.recording {
    animation: recordPulse 1s infinite;
}

@keyframes recordPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
    50% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
}

.btn-stop {
    background: var(--surface);
}

.btn-pause {
    background: var(--warning-color);
    color: #000;
}

.btn-pause:hover:not(:disabled) {
    background: var(--warning-hover);
}

.btn-download {
    background: var(--success-color);
    color: #000;
}

.btn-download:hover:not(:disabled) {
    background: var(--success-hover);
}

.btn-delete {
    background: var(--danger-color);
}

.btn-delete:hover:not(:disabled) {
    background: var(--danger-hover);
}

/* Playback Section */
.playback-section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
    display: none;
}

.playback-section.visible {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

.playback-section h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

#audioPlayer {
    width: 100%;
    margin-bottom: 1rem;
    border-radius: var(--radius-sm);
}

/* Custom audio player styling for webkit browsers */
audio::-webkit-media-controls-panel {
    background: var(--surface-hover);
}

.playback-controls {
    display: flex;
    gap: 0.75rem;
}

.playback-controls .btn {
    flex: 1;
    flex-direction: row;
    padding: 0.75rem 1rem;
}

.playback-controls .btn .icon {
    width: 18px;
    height: 18px;
}

/* Recordings Section */
.recordings-section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.recordings-section h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.recordings-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.empty-message {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: center;
    padding: 1rem;
}

.recording-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    background: var(--surface-hover);
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.recording-item:hover {
    background: var(--border);
}

.recording-info {
    flex: 1;
    min-width: 0;
}

.recording-name {
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recording-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.recording-actions {
    display: flex;
    gap: 0.5rem;
}

.recording-actions .btn {
    padding: 0.5rem;
    flex-direction: row;
}

.recording-actions .btn span {
    display: none;
}

.recording-actions .btn .icon {
    width: 16px;
    height: 16px;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem 0 1rem;
    margin-top: auto;
}

footer p {
    color: var(--text-muted);
    font-size: 0.85rem;
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

footer a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .container {
        padding: 1rem;
    }

    header h1 {
        font-size: 1.5rem;
    }

    #timer {
        font-size: 2.5rem;
    }

    .controls {
        gap: 0.75rem;
    }

    .btn {
        padding: 0.875rem 1rem;
        font-size: 0.8rem;
    }

    .btn .icon {
        width: 20px;
        height: 20px;
    }

    #waveform {
        height: 80px;
    }

    .playback-controls {
        flex-direction: column;
    }

    .playback-controls .btn {
        justify-content: center;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles */
.btn:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* High contrast mode */
@media (prefers-contrast: high) {
    :root {
        --surface: #000;
        --surface-hover: #1a1a1a;
        --border: #fff;
    }
}
