/* ==========================================
   🎨 MUSIC GENERATION - COMPLETE STYLES
   ========================================== */

/* Import Base Styles */
@import url('dubbing.css');

/* ==========================================
   1. CONTAINER & LAYOUT
   ========================================== */

.music-container {
    display: grid;
    grid-template-columns: 500px 1fr; 
    gap: 24px;
    min-height: 85vh;
    padding: 24px;
}

.settings-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
    z-index: 2;
}

/* Tối ưu header */
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0;
    margin-bottom: -12px; /* Dính sát header với khung đầu */
    width: 100%;
}

.mode-segmented-control {
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    padding: 3px;
    border-radius: 25px;
    gap: 2px;
    flex: 1;
}

.mode-btn {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    color: #888;
    transition: all 0.2s ease;
    font-weight: 500;
}

.mode-btn.active {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-weight: 700;
}

/* ==========================================
   2. CARDS & INPUTS (SIDEBAR)
   ========================================== */

.simple-card, .advanced-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#advancedModeFields {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.card-label {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 0;
}

.input-frame {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 12px;
    transition: 0.2s;
}

.input-frame:focus-within {
    border-color: rgba(99, 102, 241, 0.3);
    background: rgba(0, 0, 0, 0.3);
}

.simple-textarea, .form-input-clean {
    background: transparent;
    border: none;
    padding: 0;
    font-size: 14px;
    color: #fff;
    width: 100%;
    resize: none;
    outline: none;
    line-height: 1.5;
}

.form-input-clean {
    height: 24px;
}

.simple-textarea::placeholder, .form-input-clean::placeholder {
    color: #555;
}

/* Vocal Selector */
.vocal-segmented-control {
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    padding: 3px;
    border-radius: 10px;
    gap: 2px;
}

.vocal-btn {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    color: #888;
    transition: all 0.2s;
}

.vocal-btn.active {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-weight: 600;
}

/* Horizontal Scroll Chips */
.horizontal-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 2px 0;
    margin-top: 5px; 
    margin-bottom: 0;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; 
}
.horizontal-chips::-webkit-scrollbar { display: none; }

.outlined-chip {
    flex: 0 0 auto;
    display: inline-block;
    border: 1px solid #2a2a2a;
    color: #888;
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 11px;
    cursor: pointer;
    transition: 0.2s;
}
.outlined-chip:hover { border-color: #666; color: #fff; }

/* ==========================================
   3. BOTTOM CONTROL BAR
   ========================================== */

.bottom-control-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 5px; 
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}

.select-trigger {
    padding: 10px 14px;
    height: 42px;
    font-size: 13px;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px; 
    white-space: nowrap;
}

.control-item.credit-info {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.03);
    padding: 0 16px;
    height: 42px;
    border-radius: 8px;
}

.btn-generate {
    height: 42px;
    padding: 0 20px;
    background: #fff;
    color: #000;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

/* ==========================================
   4. HISTORY PANEL (REDESIGNED)
   ========================================== */

.history-panel {
    background: #121212;
    border: 1px solid #27272A;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    height: 85vh;
    max-height: 85vh;
    overflow: hidden;
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: #18181B;
    border-bottom: 1px solid #27272A;
}

.top-actions-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn-bulk {
    background: transparent;
    border: 1px solid #3F3F46;
    color: #F4F4F5;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.music-group {
    border-bottom: 1px solid #27272A;
}

.track-item {
    display: flex;
    padding: 16px 24px;
    transition: background 0.2s;
    gap: 20px;
}
.track-item:hover { background: #1C1C1F; }

.track-left { display: flex; gap: 16px; flex: 1; }
.track-checkbox-wrap { width: 20px; display: flex; align-items: center; }

.custom-checkbox {
    width: 18px; height: 18px;
    border: 2px solid #3F3F46; border-radius: 4px;
    cursor: pointer; position: relative;
}
.custom-checkbox.checked { background: #3B82F6; border-color: #3B82F6; }
.custom-checkbox.checked::after {
    content: '✓'; color: white; font-size: 12px;
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
}

.track-cover { width: 64px; height: 64px; border-radius: 6px; object-fit: cover; background: #27272A; }
.track-content { display: flex; flex-direction: column; justify-content: space-between; flex: 1; min-width: 0; }
.track-title { font-weight: 700; font-size: 15px; color: #FFFFFF; margin: 0; }
.track-prompt { font-size: 12px; color: #A1A1AA; margin: 2px 0 8px 0; }

.track-player { display: flex; align-items: center; gap: 12px; }
.btn-play-mini { width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid #52525B; background: transparent; color: white; display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }
.btn-play-spinner { border-color: rgba(255,255,255,0.2); cursor: default; }
.btn-play-spinner i { font-size: 13px; line-height: 1; display: flex; align-items: center; justify-content: center; }

.track-progress-wrap { flex: 1; display: flex; align-items: center; gap: 10px; }
.progress-bar-bg { flex: 1; height: 4px; background: #27272A; border-radius: 2px; position: relative; }
.progress-bar-fill { height: 100%; background: #3B82F6; border-radius: 2px; width: 0%; }
.progress-thumb { width: 10px; height: 10px; background: white; border-radius: 50%; position: absolute; top: 50%; transform: translateY(-50%); margin-left: -5px; }
.track-time-info { font-size: 11px; color: #A1A1AA; min-width: 60px; }

.track-right { display: flex; align-items: center; gap: 24px; margin-left: auto; }
.track-timestamp { font-size: 12px; color: #FFFFFF; }

.badge-pill { padding: 4px 12px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge-processing { background: #18181B; color: #FFFFFF; border: 1px solid #3F3F46; }
.badge-done { background: #F4F4F5; color: #000000; }

.btn-delete-track { color: #A1A1AA; background: transparent; border: none; cursor: pointer; font-size: 16px; }
.btn-delete-track:hover { color: #EF4444; }

.track-credits { text-align: left; min-width: 100px; }
.credit-value { display: block; font-weight: 700; color: #FFFFFF; font-size: 13px; }
.credit-label { display: block; font-size: 10px; color: #A1A1AA; }

.track-indent { padding-left: 60px; }
.spinner-spin { animation: rotate 1s linear infinite; }
@keyframes rotate { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* Toast & Empty State */
.history-empty { display: flex; justify-content: center; align-items: center; height: 200px; color: #555; font-size: 13px; }

/* ==========================================
   STREAM / LIVE PLAYER
   ========================================== */

/* Live badge — monochrome */
.badge-live {
    background: rgba(255,255,255,0.08);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.25);
    display: flex; align-items: center; gap: 5px;
    padding: 4px 10px; border-radius: 999px;
    font-size: 11px; font-weight: 700;
}
.live-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: #fff;
    animation: livePulse 1.2s ease-in-out infinite;
}
@keyframes livePulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.3; transform: scale(0.7); }
}

/* Play button when live — same as normal */
.btn-play-live {
    border-color: rgba(255,255,255,0.5) !important;
    color: #fff !important;
}
.btn-play-live:hover { background: rgba(255,255,255,0.08) !important; }

/* Cover pulsing border when live — white glow */
.cover-pulse {
    box-shadow: 0 0 0 2px rgba(255,255,255,0.4);
    animation: coverGlow 2s ease-in-out infinite;
}
@keyframes coverGlow {
    0%, 100% { box-shadow: 0 0 0 2px rgba(255,255,255,0.35); }
    50%       { box-shadow: 0 0 0 4px rgba(255,255,255,0.08); }
}

/* Waveform bars */
.waveform-bars {
    display: flex; align-items: center; gap: 3px;
}
.waveform-bars span {
    display: block; width: 3px; border-radius: 2px;
    background: #3F3F46; height: 4px;
}

/* Idle: static */
.waveform-bars.idle span { background: #2a2a2e; }

/* Playing: animated white */
.waveform-bars.playing span { background: #fff; }
.waveform-bars.playing span:nth-child(1) { animation: bar 0.9s ease-in-out infinite 0.0s; }
.waveform-bars.playing span:nth-child(2) { animation: bar 0.9s ease-in-out infinite 0.15s; }
.waveform-bars.playing span:nth-child(3) { animation: bar 0.9s ease-in-out infinite 0.05s; }
.waveform-bars.playing span:nth-child(4) { animation: bar 0.9s ease-in-out infinite 0.2s; }
.waveform-bars.playing span:nth-child(5) { animation: bar 0.9s ease-in-out infinite 0.1s; }
@keyframes bar {
    0%, 100% { height: 3px; }
    50%       { height: 16px; }
}

/* Stream live bar layout */
.stream-live-bar {
    display: flex; align-items: center; gap: 10px; flex: 1;
}
.stream-time { font-size: 11px; color: #999; min-width: 32px; }

/* Pending placeholder */
.stream-placeholder {
    display: flex; align-items: center; gap: 8px; flex: 1;
}
.loading-text { font-size: 11px; color: #52525B; }

/* Download mini button */
.btn-dl-mini {
    color: #52525B; background: transparent; border: none;
    cursor: pointer; font-size: 13px; padding: 0;
}
.btn-dl-mini:hover { color: #A1A1AA; }

/* ==========================================
   TRACK PLAYING HIGHLIGHT
   ========================================== */
.track-item.track-playing {
    background: rgba(255,255,255,0.04);
    border-left: 2px solid #fff;
}
.track-item.track-playing .track-title { color: #fff; }

/* ==========================================
   PROGRESS BAR — WHITE/BLACK
   ========================================== */
.progress-bar-bg {
    cursor: pointer;
    background: rgba(255,255,255,0.1);
}
.progress-bar-fill { background: #fff; }
.progress-thumb    { background: #fff; box-shadow: 0 0 4px rgba(0,0,0,0.6); }
.track-time-info   { color: #999; }

/* ==========================================
   CHECKBOX — WHITE/BLACK
   ========================================== */
.custom-checkbox {
    border-color: rgba(255,255,255,0.25);
    background: transparent;
}
.custom-checkbox:hover  { border-color: rgba(255,255,255,0.6); }
.custom-checkbox.checked {
    background: #fff;
    border-color: #fff;
}
.custom-checkbox.checked::after { color: #000; }

/* ==========================================
   DOWNLOAD BUTTON — BIG ICON
   ========================================== */
.btn-dl-mini {
    color: #666;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 18px;
    padding: 2px 4px;
    line-height: 1;
    transition: color 0.15s;
}
.btn-dl-mini:hover { color: #fff; }

/* ==========================================
   DETAIL SIDEBAR
   ========================================== */
.track-sidebar {
    position: fixed;
    inset: 0;
    z-index: 1000;
    pointer-events: none;
}
.track-sidebar.open { pointer-events: auto; }

.sidebar-overlay { display: none; }

.track-sidebar::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}
.track-sidebar.open::before { opacity: 1; }

.sidebar-panel {
    position: absolute;
    right: 0; top: 0; bottom: 0;
    width: 340px;
    background: #111;
    border-left: 1px solid #222;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
    padding-bottom: 24px;
    z-index: 2;
}
.track-sidebar.open .sidebar-panel { transform: translateX(0); }

.sidebar-close {
    position: absolute;
    top: 14px; right: 14px;
    background: rgba(255,255,255,0.08);
    border: none;
    color: #fff;
    width: 32px; height: 32px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    z-index: 2;
    font-size: 14px;
    transition: background 0.2s;
}
.sidebar-close:hover { background: rgba(255,255,255,0.15); }

.sidebar-cover-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    flex-shrink: 0;
}
.sidebar-cover {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
}
.sidebar-play-btn {
    position: absolute;
    bottom: 16px; right: 16px;
    width: 52px; height: 52px;
    border-radius: 50%;
    background: #fff;
    border: none;
    color: #000;
    font-size: 22px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    transition: transform 0.15s, background 0.15s;
}
.sidebar-play-btn:hover { transform: scale(1.08); }
.sidebar-play-btn.disabled { background: #333; color: #666; pointer-events: none; }

.sidebar-meta {
    padding: 16px 20px 8px;
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.sidebar-title {
    font-size: 16px; font-weight: 700; color: #fff;
    flex: 1; min-width: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.sidebar-section {
    padding: 10px 20px;
    border-top: 1px solid rgba(255,255,255,0.06);
}
.sidebar-label {
    font-size: 10px; font-weight: 700;
    color: #555; text-transform: uppercase; letter-spacing: 0.08em;
    margin-bottom: 6px;
}
.sidebar-value {
    font-size: 13px; color: #ccc; line-height: 1.5;
}
.sidebar-lyrics {
    font-size: 12px; color: #888; line-height: 1.7;
    white-space: pre-wrap; margin: 0;
    max-height: 220px; overflow-y: auto;
    font-family: inherit;
}
.sidebar-lyrics::-webkit-scrollbar { width: 3px; }
.sidebar-lyrics::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }

.sidebar-info-row {
    display: flex; justify-content: space-between;
    font-size: 12px; color: #888;
    padding: 3px 0;
}
.sidebar-info-row span:last-child { color: #ccc; }

.sidebar-dl-btn {
    margin: 16px 20px 0;
    width: calc(100% - 40px);
    padding: 12px;
    background: #fff;
    color: #000;
    border: none;
    border-radius: 10px;
    font-size: 14px; font-weight: 700;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    transition: background 0.2s;
}
.sidebar-dl-btn:hover   { background: #e5e5e5; }
.sidebar-dl-btn.disabled { background: #222; color: #444; pointer-events: none; }

@media (max-width: 600px) {
    .sidebar-panel { width: 100%; }
}
