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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: #212121;
    background-color: #F5F5F5;
}

/* Color Variables */
:root {
    --primary: #BA478F;
    --secondary: #6B4C9A;
    --background: #F5F5F5;
    --surface: #FFFFFF;
    --text: #212121;
    --border: #E0E0E0;
    --success: #4CAF50;
    --warning: #FF9800;
    --error: #F44336;
}

/* Header */
.header {
    background-color: var(--primary);
    color: white;
    padding: 20px 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-title {
    font-size: 24px;
    font-weight: 600;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.queue-status {
    background-color: rgba(255,255,255,0.2);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    transition: transform 0.3s;
}

.btn-icon:hover {
    transform: scale(1.1);
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Search Section */
.search-section {
    background-color: var(--surface);
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.search-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.search-type-select {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 16px;
    background-color: white;
    cursor: pointer;
    min-width: 150px;
}

.search-input {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 16px;
}

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

/* Buttons */
.btn-primary, .btn-secondary, .btn-text {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
    min-height: 44px;
}

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

.btn-primary:hover {
    background-color: #9a3a75;
}

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

.btn-secondary:hover {
    background-color: #563d7c;
}

.btn-secondary:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.btn-text {
    background: none;
    color: var(--primary);
    padding: 5px 10px;
}

.btn-text:hover {
    text-decoration: underline;
}

/* Advanced Filters */
.advanced-filters {
    margin-top: 15px;
}

.filter-toggle {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 14px;
    padding: 5px 0;
}

.filter-content {
    display: flex;
    gap: 15px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.filter-group label {
    font-size: 14px;
    font-weight: 500;
}

.filter-group input,
.filter-group select {
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 14px;
}

/* Main Layout */
.main-layout {
    display: grid;
    grid-template-columns: 250px 1fr 500px;
    gap: 20px;
}

/* Sidebar */
.sidebar {
    background-color: var(--surface);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    height: fit-content;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.sidebar-header h3 {
    font-size: 16px;
}

.recent-searches {
    list-style: none;
}

.recent-search-item {
    padding: 10px;
    margin-bottom: 8px;
    background-color: #f9f9f9;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.recent-search-item:hover {
    background-color: #f0f0f0;
}

.type-badge {
    display: inline-block;
    padding: 2px 8px;
    background-color: var(--secondary);
    color: white;
    border-radius: 12px;
    font-size: 12px;
    width: fit-content;
}

.recent-search-item .query {
    font-weight: 500;
}

.recent-search-item .timestamp {
    font-size: 12px;
    color: #666;
}

.cache-stats {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    font-size: 14px;
}

/* Results Panel */
.results-panel {
    background-color: var(--surface);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.results-header h2 {
    font-size: 20px;
    margin-bottom: 20px;
}

.results-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.result-card {
    padding: 20px;
    background-color: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.result-card:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    transform: translateY(-2px);
}

.result-card-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 10px;
}

.result-card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

.result-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.result-card-meta span {
    font-size: 14px;
    color: #666;
}

.mbid {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: #999;
}

.disambiguation {
    font-style: italic;
    color: #666;
    font-size: 14px;
}

.score {
    background-color: var(--success);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.page-info {
    font-size: 14px;
}

/* Detail Panel */
.detail-panel {
    background-color: var(--surface);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 20px;
}

.detail-title {
    font-size: 24px;
    font-weight: 600;
}

.btn-close {
    background: none;
    border: none;
    font-size: 32px;
    cursor: pointer;
    color: #999;
    line-height: 1;
}

.btn-close:hover {
    color: var(--text);
}

.detail-section {
    margin-bottom: 30px;
}

.detail-section h3 {
    font-size: 18px;
    margin-bottom: 15px;
    color: var(--primary);
}

.detail-section h4 {
    font-size: 16px;
    margin-bottom: 10px;
    margin-top: 15px;
}

.detail-info {
    display: grid;
    gap: 10px;
}

.detail-info-row {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 10px;
}

.detail-info-label {
    font-weight: 600;
    color: #666;
}

.detail-info-value {
    color: var(--text);
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    padding: 4px 12px;
    background-color: var(--secondary);
    color: white;
    border-radius: 16px;
    font-size: 14px;
}

.related-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.related-item {
    padding: 12px;
    background-color: #f9f9f9;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.related-item:hover {
    background-color: #f0f0f0;
}

.related-item-title {
    font-weight: 500;
    color: var(--primary);
}

.related-item-meta {
    font-size: 14px;
    color: #666;
    margin-top: 5px;
}

.cover-art {
    width: 100%;
    max-width: 250px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.tracklist {
    list-style: none;
}

.track-item {
    padding: 8px;
    border-bottom: 1px solid var(--border);
    display: grid;
    grid-template-columns: 40px 1fr auto;
    gap: 10px;
    align-items: center;
}

.track-position {
    font-weight: 600;
    color: #666;
}

.track-title {
    cursor: pointer;
    color: var(--primary);
}

.track-title:hover {
    text-decoration: underline;
}

.track-length {
    color: #666;
    font-size: 14px;
}

.link-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.link-item {
    color: var(--primary);
    text-decoration: none;
}

.link-item:hover {
    text-decoration: underline;
}

.isrc-code {
    font-family: 'Courier New', monospace;
    background-color: #f9f9f9;
    padding: 8px;
    border-radius: 4px;
    display: inline-block;
    margin-right: 10px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-state p {
    font-size: 18px;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background-color: white;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 20px;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 16px;
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: #666;
    font-size: 14px;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-message {
    color: white;
    margin-top: 20px;
    font-size: 18px;
}

/* Toast */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background-color: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 300px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left: 4px solid var(--error);
}

.toast.warning {
    border-left: 4px solid var(--warning);
}

.toast.info {
    border-left: 4px solid var(--primary);
}

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

.footer p {
    margin: 5px 0;
}

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

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

.rate-limit-notice {
    font-size: 14px;
    color: #666;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .main-layout {
        grid-template-columns: 1fr 400px;
    }
    
    .sidebar {
        display: none;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .header-content {
        padding: 0 10px;
    }
    
    .app-title {
        font-size: 18px;
    }
    
    .search-section {
        padding: 15px;
    }
    
    .search-controls {
        flex-direction: column;
    }
    
    .main-layout {
        grid-template-columns: 1fr;
    }
    
    .detail-panel {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 100;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .filter-content {
        flex-direction: column;
    }
    
    .toast-container {
        right: 10px;
        left: 10px;
    }
    
    .toast {
        min-width: auto;
    }
}

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

.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;
}
