/* ============================================
   MUSIC APP — Comic Flat Theme
   ============================================
   Design: Sharp corners, comic shadows, black
   borders, bold typography, playful aesthetic.
   Mobile-first responsive approach.
   ============================================ */

/* --- Animations --- */
@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

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

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

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

/* --- Layout --- */
.music-app {
    display: flex;
    min-height: calc(100vh - 60px);
    position: relative;
}

.music-sidebar {
    display: none;
    width: 240px;
    min-width: 240px;
    background: #fff;
    border-right: 3px solid #000;
    overflow-y: auto;
    flex-direction: column;
    z-index: 900;
}

.music-sidebar.open {
    display: flex;
    position: fixed;
    top: 60px;
    left: 0;
    bottom: 0;
    z-index: 1050;
    animation: fadeIn 0.2s ease;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1040;
}

.sidebar-overlay.active {
    display: block;
}

.music-main {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

/* --- Sidebar --- */
.sidebar-header {
    padding: 18px 15px 14px;
    font-family: 'Comic Neue', sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    border-bottom: 3px solid #000;
    background: #f0f0f0;
}

.sidebar-list {
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1;
}

.sidebar-item {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    border-bottom: 1px solid #e0e0e0;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Poppins', sans-serif;
    font-size: 0.85rem;
    gap: 8px;
}

.sidebar-item:hover {
    background: #f0f0f0;
    transform: translate(-2px, -2px);
    box-shadow: 2px 2px 0 #000 !important;
}

.sidebar-item.active {
    background: #000;
    color: #fff;
}

.sidebar-item.active:hover {
    background: #222;
}

.sidebar-item .playlist-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-item .playlist-count {
    font-size: 0.7rem;
    font-weight: 600;
    background: #f0f0f0;
    border: 1px solid #000;
    padding: 1px 7px;
    min-width: 22px;
    text-align: center;
}

.sidebar-item.active .playlist-count {
    background: #fff;
    color: #000;
}

.sidebar-add-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 12px 15px;
    border: none;
    border-top: 3px dashed #000;
    background: transparent;
    font-family: 'Poppins', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-add-btn:hover {
    background: #000;
    color: #fff;
}

/* --- Upload Zone --- */
.music-upload-zone {
    border: 3px dashed #000;
    padding: 35px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 20px;
    background: #fff;
}

.music-upload-zone:hover {
    transform: translate(-2px, -4px);
    box-shadow: 2px 4px 0 #000 !important;
}

.music-upload-zone.drag-over {
    background: #000;
    color: #fff;
    border-color: #fff;
}

.music-upload-zone .upload-icon {
    font-size: 48px;
    line-height: 1;
    margin-bottom: 10px;
    display: block;
}

.music-upload-zone .upload-text {
    font-family: 'Comic Neue', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 4px;
}

.music-upload-zone .upload-hint {
    font-size: 0.75rem;
    color: #5a5a5a;
}

.music-upload-zone.drag-over .upload-hint {
    color: #ccc;
}

/* --- Upload Progress --- */
.upload-progress {
    display: none;
    margin-bottom: 15px;
}

.upload-progress.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

.upload-progress-bar {
    height: 14px;
    border: 2px solid #000;
    background: #f0f0f0;
    overflow: hidden;
}

.upload-fill {
    height: 100%;
    background: #000;
    width: 0%;
    transition: width 0.3s ease;
}

/* --- Storage Usage --- */
.storage-usage {
    font-size: 0.72rem;
    color: #5a5a5a;
    margin-bottom: 18px;
    font-family: 'Poppins', sans-serif;
}

.storage-bar {
    height: 6px;
    border: 1px solid #000;
    background: #f0f0f0;
    margin-top: 5px;
    overflow: hidden;
}

.storage-fill {
    height: 100%;
    background: #000;
    transition: width 0.5s ease;
}

/* --- Toolbar --- */
.music-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    gap: 10px;
    flex-wrap: wrap;
}

.music-search {
    flex: 1;
    min-width: 160px;
    padding: 8px 12px;
    border: 2px solid #000;
    background: #fff;
    font-family: 'Poppins', sans-serif;
    font-size: 0.85rem;
    outline: none;
    transition: all 0.3s ease;
}

.music-search:focus {
    box-shadow: 3px 3px 0 #000 !important;
    transform: translate(-1px, -1px);
}

.toolbar-actions {
    display: flex;
    gap: 6px;
}

.toolbar-actions button {
    padding: 8px 12px;
    border: 2px solid #000;
    background: #fff;
    font-family: 'Poppins', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.toolbar-actions button:hover {
    background: #000;
    color: #fff;
    transform: translate(-2px, -2px);
    box-shadow: 2px 2px 0 #000 !important;
}

/* --- Track List --- */
.track-list {
    background: #fff;
    border: 2px solid #000;
}

.track-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    gap: 10px;
    border-bottom: 1px solid #e0e0e0;
    transition: all 0.3s ease;
    cursor: pointer;
    font-family: 'Poppins', sans-serif;
}

.track-item:last-child {
    border-bottom: none;
}

.track-item:hover {
    background: #f0f0f0;
}

.track-item.playing {
    background: #000;
    color: #fff;
    animation: pulse 2.5s ease-in-out infinite;
}

.track-item .track-number {
    width: 28px;
    min-width: 28px;
    text-align: center;
    font-size: 0.78rem;
    color: #5a5a5a;
    font-weight: 600;
}

.track-item.playing .track-number {
    color: #ccc;
}

.track-item .track-cover {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border: 2px solid #000;
    object-fit: cover;
    background: #000;
}

.track-item.playing .track-cover {
    border-color: #fff;
}

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

.track-item .track-title {
    font-weight: 600;
    font-size: 0.88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track-item .track-artist {
    font-size: 0.75rem;
    color: #5a5a5a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track-item.playing .track-artist {
    color: #aaa;
}

.track-item .track-duration {
    width: 50px;
    min-width: 50px;
    text-align: right;
    font-size: 0.78rem;
    color: #5a5a5a;
    display: none;
}

.track-item.playing .track-duration {
    color: #aaa;
}

.track-item .track-actions {
    display: flex;
    gap: 4px;
}

.track-item:hover .track-actions {
    display: flex;
}

.btn-track-action {
    width: 28px;
    height: 28px;
    min-width: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #000;
    background: #fff;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.3s ease;
    padding: 0;
}

.btn-track-action:hover {
    transform: translate(-2px, -2px);
    box-shadow: 2px 2px 0 #000 !important;
}

.track-item.playing .btn-track-action {
    border-color: #fff;
    background: transparent;
    color: #fff;
}

.track-item.playing .btn-track-action:hover {
    background: #fff;
    color: #000;
    box-shadow: 2px 2px 0 rgba(255,255,255,0.4) !important;
}

/* --- Now Playing Bar --- */
.now-playing {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 3px solid #000;
    z-index: 1000;
    padding: 8px 12px;
    transition: transform 0.4s ease;
}

.now-playing.hidden {
    transform: translateY(100%);
    pointer-events: none;
}

.now-playing-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.np-cover {
    width: 42px;
    height: 42px;
    min-width: 42px;
    border: 2px solid #000;
    object-fit: cover;
    flex-shrink: 0;
    background: #000;
}

.np-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.np-title {
    font-weight: 700;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: 'Poppins', sans-serif;
}

.np-artist {
    font-size: 0.72rem;
    color: #5a5a5a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.np-controls {
    display: flex;
    align-items: center;
    gap: 5px;
}

.btn-player {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #000;
    background: #fff;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.3s ease;
    padding: 0;
    flex-shrink: 0;
}

.btn-player:hover {
    transform: translate(-2px, -2px);
    box-shadow: 2px 2px 0 #000 !important;
}

.btn-player.btn-play {
    width: 42px;
    height: 42px;
    border-width: 3px;
    font-size: 1rem;
}

.btn-player.active {
    background: #000;
    color: #fff;
}

.np-progress-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    width: 100%;
    order: 10;
}

.np-progress-top {
    margin-bottom: 8px;
    order: unset;
}

.np-progress-bar {
    height: 6px;
    background: #f0f0f0;
    border: 1px solid #000;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
}

.np-progress-fill {
    height: 100%;
    background: #000;
    position: absolute;
    top: 0;
    left: 0;
    transition: none;
    pointer-events: none;
}

.np-progress-handle {
    width: 14px;
    height: 14px;
    background: #000;
    position: absolute;
    top: -4px;
    cursor: grab;
    z-index: 3;
    transition: none;
}

.np-progress-handle:active {
    cursor: grabbing;
}

.np-timestamps {
    display: flex;
    justify-content: space-between;
    font-size: 0.68rem;
    color: #5a5a5a;
    font-family: 'Poppins', sans-serif;
    margin-top: 2px;
}

.np-volume {
    display: none;
    align-items: center;
    gap: 5px;
    width: 100px;
}

.np-volume-bar {
    flex: 1;
    height: 4px;
    background: #f0f0f0;
    border: 1px solid #000;
    cursor: pointer;
    position: relative;
}

.np-volume-fill {
    height: 100%;
    background: #000;
    position: absolute;
    top: 0;
    left: 0;
}

.np-extra {
    display: none;
    align-items: center;
    gap: 5px;
}

/* --- A-B Loop --- */
.ab-loop-btn {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #000;
    background: #fff;
    cursor: pointer;
    font-size: 0.65rem;
    font-weight: 700;
    transition: all 0.3s ease;
    padding: 0;
    flex-shrink: 0;
    font-family: 'Poppins', sans-serif;
}

.ab-loop-btn:hover {
    transform: translate(-2px, -2px);
    box-shadow: 2px 2px 0 #000 !important;
}

.ab-loop-btn.active {
    background: #000;
    color: #fff;
}

.ab-loop-btn.set-a {
    background: #e74c3c;
    color: #fff;
    border-color: #c0392b;
}

.ab-marker {
    position: absolute;
    width: 3px;
    height: 14px;
    top: -4px;
    background: #e74c3c;
    z-index: 2;
    pointer-events: none;
}

.ab-region {
    position: absolute;
    background: rgba(231, 76, 60, 0.15);
    height: 100%;
    top: 0;
    z-index: 1;
    pointer-events: none;
}

/* --- Visualizer --- */
.visualizer-container {
    height: 48px;
    background: #000;
    overflow: hidden;
    border-top: 2px solid #000;
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    z-index: 999;
    pointer-events: none;
}

.visualizer-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* --- Toast Notifications --- */
.music-toast {
    position: fixed;
    bottom: 120px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 10px 22px;
    font-family: 'Poppins', sans-serif;
    font-size: 0.82rem;
    font-weight: 600;
    z-index: 1100;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    border: 2px solid #000;
    white-space: nowrap;
    box-shadow: 3px 3px 0 #000 !important;
}

.music-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
    animation: slideUp 0.3s ease;
}

.music-toast.success {
    background: #000;
    color: #fff;
}

.music-toast.error {
    background: #e74c3c;
    color: #fff;
    border-color: #c0392b;
}

/* --- Modal / Confirm Dialog --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.modal-box {
    background: #fff;
    border: 3px solid #000;
    box-shadow: 5px 5px 0 #000 !important;
    padding: 25px;
    max-width: 400px;
    width: 90%;
    animation: slideUp 0.3s ease;
}

.modal-title {
    font-family: 'Comic Neue', sans-serif;
    font-weight: 700;
    font-size: 1.15rem;
    margin-bottom: 12px;
}

.modal-body {
    font-family: 'Poppins', sans-serif;
    font-size: 0.88rem;
    color: #5a5a5a;
    margin-bottom: 20px;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.btn-modal {
    padding: 8px 16px;
    border: 2px solid #000;
    background: #fff;
    font-family: 'Poppins', sans-serif;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-modal:hover {
    background: #000;
    color: #fff;
    transform: translate(-2px, -2px);
    box-shadow: 2px 2px 0 #000 !important;
}

.btn-modal-danger {
    background: #e74c3c;
    color: #fff;
    border-color: #c0392b;
}

.btn-modal-danger:hover {
    background: #c0392b;
    color: #fff;
    box-shadow: 2px 2px 0 #e74c3c !important;
}

/* --- Playlist Detail Header --- */
.playlist-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 3px solid #000;
    padding-bottom: 12px;
    margin-bottom: 15px;
    gap: 10px;
    flex-wrap: wrap;
}

.playlist-title {
    font-family: 'Comic Neue', sans-serif;
    font-weight: 700;
    font-size: 1.5rem;
}

.playlist-meta {
    font-size: 0.78rem;
    color: #5a5a5a;
    font-family: 'Poppins', sans-serif;
}

/* --- Edit Metadata Modal --- */
.edit-form {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.edit-field {
    margin-bottom: 14px;
}

.edit-label {
    display: block;
    font-family: 'Poppins', sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 5px;
    color: #000;
}

.edit-input {
    width: 100%;
    padding: 8px 10px;
    border: 2px solid #000;
    background: #fff;
    font-family: 'Poppins', sans-serif;
    font-size: 0.85rem;
    outline: none;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.edit-input:focus {
    box-shadow: 3px 3px 0 #000 !important;
    transform: translate(-1px, -1px);
}

/* --- Empty States --- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #5a5a5a;
    font-family: 'Poppins', sans-serif;
}

.empty-state-icon {
    font-size: 64px;
    line-height: 1;
    margin-bottom: 12px;
    opacity: 0.4;
    display: block;
}

.empty-state-text {
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 8px;
}

/* --- Sidebar Toggle (Mobile) --- */
.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 2px solid #000;
    background: #fff;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    padding: 0;
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: #000;
    color: #fff;
    transform: translate(-2px, -2px);
    box-shadow: 2px 2px 0 #000 !important;
}

/* --- Utility States --- */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f0f0f0;
    border-top-color: #000;
    animation: spin 0.6s linear infinite;
}

.disabled {
    opacity: 0.4;
    pointer-events: none;
    cursor: not-allowed;
}

/* ============================================
   RESPONSIVE — 768px+ (Tablet / Small Desktop)
   ============================================ */
@media (min-width: 768px) {
    .music-sidebar {
        display: flex;
        flex-direction: column;
        position: static;
    }

    .sidebar-overlay {
        display: none !important;
    }

    .sidebar-toggle {
        display: none;
    }

    .music-main {
        padding: 20px;
    }

    .track-item .track-duration {
        display: block;
    }

    .track-item .track-actions {
        display: none;
    }

    .track-item:hover .track-actions {
        display: flex;
    }

    .now-playing {
        padding: 10px 20px;
    }

    .now-playing-inner {
        flex-wrap: nowrap;
        gap: 15px;
    }

    .np-cover {
        width: 50px;
        height: 50px;
        min-width: 50px;
    }

    .np-progress-wrapper {
        order: unset;
        min-width: 100px;
        width: auto;
    }

    .np-volume {
        display: flex;
    }

    .np-extra {
        display: flex;
    }

    .np-controls {
        gap: 8px;
    }

    .btn-player {
        width: 36px;
        height: 36px;
    }

    .btn-player.btn-play {
        width: 44px;
        height: 44px;
    }

    .music-toast {
        bottom: 140px;
    }
}

/* ============================================
   RESPONSIVE — 1024px+ (Large Desktop)
   ============================================ */
@media (min-width: 1024px) {
    .music-main {
        padding: 25px 30px;
    }

    .music-toolbar {
        margin-bottom: 20px;
    }

    .track-item {
        padding: 12px 16px;
        gap: 12px;
    }

    .playlist-title {
        font-size: 1.75rem;
    }

    .music-upload-zone {
        padding: 45px 30px;
    }

    .now-playing {
        padding: 10px 30px;
    }
}
