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

:root {
    --bg: #0a0a0a;
    --bg-secondary: #141414;
    --bg-card: #1a1a1a;
    --border: #2a2a2a;
    --text: #ffffff;
    --text-muted: #888888;
    --accent: #ffffff;
    --accent-hover: #e0e0e0;
    --progress-bg: #333333;
    --progress-fill: #ffffff;
}

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

a {
    color: var(--text);
    text-decoration: underline;
}

a:hover {
    color: var(--text-muted);
}

/* ===== Layout ===== */
.app {
    display: flex;
    min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
    width: 360px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 24px 20px 16px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h1 {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-header h1 i {
    font-size: 1.2rem;
}

.search-box {
    position: relative;
}

.search-box i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
}

.search-box input {
    width: 100%;
    padding: 12px 14px 12px 40px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

.search-box input:focus {
    border-color: #555;
}

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

/* ===== Playlist ===== */
.playlist {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

.playlist::-webkit-scrollbar {
    width: 6px;
}

.playlist::-webkit-scrollbar-track {
    background: transparent;
}

.playlist::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 3px;
}

.song-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    cursor: pointer;
    transition: background 0.15s;
    border-left: 3px solid transparent;
}

.song-item:hover {
    background: var(--bg-card);
}

.song-item.active {
    background: var(--bg-card);
    border-left-color: var(--accent);
}

.song-item.active .song-title {
    color: var(--accent);
}

.song-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    overflow: hidden;
    flex: 1;
}

.song-title {
    font-size: 0.95rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.song-artist {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.play-icon {
    color: var(--text-muted);
    font-size: 0.85rem;
    opacity: 0;
    transition: opacity 0.15s;
}

.song-item:hover .play-icon,
.song-item.active .play-icon {
    opacity: 1;
}

.song-item.active .play-icon {
    color: var(--accent);
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state p {
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.empty-state small {
    font-size: 0.85rem;
}

/* ===== Player Area ===== */
.player-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 30px;
    background: var(--bg);
    gap: 30px;
}

.now-playing {
    text-align: center;
    max-width: 400px;
}

.album-art {
    width: 220px;
    height: 220px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    transition: transform 0.3s;
}

.album-art.playing {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

.album-art i {
    font-size: 4rem;
    color: var(--text-muted);
    opacity: 0.5;
}

.track-info h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track-info p {
    font-size: 1rem;
    color: var(--text-muted);
}

/* ===== Progress ===== */
.progress-container {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: 480px;
}

.progress-container span {
    font-size: 0.8rem;
    color: var(--text-muted);
    min-width: 40px;
    font-variant-numeric: tabular-nums;
}

#currentTime {
    text-align: right;
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: var(--progress-bg);
    border-radius: 3px;
    cursor: pointer;
    position: relative;
}

.progress {
    height: 100%;
    background: var(--progress-fill);
    border-radius: 3px;
    width: 0%;
    transition: width 0.1s linear;
}

.progress-handle {
    position: absolute;
    top: 50%;
    left: 0%;
    width: 14px;
    height: 14px;
    background: var(--accent);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.15s;
    pointer-events: none;
}

.progress-bar:hover .progress-handle {
    opacity: 1;
}

/* ===== Controls ===== */
.controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

.ctrl-btn {
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 10px;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
}

.ctrl-btn:hover {
    background: var(--bg-card);
    color: var(--accent);
}

.ctrl-btn.play-btn {
    width: 64px;
    height: 64px;
    font-size: 1.6rem;
    background: var(--accent);
    color: var(--bg);
}

.ctrl-btn.play-btn:hover {
    background: var(--accent-hover);
    color: var(--bg);
}

.ctrl-btn.active {
    color: var(--accent);
    background: var(--bg-card);
}

/* ===== Volume ===== */
.volume-container {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 200px;
}

.volume-container i {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.volume-container input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: var(--progress-bg);
    border-radius: 2px;
    outline: none;
}

.volume-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
}

.volume-container input[type="range"]::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .app {
        flex-direction: column;
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
    }

    .sidebar {
        width: 100%;
        flex: 0 0 auto;
        max-height: 42vh;
        border-right: none;
        border-bottom: 1px solid var(--border);
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    .sidebar-header {
        flex-shrink: 0;
    }

    .playlist {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    .player-area {
        flex: 1;
        min-height: 0;
        padding: 20px 16px;
        gap: 16px;
        overflow-y: auto;
        justify-content: flex-start;
        padding-top: 24px;
    }

    .album-art {
        width: 140px;
        height: 140px;
    }

    .album-art i {
        font-size: 2.8rem;
    }

    .track-info h2 {
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    .sidebar {
        max-height: 38vh;
    }

    .sidebar-header {
        padding: 12px 14px 10px;
    }

    .sidebar-header h1 {
        font-size: 1.1rem;
        margin-bottom: 10px;
    }

    .search-box input {
        padding: 10px 12px 10px 36px;
        font-size: 0.9rem;
    }

    .song-item {
        padding: 10px 14px;
    }

    .song-title {
        font-size: 0.9rem;
    }

    .song-artist {
        font-size: 0.75rem;
    }

    .controls {
        gap: 10px;
    }

    .ctrl-btn {
        width: 40px;
        height: 40px;
        font-size: 1.05rem;
    }

    .ctrl-btn.play-btn {
        width: 52px;
        height: 52px;
        font-size: 1.3rem;
    }

    .album-art {
        width: 120px;
        height: 120px;
        margin-bottom: 16px;
    }

    .progress-container {
        max-width: 100%;
    }

    .volume-container {
        max-width: 160px;
    }
}

/* ===== Admin Styles ===== */
.admin-body {
    background: var(--bg);
    min-height: 100vh;
    padding: 40px 20px;
}

.admin-container {
    max-width: 800px;
    margin: 0 auto;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    flex-wrap: wrap;
    gap: 16px;
}

.admin-header h1 {
    font-size: 1.6rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-nav a {
    color: var(--text-muted);
    text-decoration: none;
    margin-left: 20px;
    font-size: 0.95rem;
    transition: color 0.2s;
}

.admin-nav a:hover {
    color: var(--text);
}

.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 28px;
    margin-bottom: 24px;
}

.card h2 {
    font-size: 1.2rem;
    margin-bottom: 20px;
    font-weight: 600;
}

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

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="file"] {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.95rem;
    outline: none;
}

.form-group input[type="file"] {
    padding: 10px;
}

.form-group input:focus {
    border-color: #555;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--accent);
    color: var(--bg);
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

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

.btn-danger {
    background: transparent;
    color: #ff6b6b;
    border: 1px solid #ff6b6b;
    padding: 8px 14px;
    font-size: 0.85rem;
}

.btn-danger:hover {
    background: #ff6b6b;
    color: #fff;
}

.btn-secondary {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-card);
}

.alert {
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.95rem;
}

.alert-success {
    background: #1a2e1a;
    border: 1px solid #2d5a2d;
    color: #8fdf8f;
}

.alert-error {
    background: #2e1a1a;
    border: 1px solid #5a2d2d;
    color: #df8f8f;
}

.songs-table {
    width: 100%;
    border-collapse: collapse;
}

.songs-table th,
.songs-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.songs-table th {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.songs-table td {
    font-size: 0.95rem;
}

.songs-table tr:last-child td {
    border-bottom: none;
}

.login-box {
    max-width: 400px;
    margin: 80px auto;
}

.login-box h1 {
    text-align: center;
    margin-bottom: 28px;
}

/* ===== Upload extras ===== */
.upload-hint {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 20px;
    line-height: 1.5;
}

.optional {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.file-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}

.file-btn {
    cursor: pointer;
    margin: 0;
}

.file-btn input {
    display: none;
}

.file-list {
    max-height: 200px;
    overflow-y: auto;
    margin-top: 8px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg-card);
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.file-item i {
    color: var(--text-muted);
    flex-shrink: 0;
}

.file-item .fname {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-item .fsize {
    color: var(--text-muted);
    font-size: 0.8rem;
    flex-shrink: 0;
}

.file-item .remove-file {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.file-item .remove-file:hover {
    color: #ff6b6b;
}

.progress-wrap {
    margin: 18px 0;
}

.upload-progress-bar {
    height: 8px;
    background: var(--progress-bg);
    border-radius: 4px;
    overflow: hidden;
}

.upload-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.15s ease;
}

.progress-text {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.upload-result {
    margin: 16px 0;
}

.result-list {
    list-style: none;
    margin-top: 10px;
    max-height: 180px;
    overflow-y: auto;
    font-size: 0.9rem;
}

.result-list li {
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}

.result-list li.ok {
    color: #8fdf8f;
}

.result-list li.fail {
    color: #df8f8f;
}

.result-list i {
    margin-right: 6px;
}

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

/* Admin table scroll on small screens */
@media (max-width: 600px) {
    .songs-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .admin-body {
        padding: 20px 12px;
    }

    .card {
        padding: 18px;
    }
}
