/* Setlist Designer — Band Setlist Builder */
* {
    box-sizing: border-box;
}

html {
    margin: 0;
    padding: 0;
    background: #2d2d2d;
    min-height: 100vh;
}

body {
    margin: 0;
    padding: 0;
    background: #2d2d2d;
    color: #e8e8e8;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --ink: #e8e8e8;
    --muted: #aaaaaa;
    --line: #555555;
    --accent: #d32f2f;
    --bg: #2d2d2d;
    --card: #3a3a3a;
    --card-hover: #444444;
}

body > * {
    max-width: 720px;
    margin: 0 auto;
    padding: 1rem;
    box-sizing: border-box;
    width: 100%;
}

@media (max-width: 600px) {
    body > * { padding: 0.5rem; }
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.top-bar h1 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

/* ---------- Gig header ---------- */
.gig-header {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.gig-header h2 {
    margin: 0 0 0.75rem;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    font-weight: 700;
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

@media (max-width: 600px) {
    .field-row { grid-template-columns: 1fr; }
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.field label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
}

.field input,
.field select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--card);
    color: var(--ink);
}

.field input:focus,
.field select:focus {
    outline: none;
    border-color: var(--accent);
}

.save-area {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.save-area input[type="password"] {
    width: auto;
    min-width: 140px;
    flex: 1;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1rem;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.05s, opacity 0.15s;
    -webkit-appearance: none;
    appearance: none;
    touch-action: manipulation;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--line);
    color: var(--ink);
}

.btn-success {
    background: #1a7a1a;
    color: #fff;
}

/* ---------- Add song ---------- */
.add-section {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.add-section h2 {
    margin: 0 0 0.75rem;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    font-weight: 700;
}

.dropdown-wrap {
    position: relative;
    margin-bottom: 0.5rem;
}

.dropdown-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

#btn-toggle-songs {
    width: 100%;
    padding: 0.6rem 1rem;
    font-size: 1rem;
}

.dropdown-list {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    right: 0;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 50;
    display: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    padding: 0.25rem 0;
}

.dropdown-list.open { display: block; }

.dropdown-option {
    padding: 0.55rem 0.75rem;
    font-size: 0.95rem;
    cursor: pointer;
    color: var(--ink);
}

.dropdown-option:hover,
.dropdown-option.focused {
    background: var(--card-hover);
}

.dropdown-option.selected {
    background: #3d5a80;
    color: #ffffff;
    font-weight: 600;
}

.add-hint {
    font-size: 0.85rem;
    color: var(--muted);
    margin: 0.4rem 0 0;
}

/* ---------- Setlist ---------- */
.setlist-section {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.setlist-section h2 {
    margin: 0 0 0.75rem;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    font-weight: 700;
}

.tally {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 0.75rem;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0;
}

.empty {
    color: var(--muted);
    font-style: italic;
    padding: 1rem 0;
    text-align: center;
}

#setlist {
    list-style: none;
    padding: 0;
    margin: 0;
}

.setlist-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 0.5rem;
    background: var(--card);
    color: var(--ink);
    cursor: grab;
}

.setlist-item:active {
    cursor: grabbing;
}

.setlist-item.dragging {
    opacity: 0.5;
    border-color: var(--accent);
    background: var(--card-hover);
}

.drag-handle {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    cursor: grab;
    flex-shrink: 0;
}

.setlist-item.dragging .drag-handle {
    color: var(--accent);
}

.song-info {
    flex: 1;
    min-width: 0;
}

.song-name {
    font-weight: 700;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.song-duration {
    font-size: 0.85rem;
    color: var(--muted);
}

.tuning-label {
    margin-left: 1rem;
    color: var(--muted);
    font-weight: 400;
}

.delete-btn {
    background: transparent;
    border: none;
    color: #999;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 0.25rem;
    flex-shrink: 0;
}

.delete-btn:hover { color: var(--accent); }

/* ---------- Export ---------- */
.export-section {
    margin-top: 1.5rem;
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* ---------- PDF template (hidden, used for export) ---------- */
#pdf-template {
    position: absolute;
    left: -9999px;
    top: 0;
    width: 210mm;
    min-height: 297mm;
    visibility: visible;
}

.pdf-page {
    width: 210mm;
    min-height: 297mm;
    background: #fff;
    position: relative;
    overflow: hidden;
    padding: 12mm 20mm 12mm;
    box-sizing: border-box;
    font-family: 'Lato', Arial, sans-serif;
    text-align: center;
    display: flex;
    flex-direction: column;
}

.pdf-logo {
    width: 50mm;
    height: auto;
    display: block;
    margin: 0 auto 8mm;
}

.pdf-header {
    margin-bottom: 10mm;
}

.pdf-venue-date {
    font-size: 13pt;
    font-weight: 700;
    margin: 0 0 3mm;
    letter-spacing: 0.02em;
}

.pdf-other-bands {
    font-size: 10pt;
    font-weight: 400;
    color: var(--ink);
    margin: 0 0 10mm;
    line-height: 1.5;
}

.pdf-song-list {
    margin: 0;
    padding: 0;
    list-style: none;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 6mm;
}

.pdf-song-list li {
    font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif;
    font-size: 30pt;
    font-weight: 700;
    text-align: center;
    line-height: 1.4;
    text-transform: uppercase;
}

/* ---------- Saved gigs ---------- */
.saved-gigs-section {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
}

.saved-gigs-section h2 {
    margin: 0 0 0.75rem;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    font-weight: 700;
}

#saved-gigs-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

#saved-gigs-list li {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 0.4rem;
    background: var(--card);
    color: var(--ink);
    cursor: pointer;
    transition: background 0.15s;
}

#saved-gigs-list li:hover {
    background: var(--card-hover);
}



.venue-label {
    font-size: 0.85rem;
    color: var(--muted);
    font-weight: 400;
}

/* ---------- Toast ---------- */
.toast {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background: #1a1a1a;
    color: #fff;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    opacity: 0;
    transition: opacity 0.25s;
    pointer-events: none;
    z-index: 100;
    border: 1px solid var(--line);
}

.toast.show { opacity: 1; }

/* ---------- Print ---------- */
@media print {
    /* Hide everything except the print template */
    body > *:not(#pdf-template) {
        display: none !important;
    }

    #pdf-template {
        position: static !important;
        left: 0 !important;
        top: 0 !important;
        visibility: visible !important;
        display: block !important;
        width: 210mm;
        min-height: 297mm;
    }

    .pdf-page {
        box-shadow: none;
        margin: 0;
        width: 210mm;
        min-height: 297mm;
    }

    /* Ensure white background for print */
    html, body {
        background: white !important;
        margin: 0;
        padding: 0;
    }

    /* Remove any max-width constraints */
    body > * {
        max-width: none !important;
        padding: 0 !important;
    }
}

/* Fallback: when .printing class is added to body */
body.printing > *:not(#pdf-template) {
    display: none !important;
}

body.printing #pdf-template {
    position: static !important;
    left: 0 !important;
    top: 0 !important;
    visibility: visible !important;
    display: block !important;
    width: 210mm;
    min-height: 297mm;
}

body.printing {
    background: white !important;
    margin: 0;
    padding: 0;
}
