/* Song Editor - Chord/Lyrics Editor Styles */
/* Updated with warm colors and glassmorphism */

/* ============================================
   MAIN EDITOR CONTAINER
   ============================================ */

.song-editor-container {
    display: flex;
    flex-direction: column;
    /* Full height minus app header (~64px) and body content padding/margins (~56px) */
    height: calc(100vh - 120px);
    height: calc(100dvh - 120px);
    max-height: calc(100vh - 120px);
    max-height: calc(100dvh - 120px);
    min-height: 0;
    overflow: hidden;
    /* Only extend horizontally, not vertically */
    margin: 0 -1.5rem;
    width: calc(100% + 3rem);
}

.song-metadata-header {
    flex-shrink: 0;
    background: var(--yw-header-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--yw-border);
    padding: 1rem 1.5rem;
}

.sections-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: visible;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 0;
}

/* ============================================
   SONG TITLE INPUT
   ============================================ */

.song-title-input {
    font-size: 1.75rem;
    font-weight: 600;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
    color: var(--yw-text);
    letter-spacing: -0.02em;
}

.song-title-input:focus {
    outline: none !important;
    border-bottom: 2px solid var(--yw-primary) !important;
}

.song-title-input::placeholder {
    color: var(--yw-text-muted);
}

/* ============================================
   SECTION EDITOR CARD
   ============================================ */

.section-editor {
    background: var(--yw-surface-solid);
    border: 1px solid var(--yw-card-border);
    border-radius: var(--yw-border-radius-lg);
    border-left: 4px solid var(--section-color, var(--yw-primary));
    box-shadow: var(--yw-shadow-sm);
    transition: box-shadow var(--yw-transition-fast);
    overflow: visible;
}

.section-editor.collapsed {
    border-left-color: var(--yw-text-muted);
}

.section-editor:hover {
    box-shadow: var(--yw-shadow-md);
    /* Removed transform to avoid creating new containing block for fixed popup */
}

/* Section type colors - Warm Palette */
.section-type-intro { --section-color: #9B59B6; }
.section-type-verse { --section-color: #E07B39; }
.section-type-prechorus { --section-color: #F39C12; }
.section-type-chorus { --section-color: #27AE60; }
.section-type-bridge { --section-color: #E74C3C; }
.section-type-interlude { --section-color: #8E44AD; }
.section-type-outro { --section-color: #34495E; }
.section-type-tag { --section-color: #D35400; }

/* ============================================
   SECTION HEADER
   ============================================ */

.section-header {
    background: var(--yw-surface);
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--yw-border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.section-type-badge {
    background: var(--section-color, var(--yw-primary));
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.section-label-input {
    flex: 1;
    font-weight: 500;
    background: transparent;
    border: none;
    color: var(--yw-text);
}

.section-actions {
    display: flex;
    gap: 0.25rem;
}

.section-action-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--yw-border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--yw-text-muted);
    cursor: pointer;
    transition: all var(--yw-transition-fast);
}

.section-action-btn:hover {
    background: var(--yw-surface-hover);
    color: var(--yw-text);
}

.section-action-btn.danger:hover {
    background: var(--yw-danger-light);
    color: var(--yw-danger);
}

/* ============================================
   CHORD SHEET
   ============================================ */

.chord-sheet {
    font-family: var(--yw-font-mono);
    font-size: 14px;
    line-height: 1.5;
    cursor: text;
    padding: 1rem;
    background: var(--yw-surface-solid);
    border-radius: 0 0 var(--yw-border-radius) var(--yw-border-radius);
    min-height: 100px;
    user-select: none;
    transition: background-color var(--yw-transition-fast);
}

.chord-sheet:hover {
    background: var(--yw-surface-hover);
}

/* ============================================
   CHORD LINE CONTAINER
   ============================================ */

.chord-line-container {
    position: relative;
    margin-bottom: 0.5rem;
}

.chord-line {
    position: relative;
    height: 1.5em;
    color: var(--yw-primary);
    font-weight: 700;
    pointer-events: none;
}

/* ============================================
   CHORD MARKERS
   ============================================ */

.chord-marker {
    position: absolute;
    top: 0;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.15s ease;
    white-space: nowrap;
    pointer-events: auto;
    background-color: rgba(var(--yw-primary-rgb), 0.1);
    color: var(--yw-primary);
    font-size: 13px;
    font-weight: 700;
}

.chord-marker:hover {
    background-color: var(--yw-primary);
    color: white;
    transform: scale(1.1);
    box-shadow: var(--yw-shadow-sm);
}

.chord-marker.dragging {
    opacity: 0.5;
    transform: scale(1.15);
    box-shadow: var(--yw-shadow-md);
}

.chord-line.drag-over {
    background: rgba(var(--yw-primary-rgb), 0.1);
    border-radius: 4px;
}

.chord-drop-indicator {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--yw-primary);
    pointer-events: none;
    z-index: 10;
}

/* ============================================
   LYRICS LINE
   ============================================ */

.lyrics-line {
    white-space: pre;
    min-height: 1.5em;
    cursor: text;
    padding: 2px 4px;
    border-radius: 4px;
    transition: background-color var(--yw-transition-fast);
    color: var(--yw-text);
}

.lyrics-line:hover {
    background-color: rgba(var(--yw-primary-rgb), 0.08);
}

.lyrics-line.drag-over {
    background-color: rgba(var(--yw-primary-rgb), 0.15);
    outline: 2px dashed var(--yw-primary);
    outline-offset: -2px;
}

.lyrics-line.empty {
    color: var(--yw-text-muted);
    font-style: italic;
}

.lyrics-line.empty::after {
    content: '\00a0';
}

/* ============================================
   CHORD MODAL
   ============================================ */

.chord-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: overlayFadeIn 0.15s ease;
}

@keyframes overlayFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.chord-modal {
    background: var(--yw-surface-solid);
    border: 1px solid var(--yw-border);
    border-radius: var(--yw-border-radius-lg);
    box-shadow: var(--yw-shadow-lg);
    min-width: 320px;
    max-width: 90vw;
    animation: modalSlideIn 0.2s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.chord-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--yw-border);
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--yw-text);
}

.chord-modal-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--yw-text-muted);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color var(--yw-transition-fast);
}

.chord-modal-close:hover {
    color: var(--yw-text);
}

.chord-modal-body {
    padding: 1.25rem;
}

.chord-modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--yw-border);
    gap: 0.5rem;
}

.chord-modal-footer-right {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
}

/* Quick chords section */
.quick-chords-section {
    margin-top: 1rem;
}

.quick-chords-label {
    display: block;
    font-size: 0.875rem;
    color: var(--yw-text-muted);
    margin-bottom: 0.5rem;
}

.quick-chords-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(54px, 1fr));
    gap: 0.375rem;
}

.quick-chord-btn {
    min-width: 50px;
    height: 40px;
    padding: 0 0.5rem;
    font-family: var(--yw-font-mono);
    font-weight: 700;
    font-size: 0.8rem;
    border-radius: var(--yw-border-radius);
    border: 1px solid var(--yw-border);
    background: var(--yw-surface);
    color: var(--yw-text);
    cursor: pointer;
    transition: all var(--yw-transition-fast);
    white-space: nowrap;
}

.quick-chord-btn:hover {
    background: var(--yw-primary);
    color: white;
    border-color: var(--yw-primary);
    transform: scale(1.05);
}

/* Chord input */
.chord-input {
    font-family: var(--yw-font-mono);
    font-weight: 700;
    text-align: center;
    font-size: 1.5rem;
    padding: 0.75rem;
    border-radius: var(--yw-border-radius);
    border: 2px solid var(--yw-border);
    background: var(--yw-surface);
    color: var(--yw-text);
    width: 100%;
    transition: all var(--yw-transition-fast);
}

.chord-input:focus {
    border-color: var(--yw-primary);
    box-shadow: 0 0 0 3px rgba(var(--yw-primary-rgb), 0.15);
    outline: none;
}

/* ============================================
   LYRICS EDITOR (Textarea mode)
   ============================================ */

.lyrics-editor-textarea {
    font-family: var(--yw-font-mono);
    font-size: 14px;
    line-height: 1.5;
    padding: 1rem;
    border: 1px solid var(--yw-border);
    border-radius: var(--yw-border-radius);
    background: var(--yw-surface-solid);
    color: var(--yw-text);
    resize: vertical;
    min-height: 150px;
    width: 100%;
}

.lyrics-editor-textarea:focus {
    border-color: var(--yw-primary);
    box-shadow: 0 0 0 3px rgba(var(--yw-primary-rgb), 0.15);
    outline: none;
}

/* ============================================
   ADD SECTION AREA
   ============================================ */

.add-section-area {
    border: 2px dashed var(--yw-border-strong);
    border-radius: var(--yw-border-radius-lg);
    padding: 1.5rem;
    text-align: center;
    transition: all var(--yw-transition-fast);
    cursor: pointer;
    background: transparent;
}

.add-section-area:hover {
    border-color: var(--yw-primary);
    background: rgba(var(--yw-primary-rgb), 0.05);
}

.add-section-area:hover .add-section-icon {
    transform: scale(1.1);
    color: var(--yw-primary);
}

.add-section-icon {
    font-size: 2.5rem;
    color: var(--yw-text-muted);
    transition: all var(--yw-transition-fast);
}

.add-section-text {
    color: var(--yw-text-muted);
    margin-top: 0.5rem;
    font-weight: 500;
}

/* ============================================
   METADATA ROW
   ============================================ */

.metadata-row {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.metadata-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.metadata-label {
    color: var(--yw-text-muted);
    font-size: 0.875rem;
}

.metadata-value {
    font-weight: 500;
    color: var(--yw-text);
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .sections-container {
        padding: 1rem;
    }

    .chord-sheet {
        font-size: 12px;
        padding: 0.75rem;
    }

    .chord-marker {
        font-size: 11px;
        padding: 1px 4px;
    }

    .song-title-input {
        font-size: 1.25rem;
    }

    .section-header {
        flex-wrap: wrap;
    }

    .section-actions {
        width: 100%;
        justify-content: flex-end;
        margin-top: 0.5rem;
    }

    .metadata-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    .song-editor-container {
        height: auto;
        overflow: visible;
    }

    .section-editor {
        break-inside: avoid;
        page-break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }

    .chord-sheet {
        background: white;
    }

    .section-actions,
    .add-section-area {
        display: none;
    }
}

/* ============================================
   DARK MODE FIXES FOR EDITOR
   ============================================ */

/* Buttons in section editor - make them visible in dark mode */
.theme-dark .section-editor .rz-button.rz-variant-flat,
.theme-dark .section-editor .rz-button.rz-variant-outlined,
.theme-dark .section-editor .rz-button:not(.rz-primary):not(.rz-danger):not(.rz-success):not(.rz-warning):not(.rz-info):not(.rz-secondary) {
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: var(--yw-text) !important;
}

.theme-dark .section-editor .rz-button.rz-variant-flat:hover,
.theme-dark .section-editor .rz-button.rz-variant-outlined:hover,
.theme-dark .section-editor .rz-button:not(.rz-primary):not(.rz-danger):not(.rz-success):not(.rz-warning):not(.rz-info):not(.rz-secondary):hover {
    background: rgba(255, 255, 255, 0.2) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
}

/* Chord modal in dark mode */
.theme-dark .chord-modal {
    background: #1E1E32 !important;
    border-color: rgba(255, 255, 255, 0.15) !important;
}

.theme-dark .chord-modal-header {
    border-color: rgba(255, 255, 255, 0.1) !important;
}

.theme-dark .chord-modal-footer {
    border-color: rgba(255, 255, 255, 0.1) !important;
}

.theme-dark .chord-input {
    background: rgba(255, 255, 255, 0.05) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
    color: var(--yw-text) !important;
}

.theme-dark .quick-chord-btn {
    background: rgba(255, 255, 255, 0.08) !important;
    border-color: rgba(255, 255, 255, 0.15) !important;
    color: var(--yw-text) !important;
}

.theme-dark .quick-chord-btn:hover {
    background: var(--yw-primary) !important;
    color: white !important;
}

/* Section header in dark mode */
.theme-dark .section-header {
    background: rgba(255, 255, 255, 0.03);
}

/* Chord sheet in dark mode */
.theme-dark .chord-sheet {
    background: rgba(0, 0, 0, 0.2);
}

.theme-dark .chord-sheet:hover {
    background: rgba(0, 0, 0, 0.25);
}

/* ============================================
   CHORD DIALOG (Radzen Dialog)
   ============================================ */

.chord-dialog {
    padding: 0;
}

.chord-dialog-body {
    padding: 1.25rem;
}

.chord-dialog-input {
    font-family: var(--yw-font-mono);
    font-weight: 700;
    text-align: center;
    font-size: 1.5rem;
    padding: 0.75rem;
    border-radius: var(--yw-border-radius);
    border: 2px solid var(--yw-border);
    background: var(--yw-surface);
    color: var(--yw-text);
    width: 100%;
    transition: all var(--yw-transition-fast);
}

.chord-dialog-input:focus {
    border-color: var(--yw-primary);
    box-shadow: 0 0 0 3px rgba(var(--yw-primary-rgb), 0.15);
    outline: none;
}

.chord-dialog-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--yw-border);
    gap: 0.5rem;
    background: var(--yw-surface);
}

.chord-dialog-footer-right {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
}

/* Dark mode for chord dialog */
.theme-dark .chord-dialog-input {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--yw-text);
}

.theme-dark .chord-dialog-footer {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.1);
}

/* ============================================
   CHORD-ONLY MODE (Instrumental sections)
   ============================================ */

.chord-only-container {
    padding: 1rem;
    background: var(--yw-surface-solid);
    border-radius: 0 0 var(--yw-border-radius) var(--yw-border-radius);
    min-height: 60px;
}

.chord-sequence {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    min-height: 40px;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--yw-border-radius);
    transition: background-color var(--yw-transition-fast);
}

.chord-sequence:hover {
    background: rgba(var(--yw-primary-rgb), 0.08);
}

.chord-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    padding: 0.5rem 0.75rem;
    font-family: var(--yw-font-mono);
    font-weight: 700;
    font-size: 1rem;
    background: rgba(var(--yw-primary-rgb), 0.15);
    color: var(--yw-primary);
    border-radius: var(--yw-border-radius);
    transition: all var(--yw-transition-fast);
}

.chord-badge:hover {
    background: var(--yw-primary);
    color: white;
    transform: scale(1.05);
}

/* Dark mode for chord-only */
.theme-dark .chord-only-container {
    background: rgba(0, 0, 0, 0.2);
}

.theme-dark .chord-badge {
    background: rgba(var(--yw-primary-rgb), 0.25);
}

.theme-dark .chord-sequence:hover {
    background: rgba(var(--yw-primary-rgb), 0.12);
}
