/**
 * Tracklist Builder Styles
 * Matches the YOYAKU Media Platform design system
 *
 * @version 1.0.0
 */

/* ==========================================
   Mode Toggle (Text vs Builder)
   ========================================== */

.tracklist-mode-toggle {
    display: flex;
    gap: 0;
    background: var(--bg-card, #161616);
    border-radius: 8px;
    padding: 4px;
    border: 1px solid var(--border, #2a2a2a);
}

.tracklist-mode-toggle .toggle-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-secondary, #a0a0a0);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Familjen Grotesk', sans-serif;
}

.tracklist-mode-toggle .toggle-btn:hover {
    color: var(--text-primary, #f0f0f0);
}

.tracklist-mode-toggle .toggle-btn.active {
    background: linear-gradient(135deg, var(--accent-light), #a67c52);
    color: var(--text-primary, #f0f0f0);
    box-shadow: 0 2px 8px rgba(196, 149, 106, 0.3);
}

.tracklist-mode-toggle .toggle-btn.active svg {
    stroke: #fff;
}

/* ==========================================
   Container & Layout
   ========================================== */

.tracklist-builder {
    background: var(--bg-dark, #0c0c0c);
    border: 1px solid var(--border, #2a2a2a);
    border-radius: 8px;
    overflow: hidden;
}

.tracklist-builder-wrapper {
    margin-top: 0.5rem;
}

/* ==========================================
   Header Row
   ========================================== */

.tracklist-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-input, #111111);
    border-bottom: 1px solid var(--border, #2a2a2a);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted, #8a8a8a);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.tracklist-header > div {
    padding: 0 4px;
}

.tracklist-col-position {
    width: 60px;
    margin-left: 28px; /* Account for drag handle */
}

.tracklist-col-artist {
    width: 140px;
}

.tracklist-col-title {
    flex: 1;
}

.tracklist-col-duration {
    width: 70px;
}

.tracklist-col-actions {
    width: 32px;
}

/* ==========================================
   Track Rows
   ========================================== */

.tracklist-rows {
    max-height: 400px;
    overflow-y: auto;
}

.tracklist-builder .track-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--bg-card, #161616);
    transition: background 0.15s ease;
}

.tracklist-builder .track-row:last-child {
    border-bottom: none;
}

.tracklist-builder .track-row:hover {
    background: var(--bg-tint-soft);
}

/* Drag Handle */
.track-drag-handle {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--border-hover, #3a3a3a);
    cursor: grab;
    opacity: 0.5;
    transition: opacity 0.2s ease, color 0.2s ease;
    flex-shrink: 0;
}

.tracklist-builder .track-row:hover .track-drag-handle {
    opacity: 1;
    color: var(--text-muted, #8a8a8a);
}

.track-drag-handle:active {
    cursor: grabbing;
}

/* ==========================================
   Input Fields
   ========================================== */

.track-input {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg-input, #111111);
    border: 1px solid var(--border, #2a2a2a);
    border-radius: 4px;
    color: var(--text-primary, #f0f0f0);
    font-family: 'Familjen Grotesk', sans-serif;
    font-size: 0.9rem;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.track-input:focus {
    outline: none;
    border-color: var(--accent-light);
    background: var(--bg-input, #111111);
}

.track-input::placeholder {
    color: var(--text-muted, #8a8a8a);
}

/* Position/Side Input */
.track-position-wrap {
    width: 60px;
    flex-shrink: 0;
}

.track-side-input {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 600;
    text-align: center;
    text-transform: uppercase;
    color: var(--accent-light);
}

.track-side-input:focus {
    color: var(--text-primary, #f0f0f0);
}

/* Artist Input */
.track-artist-wrap {
    width: 140px;
    flex-shrink: 0;
}

.track-artist-input {
    color: var(--text-secondary, #a0a0a0);
    font-style: italic;
}

.track-artist-input:focus {
    color: var(--text-primary, #f0f0f0);
    font-style: normal;
}

/* Title Input */
.track-title-wrap {
    flex: 1;
    min-width: 0;
}

.track-title-input {
    font-weight: 500;
}

/* Duration Input */
.track-duration-wrap {
    width: 70px;
    flex-shrink: 0;
}

.track-duration-input {
    font-family: 'IBM Plex Mono', monospace;
    text-align: center;
    color: var(--text-secondary, #a0a0a0);
}

.track-duration-input:focus {
    color: var(--text-primary, #f0f0f0);
}

/* Remove Button */
.track-remove-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border, #2a2a2a);
    border-radius: 4px;
    color: var(--text-muted, #8a8a8a);
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.tracklist-builder .track-row:hover .track-remove-btn {
    opacity: 1;
}

.track-remove-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

/* ==========================================
   Drag & Drop States
   ========================================== */

.tracklist-builder .track-row.dragging {
    opacity: 0.5;
    background: rgba(196, 149, 106, 0.1);
    border: 1px dashed var(--accent-light);
}

.tracklist-builder .track-row.drag-over {
    background: rgba(196, 149, 106, 0.15);
    border-top: 2px solid var(--accent-light);
}

.tracklist-builder .track-row.drag-over::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: -2px;
    height: 2px;
    background: var(--accent-light);
}

/* ==========================================
   Footer
   ========================================== */

.tracklist-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 16px;
    background: var(--bg-input, #111111);
    border-top: 1px solid var(--border, #2a2a2a);
}

/* Add Track Button */
.tracklist-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: transparent;
    border: 1px solid var(--border, #2a2a2a);
    border-radius: 6px;
    color: var(--text-secondary, #a0a0a0);
    font-family: 'Familjen Grotesk', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tracklist-add-btn:hover {
    background: rgba(196, 149, 106, 0.1);
    border-color: rgba(196, 149, 106, 0.3);
    color: var(--accent-light);
}

.tracklist-add-btn svg {
    stroke: currentColor;
}

/* Info Section */
.tracklist-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.85rem;
}

.tracklist-builder .track-count {
    color: var(--text-muted, #8a8a8a);
    font-family: 'IBM Plex Mono', monospace;
}

.tracklist-builder .total-duration {
    color: var(--text-secondary, #a0a0a0);
    font-family: 'IBM Plex Mono', monospace;
}

/* ==========================================
   Format Badge
   ========================================== */

.tracklist-builder .format-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 4px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.tracklist-builder .format-badge:empty {
    display: none;
}

.format-7 {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.format-12 {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.format-2lp {
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.format-3lp {
    background: rgba(236, 72, 153, 0.15);
    color: #f472b6;
    border: 1px solid rgba(236, 72, 153, 0.3);
}

/* ==========================================
   Validation States
   ========================================== */

.track-input.error {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.05);
}

.track-input.error:focus {
    border-color: #f87171;
}

.tracklist-error-message {
    padding: 10px 16px;
    background: rgba(239, 68, 68, 0.1);
    border-top: 1px solid rgba(239, 68, 68, 0.2);
    color: #f87171;
    font-size: 0.85rem;
}

/* ==========================================
   Empty State
   ========================================== */

.tracklist-rows:empty::after {
    content: 'No tracks added yet';
    display: block;
    padding: 32px;
    text-align: center;
    color: var(--text-muted, #8a8a8a);
    font-size: 0.9rem;
}

/* ==========================================
   Responsive
   ========================================== */

@media (max-width: 768px) {
    .tracklist-header {
        display: none;
    }

    .tracklist-builder .track-row {
        flex-wrap: wrap;
        gap: 8px;
        padding: 12px;
    }

    .track-drag-handle {
        order: -1;
    }

    .track-position-wrap {
        width: 50px;
    }

    .track-artist-wrap {
        width: 100%;
        order: 3;
    }

    .track-title-wrap {
        flex: 1;
        min-width: calc(100% - 150px);
    }

    .track-duration-wrap {
        width: 60px;
    }

    .tracklist-footer {
        flex-direction: column;
        gap: 12px;
    }

    .tracklist-info {
        width: 100%;
        justify-content: space-between;
    }
}

/* ==========================================
   Scrollbar Styling
   ========================================== */

.tracklist-rows::-webkit-scrollbar {
    width: 6px;
}

.tracklist-rows::-webkit-scrollbar-track {
    background: var(--bg-dark, #0c0c0c);
}

.tracklist-rows::-webkit-scrollbar-thumb {
    background: var(--border, #2a2a2a);
    border-radius: 3px;
}

.tracklist-rows::-webkit-scrollbar-thumb:hover {
    background: var(--border-hover, #3a3a3a);
}

/* ==========================================
   Animation
   ========================================== */

@keyframes trackRowAdd {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tracklist-builder .track-row {
    animation: trackRowAdd 0.2s ease-out;
}

/* ==========================================
   Integration with Existing Preview
   ========================================== */

.tracklist-preview-output {
    margin-top: 1rem;
    padding: 12px;
    background: var(--bg-dark, #0c0c0c);
    border: 1px solid var(--border, #2a2a2a);
    border-radius: 6px;
}

.tracklist-preview-output .preview-label {
    font-size: 0.75rem;
    color: var(--text-muted, #8a8a8a);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.tracklist-preview-output pre {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85rem;
    color: var(--text-secondary, #a0a0a0);
    white-space: pre-wrap;
    margin: 0;
    line-height: 1.6;
}
