:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-card: #0f3460;
    --bg-input: #1a1a2e;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --accent: #e94560;
    --accent-hover: #ff6b81;
    --success: #4caf50;
    --border: #2a2a4a;
    --scrollbar: #2a2a4a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100%;
    overflow: hidden;
}

#app { display: flex; height: 100vh; }

/* Sidebar */
.sidebar {
    width: 220px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 16px 0;
    flex-shrink: 0;
}

.sidebar-logo {
    text-align: center;
    padding: 0 16px 20px;
    font-size: 1.4em;
    font-weight: 700;
    color: var(--accent);
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}

.sidebar-user {
    padding: 12px 16px;
    font-size: 0.85em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}

.sidebar-user strong { color: var(--text-primary); display: block; }

.nav-link {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.95em;
    transition: all 0.15s;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.nav-link:hover { background: rgba(233,69,96,0.1); color: var(--text-primary); }
.nav-link.active { background: rgba(233,69,96,0.2); color: var(--accent); border-right: 3px solid var(--accent); }

.nav-spacer { flex: 1; }

/* Main content */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* Cards */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 16px;
}

.card-title {
    font-size: 0.8em;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 1px;
    margin-bottom: 12px;
}

/* Inputs */
input[type="text"], input[type="password"], input[type="email"], input[type="number"],
textarea, select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    padding: 10px 14px;
    width: 100%;
    font-size: 0.95em;
    outline: none;
    transition: border-color 0.2s;
}

input:focus, textarea:focus, select:focus { border-color: var(--accent); }

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { background: #555; cursor: not-allowed; }
.btn-secondary { background: var(--border); color: var(--text-primary); }
.btn-secondary:hover { background: #3a3a5a; }
.btn-danger { background: #c0392b; color: white; }
.btn-danger:hover { background: #e74c3c; }
.btn-sm { padding: 6px 12px; font-size: 0.8em; }

/* URL input bar */
.url-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.url-bar input { flex: 1; }

/* Progress bar */
.progress-bar-container {
    background: var(--bg-input);
    border-radius: 4px;
    height: 24px;
    overflow: hidden;
    margin: 12px 0;
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    transition: width 0.3s ease;
    border-radius: 4px;
}

.progress-bar-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.75em;
    font-weight: 600;
}

/* Log output */
.log-output {
    background: #0d0d1a;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
    font-family: 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.82em;
    max-height: 300px;
    overflow-y: auto;
    white-space: pre-wrap;
    line-height: 1.5;
}

/* Album info */
.album-info {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.album-info img {
    width: 120px;
    height: 120px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
}

.album-details h3 { margin-bottom: 4px; }
.album-details p { color: var(--text-secondary); font-size: 0.9em; margin: 2px 0; }

/* Settings grid */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.setting-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
}

.setting-item label { font-size: 0.9em; cursor: pointer; }
.setting-item input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }

.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 0.85em; color: var(--text-secondary); margin-bottom: 4px; }

/* Search results */
.search-results { margin-top: 16px; }

.search-result-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}

.search-result-row:hover { background: rgba(233,69,96,0.05); }

.search-result-row img {
    width: 50px;
    height: 50px;
    border-radius: 4px;
    object-fit: cover;
}

.search-result-info { flex: 1; }
.search-result-info .title { font-weight: 600; }
.search-result-info .artist { color: var(--text-secondary); font-size: 0.85em; }

.artist-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
}

.artist-avatar-placeholder {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2em;
    flex-shrink: 0;
}

.artist-block { border-bottom: 1px solid var(--border); }
.artist-block:last-child { border-bottom: none; }

.artist-row { cursor: pointer; border-bottom: none; }
.artist-row.expanded { background: rgba(233,69,96,0.08); }

.expand-icon {
    color: var(--text-secondary);
    font-size: 1.1em;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

.artist-albums {
    padding: 0 10px 10px 72px;
    animation: slideDown 0.2s ease-out;
}

.artist-album-row {
    border-bottom: 1px solid rgba(255,255,255,0.05) !important;
    padding: 8px 10px !important;
}

.artist-album-row:last-child { border-bottom: none !important; }

.artist-album-row img {
    width: 42px !important;
    height: 42px !important;
    border-radius: 4px;
}

.artist-albums-loading {
    padding: 12px 0;
    color: var(--text-secondary);
    font-size: 0.85em;
}

/* Selection */
.select-checkbox {
    accent-color: var(--accent);
    width: 18px;
    height: 18px;
    cursor: pointer;
    flex-shrink: 0;
}

.search-result-row.selected { background: rgba(233,69,96,0.1); }

.select-all-btn {
    float: right;
    color: var(--accent) !important;
    font-size: 0.85em !important;
    padding: 0 !important;
    background: none !important;
    border: none !important;
    cursor: pointer;
    text-decoration: none;
}

.select-all-btn:hover { text-decoration: underline; }

.selection-bar {
    position: fixed;
    bottom: 0;
    left: var(--sidebar-width, 220px);
    right: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 100;
    animation: slideUp 0.2s ease-out;
}

.selection-bar span {
    flex: 1;
    font-weight: 600;
    font-size: 0.95em;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Quality selector */
.quality-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.quality-btn {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-input);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85em;
    transition: all 0.15s;
}

.quality-btn.active {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(233,69,96,0.1);
}

/* Template Help */
.template-help {
    background: rgba(15, 52, 96, 0.3);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.template-help-toggle {
    padding: 10px 14px;
    cursor: pointer;
    color: var(--accent);
    font-size: 0.9em;
    font-weight: 600;
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

.template-help-toggle::before {
    content: "\25B6";
    font-size: 0.65em;
    transition: transform 0.2s;
}

.template-help[open] > .template-help-toggle::before {
    transform: rotate(90deg);
}

.template-help-toggle:hover { color: var(--accent-hover); }

.template-help-content {
    padding: 4px 14px 14px;
}

.template-section {
    margin-bottom: 12px;
}

.template-section-title {
    font-size: 0.75em;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent);
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(233,69,96,0.2);
}

.template-subsection {
    margin-bottom: 12px;
}

.template-subsection > summary {
    font-size: 0.75em;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    cursor: pointer;
    user-select: none;
    list-style: none;
}

.template-subsection > summary::before {
    content: "+ ";
    color: var(--accent);
}

.template-subsection[open] > summary::before {
    content: "- ";
}

.template-tokens {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 4px 0;
}

.token {
    display: inline-block;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 3px 8px;
    font-family: 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.78em;
    color: #7ec8e3;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}

.token:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(233,69,96,0.08);
    transform: translateY(-1px);
}

.token:active {
    transform: translateY(0);
    background: rgba(233,69,96,0.15);
}

.template-hint {
    font-size: 0.75em;
    color: var(--text-secondary);
    margin-top: 10px;
    font-style: italic;
}

/* Toast notification */
.toast-notification {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--success);
    color: white;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 0.85em;
    font-weight: 600;
    z-index: 9999;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 1.2s forwards;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

@keyframes toastIn {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes toastOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #3a3a5a; }

/* Responsive */
@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar-logo { font-size: 0.9em; padding: 0 4px 12px; }
    .sidebar-user { display: none; }
    .nav-link { padding: 10px; justify-content: center; font-size: 0.8em; }
    .selection-bar { left: 60px; }
}
