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

:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #e0e7ff;
    --secondary-color: #10b981;
    --secondary-hover: #059669;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-hover: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #334155;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.2);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.2s ease;
}

html {
    scroll-behavior: smooth;
}

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

.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header Styles */
.header {
    text-align: center;
    padding: 2rem 1rem;
    background: linear-gradient(135deg, var(--surface) 0%, var(--background) 100%);
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.logo-icon {
    width: 40px;
    height: 40px;
    color: var(--primary-color);
}

.logo h1 {
    font-size: 1.75rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

/* Main Content */
.main-content {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
    width: 100%;
}

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

.search-container {
    display: flex;
    gap: 0.75rem;
    max-width: 700px;
    margin: 0 auto;
}

.search-input {
    flex: 1;
    padding: 1rem 1.25rem;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-primary);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.search-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background: var(--primary-color);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background var(--transition), transform var(--transition);
}

.search-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.search-btn svg {
    width: 20px;
    height: 20px;
}

/* Categories Section */
.categories-section {
    margin-bottom: 2rem;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.results-count {
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--text-secondary);
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
}

.category-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--surface);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}

.category-btn:hover {
    background: var(--surface-hover);
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.category-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.category-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

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

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}

.sort-options {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sort-options label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.sort-select {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

/* Sound Card */
.sound-card {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.25rem;
    transition: all var(--transition);
    cursor: pointer;
}

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

.sound-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.sound-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.sound-duration {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: var(--background);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    white-space: nowrap;
}

.sound-author {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.sound-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-bottom: 1rem;
}

.sound-tag {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--background);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

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

.action-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.625rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}

.action-btn svg {
    width: 16px;
    height: 16px;
}

.play-btn {
    background: var(--primary-color);
    color: white;
}

.play-btn:hover {
    background: var(--primary-hover);
}

.play-btn.playing {
    background: var(--secondary-color);
}

.info-btn {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.info-btn:hover {
    background: var(--border-color);
}

/* Loading State */
.loading {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.loading.show {
    display: flex;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* No Results */
.no-results {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--text-secondary);
    text-align: center;
}

.no-results.show {
    display: flex;
}

.no-results svg {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    padding: 1rem;
    overflow-y: auto;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 500px;
    width: 100%;
    position: relative;
    animation: modalIn 0.3s ease;
}

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

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 32px;
    height: 32px;
    background: var(--background);
    border: none;
    border-radius: 50%;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.modal-close:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.player-info {
    margin-bottom: 1.25rem;
    padding-right: 2rem;
}

.player-info h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.player-author {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.audio-player {
    margin-bottom: 1.25rem;
}

.audio-player audio {
    width: 100%;
    height: 40px;
    border-radius: var(--radius-sm);
}

.waveform {
    height: 60px;
    background: var(--background);
    border-radius: var(--radius-sm);
    margin-top: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.waveform-bars {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 100%;
    padding: 0.5rem;
}

.waveform-bar {
    width: 3px;
    background: var(--primary-color);
    border-radius: 2px;
    animation: waveform 0.5s ease infinite alternate;
}

@keyframes waveform {
    from { transform: scaleY(0.3); }
    to { transform: scaleY(1); }
}

.player-details {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    padding: 1rem;
    background: var(--background);
    border-radius: var(--radius-sm);
}

.detail-item {
    text-align: center;
}

.detail-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.detail-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.attribution-box {
    background: var(--background);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-bottom: 1.25rem;
}

.attribution-box h4 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.attribution-box p {
    font-size: 0.85rem;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    word-break: break-word;
}

.copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}

.copy-btn:hover {
    background: var(--surface-hover);
    border-color: var(--primary-color);
}

.copy-btn svg {
    width: 14px;
    height: 14px;
}

.download-options {
    margin-bottom: 1.25rem;
}

.download-options h4 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
}

.download-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.download-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.download-btn svg {
    width: 18px;
    height: 18px;
}

.download-btn.primary {
    background: var(--secondary-color);
    color: white;
}

.download-btn.primary:hover {
    background: var(--secondary-hover);
}

.download-btn.secondary {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.download-btn.secondary:hover {
    background: var(--border-color);
}

.source-link {
    display: block;
    text-align: center;
    color: var(--primary-color);
    font-size: 0.9rem;
    text-decoration: none;
    transition: color var(--transition);
}

.source-link:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--surface);
    color: var(--text-primary);
    padding: 0.875rem 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s ease;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Footer */
.footer {
    background: var(--surface);
    border-top: 1px solid var(--border-color);
    padding: 1.5rem 1rem;
    text-align: center;
}

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

.footer-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.footer-text a {
    color: var(--primary-color);
    text-decoration: none;
}

.footer-text a:hover {
    text-decoration: underline;
}

.footer-powered {
    font-size: 0.875rem;
    color: var(--text-muted);
}

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

.footer-powered a:hover {
    text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header {
        padding: 1.5rem 1rem;
    }

    .logo h1 {
        font-size: 1.5rem;
    }

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

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

    .categories-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }

    .results-grid {
        grid-template-columns: 1fr;
    }

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

    .player-details {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .detail-item {
        display: flex;
        justify-content: space-between;
        text-align: left;
    }

    .modal-content {
        padding: 1.25rem;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 1rem;
    }

    .category-btn {
        padding: 0.75rem;
        font-size: 0.8rem;
    }

    .sound-card {
        padding: 1rem;
    }

    .sound-actions {
        flex-direction: column;
    }

    .action-btn {
        width: 100%;
    }
}

/* 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 for keyboard navigation */
:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}
