/* Theme Variables */
:root {
    /* Dark theme (default) */
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-tertiary: #0f3460;
    --text-primary: #eee;
    --text-secondary: #888;
    --text-tertiary: #666;
    --accent-primary: #e94560;
    --accent-hover: #d63750;
    --border-color: #333;
    --border-hover: #444;
    --error-bg: #3d1f2b;
    --error-text: #ff6b8a;
}

/* Light theme */
.light-theme {
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8e8e8;
    --text-primary: #1a1a1a;
    --text-secondary: #666;
    --text-tertiary: #999;
    --accent-primary: #e94560;
    --accent-hover: #d63750;
    --border-color: #ddd;
    --border-hover: #ccc;
    --error-bg: #ffe8ec;
    --error-text: #c92a2a;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 1rem;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 0.5rem;
}

header {
    text-align: center;
    margin-bottom: 2rem;
    position: relative;
}

header > div {
    display: block;
}

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

header p {
    color: var(--text-secondary);
}

/* Header controls container */
.header-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    position: absolute;
    top: 0;
    right: 0;
}

/* Format selector */
.format-selector {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    font-weight: 600;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 44px;
}

.format-selector:hover {
    border-color: var(--accent-primary);
}

.format-selector:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.theme-toggle {
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem;
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
    transition: all 0.2s;
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.theme-toggle:hover {
    border-color: var(--accent-primary);
    transform: scale(1.1);
}

.search-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.search-form input {
    flex: 1;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
}

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

.search-form button {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    min-height: 44px;
    min-width: 44px;
}

.search-form button:hover {
    background: var(--accent-hover);
}

.status {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    display: none;
}

.status.info {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

.status.error {
    background: var(--error-bg);
    border: 1px solid var(--accent-primary);
    color: var(--error-text);
}

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

.track {
    display: flex;
    align-items: center;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    gap: 0.75rem;
}

.track:hover {
    border-color: var(--border-hover);
}

.track-main {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}

.track-cover {
    width: 80px;
    height: 80px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--bg-tertiary);
}

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

.track-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    word-break: break-word;
}

.track-artist {
    color: var(--text-secondary);
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    word-break: break-word;
}

.track-meta {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-top: 0.25rem;
    font-size: 0.85rem;
    color: var(--text-tertiary);
}

.track-duration {
    color: var(--text-tertiary);
}

.track-views {
    color: var(--text-tertiary);
}

/* Track actions container */
.track-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-shrink: 0;
}

/* Play button */
.play-btn {
    padding: 0;
    font-size: 1.2rem;
    font-weight: 600;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    min-height: 44px;
    min-width: 44px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    text-indent: 2px;
}

.play-btn:hover:not(:disabled) {
    background: var(--accent-primary);
    color: white;
    transform: scale(1.05);
}

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

.download-btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
    min-height: 44px;
    min-width: 100px;
    flex-shrink: 0;
}

.download-btn:hover:not(:disabled) {
    background: var(--accent-primary);
    color: white;
}

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

/* Save to Computer button variant */
.download-btn.save-btn {
    background: var(--accent-primary);
    color: white;
    animation: pulse 2s ease-in-out infinite;
}

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

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

/* Responsive Design - Mobile First */

/* Very small screens (< 480px) */
@media (max-width: 480px) {
    header h1 {
        font-size: 1.75rem;
    }

    .header-controls {
        position: static;
        margin: 1rem auto 0;
        justify-content: center;
    }

    .format-selector {
        flex: 1;
    }

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

    .search-form button {
        width: 100%;
    }
}

/* Small screens (< 640px) */
@media (max-width: 640px) {
    header > div {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

    .header-controls {
        position: static;
        justify-content: center;
    }

    .track {
        padding: 0.75rem;
        flex-direction: column;
        align-items: stretch;
    }

    .track-main {
        margin-bottom: 0.75rem;
    }

    .track-cover {
        width: 60px;
        height: 60px;
    }

    .track-actions {
        width: 100%;
        flex-direction: row;
        justify-content: stretch;
    }

    .play-btn {
        flex: 0 0 auto;
    }

    .download-btn {
        flex: 1;
        min-width: unset;
    }
}

/* Tablet (640px - 1024px) */
@media (min-width: 640px) {
    .container {
        padding: 0 1rem;
    }

    .track {
        padding: 1.25rem;
    }

    header h1 {
        font-size: 2.5rem;
    }
}

/* Desktop (> 1024px) */
@media (min-width: 1024px) {
    body {
        padding: 2rem;
    }
}

/* Desktop - single line for cleaner look */
@media (min-width: 1024px) {
    .track-title,
    .track-artist {
        white-space: nowrap;
        text-overflow: ellipsis;
        -webkit-line-clamp: 1;
        line-clamp: 1;
    }
}
