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

:root {
    --bg: #0d0d1a;
    --bg-card: #1a1a2e;
    --bg-input: #16213e;
    --primary: #e94560;
    --accent: #0f3460;
    --text: #eee;
    --text-muted: #888;
    --success: #00c853;
    --error: #ff1744;
    --radius: 12px;
}

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

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

/* === Navbar === */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    background: var(--bg-card);
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.logo {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.credits-badge {
    background: var(--accent);
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
}

/* === Buttons === */
.btn {
    display: inline-block;
    padding: 0.6rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.2s;
    text-align: center;
    color: var(--text);
    background: var(--bg-input);
}

.btn:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

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

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

.btn-accent {
    background: var(--success);
    color: #000;
}

.btn-sm {
    padding: 0.3rem 0.8rem;
    font-size: 0.85rem;
}

.btn-lg {
    padding: 1rem 3rem;
    font-size: 1.1rem;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* === Container === */
.container {
    max-width: 900px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

/* === Auth Pages === */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.auth-container {
    background: var(--bg-card);
    padding: 2.5rem;
    border-radius: var(--radius);
    width: 100%;
    max-width: 420px;
    text-align: center;
}

.auth-container h1 {
    margin-bottom: 0.5rem;
    font-size: 1.8rem;
}

.auth-container h2 {
    margin-bottom: 1.5rem;
    font-weight: 400;
    color: var(--text-muted);
    font-size: 1.1rem;
}

.form-group {
    margin-bottom: 1rem;
    text-align: left;
}

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

.form-group input {
    width: 100%;
    padding: 0.7rem 1rem;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text);
    font-size: 1rem;
}

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

.auth-container .btn {
    width: 100%;
    margin-top: 0.5rem;
}

.auth-link {
    margin-top: 1.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* === Alerts === */
.alert {
    padding: 0.8rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert.error {
    background: rgba(255,23,68,0.15);
    border: 1px solid var(--error);
    color: var(--error);
}

/* === Upload Zone === */
.upload-zone {
    margin: 2rem 0;
}

.upload-tracks {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.track-slot {
    background: var(--bg-card);
    border: 2px dashed rgba(255,255,255,0.15);
    border-radius: var(--radius);
    padding: 2rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.track-slot:hover {
    border-color: var(--primary);
    background: rgba(233,69,96,0.05);
}

.track-slot.has-file {
    border-color: var(--success);
    border-style: solid;
}

.track-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.track-label {
    font-weight: 600;
    margin-bottom: 0.3rem;
}

.track-name {
    font-size: 0.8rem;
    color: var(--text-muted);
    word-break: break-all;
}

.file-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.upload-hint {
    text-align: center;
    margin-top: 1rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

#btnGenerate {
    display: block;
    margin: 1.5rem auto 0;
}

/* === Progress === */
.progress-bar {
    width: 100%;
    height: 12px;
    background: var(--bg-input);
    border-radius: 6px;
    overflow: hidden;
    margin: 1.5rem 0 1rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--success));
    border-radius: 6px;
    width: 0%;
    transition: width 0.5s ease;
}

.progress-step {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.progress-steps {
    display: flex;
    justify-content: space-around;
    gap: 0.5rem;
}

.step {
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border-radius: 8px;
    font-size: 0.85rem;
    opacity: 0.4;
    transition: opacity 0.3s;
}

.step.active {
    opacity: 1;
    background: var(--accent);
}

.step.done {
    opacity: 1;
    background: rgba(0,200,83,0.2);
}

/* === Player === */
.player-container {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: var(--radius);
    margin: 1.5rem 0;
    text-align: center;
}

.player-container audio {
    width: 100%;
    max-width: 600px;
}

.result-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1rem;
}

/* === Credits Page === */
.packs-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin: 2rem 0;
}

.pack-card {
    background: var(--bg-card);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    transition: all 0.2s;
}

.pack-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.pack-card h3 {
    margin-bottom: 0.5rem;
}

.pack-price {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary);
    margin: 1rem 0;
}

.pack-card .btn {
    width: 100%;
}

/* === Success === */
.success-box {
    background: var(--bg-card);
    padding: 3rem;
    border-radius: var(--radius);
    text-align: center;
    margin-top: 2rem;
}

.success-box h2 {
    color: var(--success);
    margin-bottom: 1rem;
}

/* === Error === */
.error-message {
    background: rgba(255,23,68,0.1);
    padding: 1rem;
    border-radius: 8px;
    margin: 1rem 0;
    color: var(--error);
}

/* === History === */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    border-left: 4px solid var(--text-muted);
}

.history-item.done {
    border-left-color: var(--success);
}

.history-item.error {
    border-left-color: var(--error);
}

.history-item.queued,
.history-item.bpm,
.history-item.vocals,
.history-item.lyrics,
.history-item.beat,
.history-item.mixing {
    border-left-color: #ff9800;
}

.history-info {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.history-status {
    font-weight: 600;
    min-width: 160px;
}

.history-date {
    color: var(--text-muted);
    font-size: 0.85rem;
}

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

.history-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.error-badge {
    color: var(--error);
    font-size: 0.85rem;
    font-weight: 600;
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

.loading {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

/* === Queue Banner === */
.queue-banner {
    background: rgba(255,152,0,0.15);
    border: 1px solid #ff9800;
    border-radius: var(--radius);
    padding: 1rem 1.5rem;
    margin-bottom: 1rem;
    text-align: center;
}

/* === Auth enhancements === */
.auth-logo {
    display: block;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    margin-bottom: 1.5rem;
}

.auth-info {
    background: rgba(233,69,96,0.1);
    border: 1px solid rgba(233,69,96,0.3);
    border-radius: 8px;
    padding: 0.8rem 1rem;
    margin-bottom: 1.5rem;
    font-size: 0.85rem;
    color: #ccc;
    line-height: 1.5;
}

.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-wrapper input {
    width: 100%;
    padding-right: 5rem;
}

.password-toggle {
    position: absolute;
    right: 0.5rem;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.15);
    color: var(--text-muted);
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.75rem;
}

.password-toggle:hover {
    color: var(--text);
    border-color: rgba(255,255,255,0.3);
}

.form-hint {
    display: block;
    margin-top: 0.3rem;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.btn-block {
    width: 100%;
    display: block;
}

.auth-footer {
    margin-top: 2rem;
    color: #444;
    font-size: 0.75rem;
    line-height: 1.6;
}

.auth-footer a {
    color: #555;
}

.alert.success {
    background: rgba(0,200,83,0.15);
    border: 1px solid var(--success);
    color: var(--success);
}

/* === Utils === */
.hidden {
    display: none !important;
}

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

/* ==============================
   RESPONSIVE
   ============================== */

@media (max-width: 768px) {
    .upload-tracks {
        grid-template-columns: 1fr;
    }

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

    .progress-steps {
        flex-wrap: wrap;
        gap: 0.3rem;
    }

    .step {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
    }

    .navbar {
        flex-direction: column;
        gap: 0.8rem;
        padding: 1rem;
    }

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

    .auth-container {
        margin: 1rem;
        padding: 1.5rem;
    }

    .container {
        padding: 0 1rem;
    }

    .history-item {
        flex-direction: column;
        gap: 0.8rem;
        align-items: flex-start;
    }

    .history-info {
        flex-direction: column;
        gap: 0.5rem;
    }

    .player-container {
        padding: 1rem;
    }

    .player-container audio {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .navbar .logo {
        font-size: 1.1rem;
    }

    .credits-badge {
        font-size: 0.8rem;
        padding: 0.3rem 0.7rem;
    }

    .track-slot {
        padding: 1.5rem 0.8rem;
    }

    .btn-lg {
        padding: 0.8rem 1.5rem;
        font-size: 1rem;
    }
}
