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

:root {
    --cd-silver: #e0e0e8;
    --cd-reflection: linear-gradient(135deg, #e8e8f0 0%, #d0d0e0 25%, #c0c0d8 50%, #d0d0e0 75%, #e8e8f0 100%);
    --cd-shadow: rgba(0, 0, 0, 0.3);
    --cd-border: #a0a0b0;
    --accent-blue: #4a90e2;
    --accent-purple: #9b59b6;
    --text-dark: #2c3e50;
    --text-light: #7f8c8d;
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --panel-bg: rgba(255, 255, 255, 0.95);
    --hover-bg: rgba(74, 144, 226, 0.1);
    --selected-bg: rgba(155, 89, 182, 0.15);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-image: url('images/blurred-room-with-lamps-armchairs.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: repeat-y;
    color: var(--text-dark);
    min-height: 100vh;
    line-height: 1.6;
}

/* ===========================
   Container & Layout
   =========================== */
.container {
    max-width: 100%;
    width: 100%;
    margin: 0 auto;
    padding: 20px;
}

@media (min-width: 900px) {
    .container {
        max-width: 1400px;
    }
}

header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 5px;
    font-weight: 700;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* ===========================
   Error Message
   =========================== */
.error-message {
    background: rgba(231, 76, 60, 0.9);
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

/* ===========================
   Main Content Layout
   =========================== */
.main-content {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

/* Mobile first: Track panel on top */
@media (max-width: 899px) {
    .main-content {
        flex-direction: column-reverse;
    }
}

/* Desktop: No special layout needed for modal (centered by default) */
@media (min-width: 900px) {
    .main-content {
        flex-direction: row;
    }
    
    .album-list-container {
        flex: 1;
        max-width: 1000px;
    }
}

/* ===========================
   Album Stats
   =========================== */
.album-stats {
    background: var(--panel-bg);
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    text-align: center;
    font-size: 0.95rem;
    color: var(--text-light);
}

/* ===========================
   Album List (CD Stack)
   =========================== */
.album-list-container {
    min-width: 0; /* Prevent flex overflow */
}

.album-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.album-item {
    /* Background color will be set via inline style */
    border: none;
    border-radius: 8px;
    padding: 0;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 15px;
    box-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    background-image: url('images/cd-case-spine.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* CD case shine effect */
.album-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left 0.5s ease;
    pointer-events: none;
}

.album-item:hover::before {
    left: 100%;
}

.album-item:hover {
    transform: translateY(-2px) translateX(3px);
    box-shadow: 
        0 4px 8px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.album-item.selected {
    transform: translateX(5px);
    box-shadow: 
        0 4px 12px rgba(155, 89, 182, 0.5),
        inset 0 0 0 2px rgba(155, 89, 182, 0.6);
}

.album-info {
    flex: 1;
    min-width: 0;
    padding: 0 20px;
    display: flex;
    align-items: center;
}

.album-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: #2c3e50;
    text-decoration: none;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.2s ease;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
    width: 100%;
    text-align: center;
}

.album-name:hover {
    color: var(--accent-purple);
    transform: scale(1.02);
}

.open-btn {
    border: none;
    width: 32px;
    height: 32px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-right: 12px;
    margin-left: 48px;
    background: url('images/play-button.png') no-repeat center center;
    background-size: contain;
    padding: 0;
}

.open-btn:hover {
    transform: scale(1.15);
    filter: brightness(1.2) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.open-btn:active {
    transform: scale(0.95);
}

.open-btn:focus {
    outline: 2px solid var(--accent-purple);
    outline-offset: 2px;
}

/* ===========================
   Track Modal
   =========================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.track-modal {
    position: relative;
    width: 700px;
    height: 600px;
    background-image: url('images/cd-case-back.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

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

.modal-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1.3rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.modal-close-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

.modal-close-btn:focus {
    outline: 2px solid white;
    outline-offset: 2px;
}

.track-modal-content {
    padding: 30px;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

.modal-header {
    display: flex;
    align-items: flex-start;
    margin-bottom: 20px;
}

.album-thumbnail {
    position: absolute;
    top: 30px;
    right: 50px;
    width: 120px;
    height: 120px;
    border-radius: 8px;
    object-fit: cover;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    z-index: 5;
}

.modal-title {
    text-align: left;
    text-shadow: 0 2px 4px rgba(255, 255, 255, 0.8);
    padding-right: 140px;
    flex: 1;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    line-height: 1.2;
}

.modal-artist {
    font-size: 1.1rem;
    font-weight: 600;
    color: #555;
}

.modal-album {
    font-size: 1.4rem;
    font-weight: 700;
    color: #2c3e50;
}

.track-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 15px;
    background: rgba(255, 255, 255, 0.85);
    border-radius: 8px;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.1);
}

.track-item {
    padding: 4px 10px;
    margin-bottom: 2px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: space-between;
    background: transparent;
}

.track-item:hover {
    background: rgba(255, 255, 255, 0.3);
}

.track-name {
    color: var(--text-dark);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.play-btn {
    border: none;
    width: 28px;
    height: 28px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-right: 10px;
    background: url('images/play-button.png') no-repeat center center;
    background-size: contain;
    padding: 0;
}

.play-btn-placeholder {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    margin-right: 10px;
}

.play-btn:hover {
    transform: scale(1.2);
    filter: brightness(1.2) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.play-btn:active {
    transform: scale(0.95);
}

.play-btn:focus {
    outline: 2px solid var(--accent-purple);
    outline-offset: 2px;
}

/* Custom scrollbar for track list */
.track-list::-webkit-scrollbar {
    width: 8px;
}

.track-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
}

.track-list::-webkit-scrollbar-thumb {
    background: var(--accent-purple);
    border-radius: 4px;
}

.track-list::-webkit-scrollbar-thumb:hover {
    background: var(--accent-blue);
}

/* ===========================
   Responsive Design
   =========================== */
@media (max-width: 899px) {
    header h1 {
        font-size: 2rem;
    }
    
    .album-item {
        height: 55px;
    }
    
    .album-name {
        font-size: 0.9rem;
    }
    
    .open-btn {
        width: 30px;
        height: 30px;
        font-size: 0.75rem;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 15px;
    }
    
    header h1 {
        font-size: 1.75rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .album-item {
        height: 50px;
    }
    
    .album-name {
        font-size: 0.85rem;
    }
    
    .open-btn {
        width: 28px;
        height: 28px;
        font-size: 0.7rem;
        margin-right: 6px;
    }
    
    .track-modal {
        width: 95%;
        max-width: 700px;
        height: 85vh;
        max-height: 85vh;
    }
    
    .album-thumbnail {
        width: 80px;
        height: 80px;
        top: 20px;
        right: 20px;
    }
    
    .modal-title {
        font-size: 1.1rem;
        padding-right: 90px;
    }
    
    .track-modal-content {
        padding: 20px;
    }
    
    .track-name {
        font-size: 0.9rem;
    }
}

/* ===========================
   Loading Animation
   =========================== */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

.loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 1000px 100%;
    animation: shimmer 2s infinite;
}

/* ===========================
   Accessibility
   =========================== */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* Focus visible styles for keyboard navigation */
*:focus-visible {
    outline: 2px solid var(--accent-purple);
    outline-offset: 2px;
}
