/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6200ea;
    --primary-dark: #4a00b0;
    --primary-light: #7c3aed;
    --secondary-color: #03dac6;
    --background: #ffffff;
    --surface: #f5f5f5;
    --error: #b00020;
    --on-primary: #ffffff;
    --on-background: #000000;
    --on-surface: #000000;
    --border-color: #e0e0e0;
    --shadow: rgba(0, 0, 0, 0.1);
}

@media (prefers-color-scheme: dark) {
    :root {
        --background: #121212;
        --surface: #1e1e1e;
        --on-background: #ffffff;
        --on-surface: #ffffff;
        --border-color: #333333;
        --shadow: rgba(255, 255, 255, 0.1);
    }
}

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

/* Screen Reader Only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
}

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

header h1 {
    color: var(--primary-color);
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--on-background);
    opacity: 0.7;
    font-size: 1.1rem;
}

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

/* Search Section */
.search-section {
    margin-bottom: 2rem;
}

#search-form {
    display: flex;
    gap: 0.5rem;
    max-width: 600px;
    margin: 0 auto;
}

#search-input {
    flex: 1;
    padding: 1rem;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--surface);
    color: var(--on-surface);
    transition: border-color 0.3s ease;
}

#search-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

#search-form button {
    padding: 1rem 1.5rem;
    background-color: var(--primary-color);
    color: var(--on-primary);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background-color 0.3s ease, transform 0.1s ease;
}

#search-form button:hover {
    background-color: var(--primary-dark);
}

#search-form button:active {
    transform: scale(0.98);
}

#search-form button:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Current Track */
.current-track {
    margin-bottom: 1.5rem;
    background-color: var(--surface);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px var(--shadow);
}

.track-info-display {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.cover-placeholder {
    width: 80px;
    height: 80px;
    background-color: var(--border-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--on-surface);
    opacity: 0.5;
    flex-shrink: 0;
}

.cover-image {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

.track-details {
    flex: 1;
    min-width: 0;
}

.track-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--on-surface);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track-artist {
    font-size: 1rem;
    color: var(--on-surface);
    opacity: 0.7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.no-track-message {
    color: var(--on-surface);
    opacity: 0.6;
    font-style: italic;
}

/* Audio Player */
.player-section {
    margin-bottom: 1.5rem;
}

#audio-player {
    width: 100%;
    height: 54px;
    border-radius: 8px;
    background-color: var(--surface);
}

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

.control-btn {
    padding: 0.75rem 1.5rem;
    background-color: var(--surface);
    color: var(--on-surface);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.control-btn:hover:not(:disabled) {
    background-color: var(--primary-color);
    color: var(--on-primary);
    border-color: var(--primary-color);
}

.control-btn:active:not(:disabled) {
    transform: scale(0.98);
}

.control-btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

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

/* Search Results */
.results-section {
    margin-bottom: 2rem;
}

#search-results {
    display: grid;
    gap: 1rem;
}

.result-item {
    background-color: var(--surface);
    border-radius: 8px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    display: flex;
    gap: 1rem;
    align-items: center;
}

.result-item:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px var(--shadow);
}

.result-item:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.result-cover {
    width: 60px;
    height: 60px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
    background-color: var(--border-color);
}

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

.result-title {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.25rem;
    color: var(--on-surface);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-artist {
    font-size: 0.9rem;
    color: var(--on-surface);
    opacity: 0.7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-duration {
    font-size: 0.85rem;
    color: var(--on-surface);
    opacity: 0.6;
    flex-shrink: 0;
}

/* Loading State */
.loading {
    text-align: center;
    padding: 2rem;
    color: var(--on-surface);
    opacity: 0.7;
}

/* Error State */
.error {
    background-color: var(--error);
    color: var(--on-primary);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    text-align: center;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--on-surface);
    opacity: 0.6;
    font-style: italic;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem 0 1rem;
    color: var(--on-background);
    opacity: 0.6;
    margin-top: auto;
}

/* Responsive Design */
@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    #search-form {
        flex-direction: column;
    }

    #search-form button {
        justify-content: center;
    }

    .track-info-display {
        flex-direction: column;
        text-align: center;
    }

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

    .control-btn {
        width: 100%;
        justify-content: center;
    }

    .result-item {
        flex-direction: column;
        text-align: center;
    }

    .result-cover {
        width: 80px;
        height: 80px;
    }
}

/* Focus Visible - Better accessibility */
*:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Results Headers */
.results-header {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 1.5rem 0 1rem;
    color: var(--primary-color);
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
}

.results-header:first-child {
    margin-top: 0;
}

/* Correction Notice */
.correction-notice {
    background-color: var(--surface);
    border-left: 4px solid var(--secondary-color);
    padding: 1rem;
    margin-bottom: 1.5rem;
    border-radius: 4px;
    color: var(--on-surface);
}

.correction-notice strong {
    color: var(--primary-color);
}

/* Album and Artist Items */
.album-item, .artist-item {
    border-left: 4px solid var(--secondary-color);
}

.album-item:hover, .artist-item:hover {
    border-left-color: var(--primary-color);
}

/* Result Metadata */
.result-meta {
    font-size: 0.85rem;
    color: var(--on-surface);
    opacity: 0.6;
    margin-top: 0.25rem;
}

.result-album-link {
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

.result-album-link a {
    color: var(--primary-color);
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.result-album-link a:hover {
    text-decoration: underline;
    opacity: 0.8;
}

.result-album-link a:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: 2px;
}

/* Back Button */
.back-button {
    background-color: var(--surface);
    color: var(--on-surface);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    margin-bottom: 1rem;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.back-button:hover {
    background-color: var(--primary-color);
    color: var(--on-primary);
    border-color: var(--primary-color);
}

.back-button:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}


/* ── Active / now-playing track highlight ─────────────────────────────────── */
.result-item.active {
    border-left: 4px solid var(--primary-color);
    background-color: color-mix(in srgb, var(--primary-color) 10%, var(--surface));
    padding-left: calc(1rem - 4px);
}

.result-item.active .result-title {
    color: var(--primary-color);
    font-weight: 700;
}

/* ── Share link buttons ───────────────────────────────────────────────────── */
.icon-btn {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    color: var(--on-surface);
    opacity: 0.7;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    opacity: 1;
    background-color: var(--primary-color);
    color: var(--on-primary);
    border-color: var(--primary-color);
}

.icon-btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.share-btn-inline {
    background-color: transparent;
}

/* ── ZIP download button ────────────────────────────────────────────────────── */
.zip-btn {
    background-color: var(--secondary-color);
    color: #000;
    border: none;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    transition: opacity 0.2s;
}

.zip-btn:hover {
    opacity: 0.85;
}

.zip-btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}
