/* Session Fakebook Styles */

/* Fakebook page header styles - only apply on fakebook.html */
body.fakebook-page header h1 {
    font-family: 'Indie Flower', cursive;
    font-weight: bold;
    font-size: 3rem;
}

/* Celtic font for institutional volume titles */
body.fakebook-page header h1.institution-title {
    font-family: 'Uncial Antiqua', serif;
    font-weight: normal;
}

body.fakebook-page header .tagline {
    font-family: 'Indie Flower', cursive;
    font-size: 1.5rem;
}

.fakebook-stats {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin: 40px 0;
    padding: 20px 32px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-card);
    font-size: 1.3rem;
    font-family: 'Indie Flower', cursive;
    color: var(--text-secondary);
    white-space: nowrap;
}

.fakebook-stats #fakebookCount {
    font-size: 2.5rem;
    font-weight: 700;
    font-family: 'Indie Flower', cursive;
    color: var(--text-accent);
    line-height: 1;
}

.fakebook-filter-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

.fakebook-filter-section input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--bg-card);
    color: var(--text-primary);
}

.fakebook-filter-section input:focus {
    outline: none;
    border-color: var(--text-accent);
    box-shadow: 0 0 0 2px rgba(42, 84, 52, 0.1);
}

.dark-theme .fakebook-filter-section input {
    color: #f4e4bc !important;
}

.fakebook-filter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.fakebook-filter-section .filter-btn {
    background: #faf7f0;
    color: var(--text-accent);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.dark-theme .fakebook-filter-section .filter-btn {
    background: var(--gradient-brown);
    color: #f4e4bc;
    border: 1px solid rgba(212, 175, 55, 0.3);
}

.fakebook-filter-section .filter-btn:hover {
    background: var(--bg-accent);
    border-color: var(--text-accent);
}

.dark-theme .fakebook-filter-section .filter-btn:hover:not(.active) {
    background: linear-gradient(135deg, #a0522d, #8b4513);
    border-color: var(--text-accent);
}

.fakebook-filter-section .filter-btn.active {
    background: var(--bg-button-primary);
    color: white;
    border-color: transparent;
}

.dark-theme .fakebook-filter-section .filter-btn.active {
    background: linear-gradient(135deg, #d4af37, #b8941f) !important;
    color: white !important;
    border-color: transparent !important;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-accent);
}

.dark-theme .stat-value {
    color: var(--text-secondary);
}

.unlimited-badge {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
}

.fakebook-container {
    padding: 0;
    margin: 0;
}

.fakebook-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px 32px;
    margin-bottom: 40px;
    box-shadow: var(--shadow-elevated);
    position: relative;
}

/* Space between music systems (not above first) */
.fakebook-item svg + svg {
    margin-top: 10px;
}

.fakebook-item-header {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: flex-start;
    margin-bottom: 8px;
    gap: 10px;
    position: relative;
}

/* Fakebook tempo control - inside title container, flows after metadata */
.fakebook-tempo-control {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
    margin-bottom: 4px;
}

.fakebook-tempo-control .ctrl-label {
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    color: var(--text-muted);
}

.fakebook-tempo-control .tempo-note {
    font-size: 14px;
}

.fakebook-tempo-control .tempo-equals {
    font-size: 10px;
    margin: 0 2px;
}

.fakebook-tempo-control input[type="range"] {
    width: 180px;
    max-width: 180px;
    flex-shrink: 0;
}

/* Drag handle for reordering */
.drag-handle {
    grid-column: 1;
    grid-row: 1;
    align-self: start;
    cursor: grab;
    font-size: 1.8rem;
    color: var(--text-muted);
    opacity: 0.5;
    margin-left: -20px;
    margin-top: -10px;
    padding: 4px;
    user-select: none;
    touch-action: none;
    transition: opacity 0.2s, color 0.2s;
}

.drag-handle:hover {
    opacity: 1;
    color: var(--text-accent);
}

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

/* Hide drag handle when filters are active */
.fakebook-container.filters-active .drag-handle {
    opacity: 0.2;
    pointer-events: none;
}

/* Mobile arrow buttons - hidden by default */
.mobile-arrow-up,
.mobile-arrow-down {
    display: none;
}

/* On touch devices OR narrow screens: show arrows, hide drag handle */
@media (hover: none) and (pointer: coarse), (max-width: 768px) {
    .drag-handle {
        display: none;
    }

    .fakebook-item {
        position: relative;
    }

    .mobile-arrow-up,
    .mobile-arrow-down {
        display: flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        bottom: 8px;
        width: 28px;
        height: 28px;
        font-size: 0.65rem;
        color: var(--text-accent);
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        border-radius: 50%;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    }

    .mobile-arrow-up {
        right: 4px;
    }

    .mobile-arrow-down {
        left: 4px;
    }
}

/* Hide arrows when filters are active */
.fakebook-container.filters-active .mobile-arrow-up,
.fakebook-container.filters-active .mobile-arrow-down {
    opacity: 0.2;
    pointer-events: none;
}

/* SortableJS ghost styling - item being dragged */
.fakebook-item.sortable-ghost {
    opacity: 0.4;
    background: var(--bg-accent);
}

/* SortableJS chosen styling - item picked up */
.fakebook-item.sortable-chosen {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* SortableJS drag styling */
.fakebook-item.sortable-drag {
    opacity: 1;
}

.fakebook-item-title {
    grid-column: 2 / 3;
    grid-row: 1 / 3;
    min-width: 0;
    padding-right: 10px;
}

.fakebook-item-title h3 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--text-accent);
    font-family: 'Uncial Antiqua', 'Cinzel', 'Trajan Pro', Georgia, serif;
}

.fakebook-tune-metadata {
    margin: 0;
    font-size: 0.9rem;
    font-style: italic;
    color: var(--text-muted);
    font-family: Georgia, serif;
}

.fakebook-item-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.badge, .key-badge, .difficulty-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.badge {
    background: var(--bg-badge);
    color: var(--text-primary);
}

.key-badge {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.difficulty-badge {
    background: #e8f5e9;
    color: #2e7d32;
    text-transform: capitalize;
}

.dark-theme .difficulty-badge {
    background: rgba(76, 175, 80, 0.2);
    color: #81c784;
}

.fakebook-item-actions {
    display: contents;
}

/* Bin button - top right, column 4, row 1 */
.fakebook-item-actions .bin-button {
    grid-column: 4;
    grid-row: 1;
    justify-self: end;
}

/* Print button - above headphones, column 3, row 1 */
.fakebook-item-actions .print-button {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
}

/* Play button (headphones) - below printer, column 3, row 2 */
.fakebook-item-actions > button:not(.bin-button):not(.print-button) {
    grid-column: 3;
    grid-row: 2;
    justify-self: end;
}

/* Controls - below bin, column 4, row 2 */
.fakebook-item-actions > a {
    grid-column: 4;
    grid-row: 2;
    justify-self: end;
}

.fakebook-item .btn-icon {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    opacity: 0.7;
    text-decoration: none;
}

/* Mobile tap feedback - immediate press-in effect while tapping */
.btn-icon:active {
    transform: scale(0.9) !important;
    opacity: 0.4 !important;
    transition: none !important;
}

/* Only apply hover on pointer devices (desktop mice), NOT touch devices */
@media (hover: hover) and (pointer: fine) {
    .fakebook-item .btn-icon {
        transition: all 0.2s ease;
    }

    .btn-icon:hover {
        transform: scale(1.2);
        opacity: 0.8;
    }
}

.fakebook-sheet-music {
    overflow-x: auto;
    margin-bottom: 0;
}

.fakebook-sheet-music svg {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
}

/* Light mode SVG styling */
.fakebook-sheet-music svg text {
    fill: #000000 !important;
    font-weight: 500;
}

/* Indie Flower font for chord symbols */
.fakebook-sheet-music svg text[data-name="chord"] {
    font-family: 'Indie Flower', cursive !important;
    font-size: 20px !important;
    font-weight: bold !important;
    fill: #000000 !important;
}

.fakebook-sheet-music svg .abcjs-note {
    fill: #000000 !important;
}

.fakebook-sheet-music svg .abcjs-staff,
.fakebook-sheet-music svg .abcjs-ledger {
    stroke: #000000 !important;
}

.fakebook-sheet-music svg .abcjs-stem,
.fakebook-sheet-music svg .abcjs-beam {
    fill: #000000 !important;
}

.fakebook-sheet-music svg .abcjs-note,
.fakebook-sheet-music svg .abcjs-notehead,
.fakebook-sheet-music svg path,
.fakebook-sheet-music svg ellipse,
.fakebook-sheet-music svg circle,
.fakebook-sheet-music svg text,
.fakebook-sheet-music svg tspan {
    user-select: none;
}

/* Dark mode SVG styling */
.dark-theme .fakebook-sheet-music svg text {
    fill: var(--text-muted) !important;
}

.dark-theme .fakebook-sheet-music svg text[data-name="chord"] {
    font-family: 'Indie Flower', cursive !important;
    font-size: 20px !important;
    font-weight: bold !important;
    fill: var(--text-muted) !important;
}

.dark-theme .fakebook-sheet-music svg .abcjs-note,
.dark-theme .fakebook-sheet-music svg .abcjs-notehead,
.dark-theme .fakebook-sheet-music svg path,
.dark-theme .fakebook-sheet-music svg ellipse,
.dark-theme .fakebook-sheet-music svg circle,
.dark-theme .fakebook-sheet-music svg text,
.dark-theme .fakebook-sheet-music svg tspan {
    fill: var(--text-muted) !important;
}

.dark-theme .fakebook-sheet-music svg g[data-name="ending"] path {
    stroke: var(--text-muted) !important;
    fill: none !important;
}

.dark-theme .fakebook-sheet-music svg g[data-name="ending"] text,
.dark-theme .fakebook-sheet-music svg g[data-name="ending"] tspan {
    fill: var(--text-muted) !important;
}

.dark-theme .fakebook-sheet-music svg .abcjs-staff,
.dark-theme .fakebook-sheet-music svg .abcjs-staff-extra,
.dark-theme .fakebook-sheet-music svg .abcjs-ledger,
.dark-theme .fakebook-sheet-music svg line {
    stroke: var(--text-muted) !important;
    fill: none !important;
}

.dark-theme .fakebook-sheet-music svg .abcjs-stem,
.dark-theme .fakebook-sheet-music svg .abcjs-beam,
.dark-theme .fakebook-sheet-music svg rect {
    fill: var(--text-muted) !important;
}

.fakebook-attribution {
    margin-top: 4px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
    font-size: 0.9rem;
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Empty state styling */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: var(--bg-secondary);
    border-radius: 12px;
    box-shadow: var(--shadow-card);
}

.empty-state h3 {
    margin-bottom: 16px;
    color: var(--text-accent);
}

.dark-theme .empty-state h3 {
    color: var(--text-secondary);
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 12px;
    line-height: 1.6;
}

.empty-state .btn-primary {
    margin-top: 20px;
}

/* Loading state */
.loading {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* Upgrade modal specific styles */
.fakebook-upgrade-benefits {
    margin: 24px 0;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.fakebook-upgrade-benefits h3 {
    margin-bottom: 16px;
    color: var(--text-primary);
}

.fakebook-upgrade-benefits ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.fakebook-upgrade-benefits li {
    padding: 8px 0;
    color: var(--text-primary);
    font-size: 1rem;
    line-height: 1.6;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 24px;
}

.modal-actions .btn-primary {
    width: 100%;
}

.modal-actions .btn-secondary {
    width: 100%;
}

/* Premium modal styling */
/* Light mode: make modal title and description dark green */
#fakebookUpgradeModal h2,
#fakebookUpgradeModal .modal-content > p {
    color: var(--text-accent);
}

.dark-theme #fakebookUpgradeModal h2,
.dark-theme #fakebookUpgradeModal .modal-content > p {
    color: var(--text-muted); /* Tan in dark mode */
}

.fakebook-upgrade-benefits h3 {
    color: var(--text-accent); /* Light: dark green, Dark: gold */
}

.fakebook-upgrade-benefits ul,
.fakebook-upgrade-benefits li {
    color: var(--text-accent); /* Light mode: dark green */
}

.dark-theme .fakebook-upgrade-benefits ul,
.dark-theme .fakebook-upgrade-benefits li {
    color: var(--text-muted); /* Dark mode: tan */
}

/* Make upgrade button text bold in both themes */
#fakebookUpgradeModal .btn-primary {
    font-weight: bold;
}

/* Dark theme GOLD button for upgrade modal - starts gold */
.dark-theme #fakebookUpgradeModal .btn-primary {
    background: linear-gradient(135deg, #d4af37, #b8941f);
    color: white;
    border: 2px solid rgba(212, 175, 55, 0.3);
    box-shadow: 0 3px 8px rgba(212, 175, 55, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.dark-theme #fakebookUpgradeModal .btn-primary:hover {
    background: linear-gradient(135deg, #f4e4bc, #d4af37);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(212, 175, 55, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

/* Responsive design */
@media (max-width: 768px) {
    .fakebook-stats {
        flex-direction: column;
        gap: 20px;
    }

    .fakebook-filter-buttons {
        justify-content: center;
    }

    .fakebook-item-header {
        gap: 6px;
        margin-bottom: 4px;
    }

    .fakebook-item-title {
        padding-right: 70px;
    }

    .fakebook-item-title h3 {
        font-size: 1.3rem;
        margin-bottom: 0;
    }

    .fakebook-tune-metadata {
        display: block;
        font-size: 0.85rem;
    }

    .fakebook-tempo-control {
        gap: 0;
        margin-top: 4px;
    }

    .fakebook-tempo-control input[type="range"] {
        width: 134px;
        margin-left: -15px;
    }

    /* Absolute position buttons so they don't shift when title wraps */
    .fakebook-item-header {
        position: relative;
    }

    .fakebook-item-actions {
        display: grid;
        grid-template-columns: auto auto;
        gap: 4px;
        position: absolute;
        top: 0;
        right: 0;
    }

    .fakebook-item-actions .bin-button,
    .fakebook-item-actions .print-button,
    .fakebook-item-actions > button:not(.bin-button):not(.print-button),
    .fakebook-item-actions > a {
        grid-column: auto;
        grid-row: auto;
        justify-self: auto;
    }

    /* Order: print, bin on row 1; play, controls on row 2 */
    .fakebook-item-actions .print-button { order: 1; }
    .fakebook-item-actions .bin-button { order: 2; }
    .fakebook-item-actions > button:not(.bin-button):not(.print-button) { order: 3; }
    .fakebook-item-actions > a { order: 4; }

    .fakebook-attribution {
        font-size: 0.8rem;
        display: flex;
        flex-direction: column;
        gap: 4px;
        text-align: center;
        align-items: center;
    }

    .attribution-metadata {
        display: block;
    }

    .fakebook-item {
        padding: 8px;
    }

    .fakebook-item.melody-only {
        padding-bottom: 40px; /* Room for mobile arrow buttons when no attribution */
    }

    .fakebook-sheet-music {
        display: flex;
        justify-content: center;
        overflow: visible;
        margin-left: 0;
        margin-right: 0;
    }

    .fakebook-sheet-music svg {
        display: block;
        margin: 0 auto;
        width: 100% !important;
        height: auto !important;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .fakebook-attribution {
        font-size: 0.8rem;
    }
}

/* Print All container - buttons centered */
.print-all-container {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 8px;
    width: 100%;
    position: relative;
}

/* Button text variants - long text on desktop, short on mobile */
.print-all-container .btn-text-short {
    display: none;
}

/* Consistent button sizing for all header buttons (except emoji buttons) */
.print-all-container button:not(.reset-order-btn):not(.print-all-btn),
.print-all-container .my-sets-btn {
    height: 38px;
    padding: 0 16px;
    font-size: 0.9rem;
    font-weight: 500;
}

/* Print and ABC buttons - emoji style, identical sizing */
.print-all-btn,
.reset-order-btn {
    width: 48px;
    height: 48px;
    font-size: 2rem;
    background: none;
    border: none;
    box-shadow: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    border-radius: 8px;
    opacity: 0.7;
    display: flex;
    align-items: center;
    justify-content: center;
    color: inherit;
}

/* Position both buttons on the right */
.print-all-btn {
    position: absolute;
    right: 64px;
}

.reset-order-btn {
    position: absolute;
    right: 0;
}

.print-all-btn:active,
.reset-order-btn:active {
    transform: scale(0.9);
    opacity: 0.4;
}

@media (hover: hover) and (pointer: fine) {
    .print-all-btn,
    .reset-order-btn {
        transition: all 0.2s ease;
    }

    .print-all-btn:hover,
    .reset-order-btn:hover {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Print-only branding - hidden on screen */
.print-branding,
.tune-print-branding {
    display: none;
}

/* Print styles for printing fakebook */
@media print {
    /* Force light theme - override all dark theme styles */
    body,
    .fakebook-item,
    .fakebook-sheet-music,
    header {
        background: white !important;
        color: #000 !important;
    }

    /* Full width - remove container constraints */
    .container {
        max-width: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Hide screen-only elements */
    .auth-section-top,
    header .header-actions,
    .fakebook-stats,
    .fakebook-filter-section,
    .print-all-container,
    .fakebook-item-actions,
    .btn-icon,
    .drag-handle,
    .mobile-arrow-up,
    .mobile-arrow-down,
    .tune-select-checkbox,
    .selection-mode .tune-select-checkbox,
    .set-builder-panel,
    footer {
        display: none !important;
    }

    /* Reset selection mode styling for print */
    .selection-mode .fakebook-item,
    .selection-mode .fakebook-item.selected {
        background: white !important;
        box-shadow: none !important;
        border: none !important;
        border-bottom: 1px solid #ccc !important;
    }

    .selection-mode .fakebook-item-title {
        padding-left: 0 !important;
    }

    .selection-mode .fakebook-item:last-child {
        border-bottom: none !important;
    }

    /* Show header branding - subtle */
    .print-branding {
        display: block;
        text-align: center;
        font-size: 0.65rem;
        color: #999;
        font-style: italic;
        margin-top: 30px;
    }

    .print-branding a {
        color: #999;
        text-decoration: none;
    }

    /* Show tune branding in top right */
    .tune-print-branding {
        display: block;
        position: absolute;
        top: 0;
        right: 0;
        font-size: 0.75rem;
        color: #2a5434;
        font-weight: 600;
        text-decoration: none;
    }

    /* Position fakebook-item-header relatively for absolute positioning */
    .fakebook-item-header {
        position: relative;
    }

    /* Fakebook items - no cards, full width, clean separation */
    .fakebook-item {
        page-break-inside: avoid;
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
        padding: 0 !important;
        margin-bottom: 24px;
        padding-bottom: 20px !important;
        border-bottom: 1px solid #ccc !important;
        background: white;
    }

    /* Last item doesn't need bottom border */
    .fakebook-item:last-child {
        border-bottom: none !important;
        margin-bottom: 0;
    }

    .fakebook-sheet-music {
        background: white;
        margin: 0;
    }

    /* Clean up attribution for print */
    .fakebook-attribution {
        border-top: none;
        padding-top: 4px;
        margin-top: 8px;
    }

    /* With oneSvgPerLine, each system is its own SVG - avoid breaking inside */
    .fakebook-sheet-music {
        display: block !important;
        overflow: visible !important;
    }

    .fakebook-sheet-music svg {
        display: block !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
        -webkit-column-break-inside: avoid !important;
        page-break-before: auto !important;
        page-break-after: auto !important;
    }

    .fakebook-sheet-music > div,
    .fakebook-sheet-music .abcjs-inner {
        display: block !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
        -webkit-column-break-inside: avoid !important;
        overflow: visible !important;
    }


    body {
        background: white;
    }

    /* Keep header visible but remove card styling */
    header {
        display: block;
        text-align: center;
        margin-bottom: 20px;
        padding: 0 !important;
        background: none !important;
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
    }

    /* Show institution name in top right for institutional accounts */
    .institution-print-name {
        display: block !important;
        position: absolute;
        top: 10px;
        right: 20px;
        font-family: 'Uncial Antiqua', serif;
        font-size: 1.3rem;
        color: #2a7575;
        text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.15);
        letter-spacing: 0.5px;
    }

    /* Center title vertically when first tune pushed to page 2 */
    .center-title-page header {
        min-height: 100vh;
        display: flex !important;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        page-break-after: always;
    }

    /* Hide Set Builder panel when printing */
    .set-builder-panel {
        display: none !important;
    }
}

/* ==================== */
/* Set Builder Feature  */
/* ==================== */

/* Create Set and My Sets buttons in header - match tune page toggle style */
.create-set-btn,
.my-sets-btn {
    background: linear-gradient(135deg, #f0f7f0, #e8f4e8) !important;
    color: #2a5434 !important;
    border: 2px solid rgba(42, 84, 52, 0.2) !important;
    border-radius: 8px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
}

.create-set-btn:hover,
.my-sets-btn:hover {
    background: linear-gradient(135deg, #e8f4e8, #ddeedd) !important;
    color: #1e4228 !important;
    transform: translateY(-1px);
    box-shadow: 0 5px 12px rgba(42, 84, 52, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.4);
    border-color: rgba(42, 84, 52, 0.4) !important;
}

/* Dark theme versions */
.dark-theme .create-set-btn,
.dark-theme .my-sets-btn {
    background: linear-gradient(135deg, #3d3d2d, #4a4a38) !important;
    color: var(--text-secondary) !important;
    border: 2px solid rgba(212, 175, 55, 0.3) !important;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.dark-theme .create-set-btn:hover,
.dark-theme .my-sets-btn:hover {
    background: linear-gradient(135deg, #4a4a38, #575745) !important;
    border-color: rgba(212, 175, 55, 0.5) !important;
    box-shadow: 0 5px 12px rgba(212, 175, 55, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.create-set-btn {
    margin-right: 8px;
}

/* My Sets Dropdown */
.my-sets-dropdown {
    position: relative;
    display: inline-block;
    margin-right: 8px;
}

.my-sets-btn {
    min-width: 95px;
}

.my-sets-dropdown .dropdown-content {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 320px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
    z-index: 100;
    max-height: 320px;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 8px 0;
}

.dark-theme .my-sets-dropdown .dropdown-content {
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

.my-sets-dropdown .dropdown-content.show {
    display: block;
    animation: dropdownFadeIn 0.15s ease;
}

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

.my-sets-dropdown .dropdown-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    margin: 0;
    border-radius: 0;
    cursor: pointer;
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.15s ease;
    border-bottom: 1px solid var(--border-color);
    gap: 12px;
}

.my-sets-dropdown .dropdown-item:last-child {
    border-bottom: none;
}

.my-sets-dropdown .dropdown-item:hover {
    background: var(--bg-accent);
}

.my-sets-dropdown .dropdown-item .set-name {
    flex: 1;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-accent);
    padding-right: 12px;
    border-right: 1px solid var(--border-color);
}

.my-sets-dropdown .dropdown-item .set-count {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: var(--bg-secondary);
    padding: 4px 10px;
    border-radius: 12px;
    white-space: nowrap;
}

.my-sets-dropdown .dropdown-item .delete-set-btn {
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0.6;
    font-size: 1rem;
    padding: 6px 10px;
    border-radius: 8px;
    transition: all 0.15s ease;
}

/* Delete button hover effect on desktop */
@media (hover: hover) and (pointer: fine) {
    .my-sets-dropdown .dropdown-item .delete-set-btn:hover {
        opacity: 1;
        background: rgba(220, 53, 69, 0.1);
        color: #dc3545;
    }
}

.my-sets-dropdown .dropdown-empty {
    padding: 24px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-style: italic;
}

/* Selection mode - checkboxes on tune cards */
.tune-select-checkbox {
    display: none;
    position: absolute;
    top: 16px;
    left: 14px;
    width: 22px;
    height: 22px;
    cursor: pointer;
    z-index: 10;
    accent-color: var(--text-accent);
    transition: transform 0.15s ease;
}

.tune-select-checkbox:hover {
    transform: scale(1.1);
}

.dark-theme .tune-select-checkbox {
    accent-color: var(--text-accent);
}

/* Show checkboxes when in selection mode */
.selection-mode .tune-select-checkbox {
    display: block !important;
}

/* Highlight selected tunes - solid white to pop against gradient default */
.selection-mode .fakebook-item.selected {
    border-color: var(--text-accent);
    background: var(--bg-card);
    box-shadow: inset 4px 0 0 var(--text-accent);
}

.dark-theme .selection-mode .fakebook-item.selected {
    border-color: var(--text-accent);
    background: var(--bg-card);
    box-shadow: inset 4px 0 0 var(--text-accent);
}

/* Set view mode - show tunes as normal (no selection styling) */
.set-view-mode .fakebook-item-title {
    padding-left: 0 !important; /* Override selection-mode title padding */
}

/* Hide checkboxes in set view mode */
.set-view-mode .tune-select-checkbox {
    display: none !important;
}

/* Remove selection border/shadow in set view mode, keep elevated lift */
.set-view-mode .fakebook-item.selected,
.dark-theme.set-view-mode .fakebook-item.selected {
    border-color: var(--border-color);
    box-shadow: var(--shadow-elevated);
}

/* Currently playing tune in set playback */
.fakebook-item.set-playing {
    border-color: #28a745;
    background: linear-gradient(to right, rgba(40, 167, 69, 0.08), transparent);
    box-shadow: inset 4px 0 0 #28a745, 0 0 0 2px rgba(40, 167, 69, 0.2);
}

.dark-theme .fakebook-item.set-playing {
    border-color: #28a745;
    background: linear-gradient(to right, rgba(40, 167, 69, 0.1), transparent);
    box-shadow: inset 4px 0 0 #28a745, 0 0 0 2px rgba(40, 167, 69, 0.3);
}

/* Add padding for checkbox in selection mode - only shift title, not ABC */
.selection-mode .fakebook-item-title {
    padding-left: 36px;
    transition: padding 0.2s ease;
}

/* Hide drag handles in selection mode */
.selection-mode .drag-handle,
.selection-mode .mobile-arrow-up,
.selection-mode .mobile-arrow-down {
    display: none !important;
}

/* ==================== */
/* Compact Set Bar      */
/* ==================== */

/* Compact 48px bar at bottom - replaces bloated panel */
.set-builder-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: var(--bg-card);
    border-top: 2px solid var(--text-accent);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

.dark-theme .set-builder-panel {
    border-top-color: var(--text-accent);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
}

/* Left side: count and reorder button */
.set-bar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.set-bar-count {
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--text-accent);
}

.dark-theme .set-bar-count {
    color: var(--text-secondary);
}

/* Right side: icon buttons */
.set-bar-actions {
    display: flex;
    gap: 8px;
}

.set-builder-panel .btn-icon {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    opacity: 0.7;
    transition: all 0.2s ease;
}

@media (hover: hover) and (pointer: fine) {
    .set-builder-panel .btn-icon:hover {
        transform: scale(1.2);
        opacity: 0.8;
    }
}

/* Add/Remove button - subtle outline for visibility on white */
#addRemoveBtn {
    filter: drop-shadow(0 0 1px rgba(0,0,0,0.3));
}

/* Themed play button - green/gold triangle */
#playSetBtn {
    color: var(--text-accent);
}

.dark-theme #playSetBtn {
    color: var(--text-secondary);
}

/* Playing state for play button */
#playSetBtn.playing {
    transform: scale(1.1);
}

/* Hover state for stop button (playing state) */
@media (hover: hover) and (pointer: fine) {
    #playSetBtn.playing:hover {
        transform: scale(1.2);
    }
}

/* Close button */
.set-bar-close {
    color: var(--text-muted);
}

.set-bar-close:hover {
    color: var(--text-primary);
}

/* Desktop: Compact floating panel with frosted glass effect */
@media (min-width: 769px) {
    .set-builder-panel {
        bottom: 24px;
        left: 24px;
        right: auto;
        width: 200px;
        height: auto;
        padding: 20px;
        border-radius: 16px;
        border: 1px solid rgba(42, 84, 52, 0.3);
        flex-direction: column;
        gap: 16px;
        /* Frosted glass effect */
        background: rgba(255, 255, 255, 0.85);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        /* Layered shadow for depth */
        box-shadow:
            0 2px 4px rgba(0, 0, 0, 0.04),
            0 8px 16px rgba(0, 0, 0, 0.08),
            0 16px 32px rgba(0, 0, 0, 0.08),
            0 0 0 1px rgba(255, 255, 255, 0.5) inset;
        /* Entrance animation */
        animation: setBarSlideIn 0.3s ease-out;
    }

    @keyframes setBarSlideIn {
        from {
            opacity: 0;
            transform: translateY(20px) scale(0.95);
        }
        to {
            opacity: 1;
            transform: translateY(0) scale(1);
        }
    }

    .dark-theme .set-builder-panel {
        background: rgba(30, 30, 25, 0.9);
        border-color: rgba(212, 175, 55, 0.4);
        box-shadow:
            0 2px 4px rgba(0, 0, 0, 0.1),
            0 8px 16px rgba(0, 0, 0, 0.2),
            0 16px 32px rgba(0, 0, 0, 0.25),
            0 0 20px rgba(212, 175, 55, 0.1),
            0 0 0 1px rgba(212, 175, 55, 0.15) inset;
    }

    .set-bar-left {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
        width: 100%;
    }

    /* Count on its own row, centered */
    .set-bar-count {
        flex: 0 0 100%;
        text-align: center;
        font-size: 1.15rem;
        font-weight: 600;
        color: var(--text-accent);
    }

    .dark-theme .set-bar-count {
        color: var(--text-secondary);
    }

    /* When showing saved set: put "(x tunes)" on new line under set name */
    #setCountLabel {
        display: block;
        font-size: 0.9rem;
        opacity: 0.8;
        margin-top: 2px;
    }

    /* Edit/reorder buttons stay side by side on next row */

    .set-bar-actions {
        justify-content: center;
        gap: 10px;
        width: 100%;
        padding-top: 4px;
        border-top: 1px solid rgba(0, 0, 0, 0.08);
    }

    .dark-theme .set-bar-actions {
        border-top-color: rgba(255, 255, 255, 0.1);
    }

    /* All buttons same size, no background */
    .set-builder-panel .btn-icon {
        font-size: 1.3rem;
        background: none;
        border: none;
    }
}

/* ==================== */
/* Reorder Modal        */
/* ==================== */

.reorder-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: 2000;
    animation: modalFadeIn 0.2s ease;
}

.reorder-modal {
    background: var(--bg-card);
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.25);
    animation: modalSlideIn 0.25s ease;
}

.dark-theme .reorder-modal {
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

.reorder-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.reorder-modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-accent);
}

.dark-theme .reorder-modal-header h3 {
    color: var(--text-accent);
}

.reorder-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0;
    line-height: 1;
}

.reorder-modal-close:hover {
    color: var(--text-primary);
}

.reorder-modal-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    min-height: 100px;
    max-height: 50vh;
}

.reorder-modal-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    margin: 0 8px 4px 8px;
    border-radius: 8px;
    background: var(--bg-secondary);
    transition: background 0.15s ease;
}

.reorder-modal-item .drag-handle {
    margin-left: 0;
    margin-right: 12px;
    margin-top: 0;
    font-size: 1.2rem;
    opacity: 0.4;
    cursor: grab;
}

.reorder-modal-item .drag-handle:active {
    cursor: grabbing;
}

/* Hover states only for pointer devices */
@media (hover: hover) and (pointer: fine) {
    .reorder-modal-item:hover {
        background: var(--bg-accent);
    }

    .reorder-modal-item:hover .drag-handle {
        opacity: 0.7;
    }
}

/* Mobile reorder arrows */
.reorder-modal-arrows {
    display: none;
    margin-left: auto;
    gap: 4px;
}

.reorder-modal-arrows button {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-card);
    font-size: 0.8rem;
    cursor: pointer;
    color: var(--text-accent);
}

.dark-theme .reorder-modal-arrows button {
    color: var(--text-accent);
}

.reorder-modal-arrows button:active {
    transform: scale(0.95);
    background: var(--bg-accent);
}

.reorder-modal-arrows button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.reorder-modal-item-name {
    flex: 1;
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reorder-modal-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.reorder-modal-footer button {
    padding: 10px 32px;
}

/* Sortable ghost for reorder modal */
.reorder-modal-item.sortable-ghost {
    opacity: 0.4;
    background: var(--bg-accent);
}

.reorder-modal-item.sortable-chosen {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Save Set Modal */
.save-set-modal {
    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: 2000;
    animation: modalFadeIn 0.2s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.save-set-modal-content {
    background: var(--bg-card);
    border-radius: 14px;
    padding: 24px 28px;
    width: 90%;
    max-width: 360px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.25);
    animation: modalSlideIn 0.25s ease;
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(-20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.dark-theme .save-set-modal-content {
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

.save-set-modal h3 {
    margin: 0 0 18px 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-accent);
}

.dark-theme .save-set-modal h3 {
    color: var(--text-accent);
}

.save-set-modal input {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    margin-bottom: 20px;
    box-sizing: border-box;
    transition: border-color 0.2s ease;
}

.save-set-modal input:focus {
    outline: none;
    border-color: var(--text-accent);
    background: var(--bg-card);
}

.dark-theme .save-set-modal input:focus {
    border-color: var(--text-accent);
}

.save-set-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.save-set-modal-actions button {
    padding: 10px 18px;
    font-weight: 500;
}

/* Mobile responsive for Set Builder */
@media (max-width: 768px) {
    .print-all-container {
        justify-content: flex-start;
        flex-wrap: nowrap;
        gap: 6px;
    }

    /* Hide long text, show short text on mobile */
    .print-all-container .btn-text {
        display: none;
    }

    .print-all-container .btn-text-short {
        display: inline;
    }

    .create-set-btn,
    .my-sets-btn {
        flex: 0;
        min-width: auto;
        padding: 0 6px;
        white-space: nowrap;
        height: 30px;
        font-size: 0.85rem;
    }

    /* Print and ABC buttons as standalone emojis on mobile */
    .print-all-btn,
    .reset-order-btn {
        flex: 0 0 auto;
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        padding: 0 !important;
        background: none !important;
        border: none !important;
        box-shadow: none !important;
        font-size: 1.8rem !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        align-self: center;
    }

    /* Both emoji buttons on the right */
    .print-all-btn {
        margin-left: auto;
        margin-right: 8px;
        position: static;
    }

    .reset-order-btn {
        position: static;
        margin-left: 0;
    }

    /* Mobile set bar: count on top, 5 emojis below equally spaced */
    .set-builder-panel {
        height: auto;
        padding: 8px 16px;
        flex-wrap: wrap;
        gap: 8px;
    }

    /* Count takes full width - forces new row for buttons */
    .set-bar-count {
        flex: 0 0 100% !important;
        font-size: 1.1rem;
        font-weight: 600;
        text-align: center;
        order: 1 !important;
        padding-bottom: 6px;
        border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    }

    .dark-theme .set-bar-count {
        border-bottom-color: rgba(255, 255, 255, 0.15);
    }

    /* Both containers flow inline */
    .set-bar-left {
        display: contents !important;
    }

    .set-bar-actions {
        display: contents !important;
    }

    /* All buttons equally spaced on row 2 */
    .set-builder-panel .btn-icon {
        flex: 1 !important;
        display: flex !important;
        justify-content: center !important;
        font-size: 1.15rem;
        padding: 4px;
        order: 2 !important;
    }

    .tune-select-checkbox {
        width: 26px;
        height: 26px;
        top: 12px;
        left: 10px;
    }

    .selection-mode .fakebook-item-title {
        padding-left: 32px;
    }

    .my-sets-dropdown .dropdown-content {
        position: fixed;
        top: auto;
        left: 16px;
        right: 16px;
        width: auto;
        min-width: unset;
    }

    /* Reorder modal on mobile */
    .reorder-modal {
        width: 95%;
        max-height: 80vh;
    }

    .reorder-modal-item {
        padding: 10px 12px;
    }

    .reorder-modal-item .drag-handle {
        display: none;
    }

    .reorder-modal-arrows {
        display: flex;
    }
}

/* Print overrides - MUST come last to override selection-mode rules */
@media print {
    .tune-select-checkbox,
    .selection-mode .tune-select-checkbox,
    #toast,
    .reorder-modal-overlay,
    .fakebook-tempo-control,
    .set-builder-panel {
        display: none !important;
    }
}
