/* FTH Packet Editor Styles — Phase 3: Full Section Management */

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: Arial, 'Helvetica Neue', sans-serif;
    background: #e8e8e8;
    color: #333;
}

/* ── Toolbar ────────────────────────────────────────────── */
.toolbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.6rem 1.5rem;
    background: #2d2d2d;
    color: #eee;
    font-size: 0.85rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.toolbar .back {
    color: #aaa;
    text-decoration: none;
    font-size: 0.85rem;
    white-space: nowrap;
}
.toolbar .back:hover { color: #fff; }

.toolbar-center {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.toolbar .status {
    color: #aaa;
    font-size: 0.8rem;
}

.category-select {
    background: #444;
    color: #ddd;
    border: 1px solid #555;
    border-radius: 4px;
    padding: 0.3rem 0.5rem;
    font-size: 0.8rem;
    cursor: pointer;
}
.category-select:hover { border-color: #888; }

.toolbar .actions { display: flex; gap: 0.5rem; }

.toolbar button, .toolbar .btn {
    padding: 0.4rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
}

#btn-build { background: var(--accent, #C4196F); color: white; }
#btn-build:hover { opacity: 0.9; }
#btn-build:disabled { opacity: 0.5; cursor: wait; }

#btn-download { background: #4a9; color: white; }
#btn-download:hover { opacity: 0.9; }

.btn-secondary { background: #607D8B; color: white; }
.btn-secondary:hover { opacity: 0.9; }

.hidden { display: none !important; }

/* ── Packet (paper) ─────────────────────────────────────── */
.packet {
    max-width: 8.5in;
    min-height: 11in;
    margin: 1.5rem auto;
    padding: 0.75in 0.75in;
    background: white;
    box-shadow: 0 2px 16px rgba(0,0,0,0.12);
    line-height: 1.5;
}

/* ── Event Header ───────────────────────────────────────── */
.event-header { text-align: center; margin-bottom: 1rem; }

.event-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 0.25rem;
}

.event-subtitle {
    font-size: 0.95rem;
    color: var(--accent);
    font-style: italic;
    margin-bottom: 0.15rem;
}

.event-date {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 0.2rem;
}

.event-times { font-size: 0.9rem; color: var(--dark); }
.event-times .separator { margin: 0 0.5rem; color: #ccc; }

.divider {
    border: none;
    border-bottom: 3px solid var(--dark);
    margin: 0.8rem auto;
    width: 100%;
}

/* ── Section Wrapper (draggable container) ──────────────── */
.page-break-indicator {
    text-align: center;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    color: #999;
    margin: 1.2rem 0 0.2rem;
    border-top: 2px dashed #ccc;
    padding-top: 0.3rem;
}
.section-wrapper {
    position: relative;
    transition: opacity 0.2s;
}
.section-wrapper.dragging { opacity: 0.4; }
.section-wrapper.drop-above { border-top: 3px solid var(--accent); }
.section-wrapper.drop-below { border-bottom: 3px solid var(--accent); }

/* ── Section Controls (drag handle + remove) ────────────── */
.section-controls {
    position: absolute;
    left: -32px;
    top: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.15s;
}
.section-wrapper:hover .section-controls { opacity: 1; }

.drag-handle {
    cursor: grab;
    font-size: 0.85rem;
    color: #bbb;
    letter-spacing: 2px;
    user-select: none;
    padding: 2px 4px;
}
.drag-handle:hover { color: var(--accent); }
.drag-handle:active { cursor: grabbing; }

.section-remove {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.8rem;
    color: #ccc;
    padding: 0 4px;
}
.section-remove:hover { color: #cc0000; }

/* ── Sections ───────────────────────────────────────────── */
.section { margin-top: 0.4rem; margin-bottom: 0.6rem; }

.section-heading {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.02em;
    margin-bottom: 0.4rem;
    padding-bottom: 0.25rem;
    border-bottom: 2px solid var(--accent);
}

.empty-section {
    color: #aaa;
    font-style: italic;
    font-size: 0.85rem;
    padding: 0.5rem 0;
}

/* ── Add Section Bar ────────────────────────────────────── */
.add-section-bar {
    position: relative;
    height: 24px;
    margin: 4px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}
.add-section-bar:hover,
.add-section-bar:focus-within { opacity: 1; }

.add-section-line {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    border-top: 1px dashed #ddd;
}

.add-section-btn {
    position: relative;
    z-index: 1;
    width: 24px;
    height: 24px;
    border: 1px dashed #ccc;
    border-radius: 50%;
    background: white;
    color: #aaa;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.add-section-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--lightbg, #fdf0f7);
}

/* ── Section Picker (dropdown) ──────────────────────────── */
.section-picker {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    padding: 0.4rem;
    min-width: 200px;
    max-height: 320px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.picker-group {
    padding: 0.2rem 0;
}
.picker-group + .picker-group {
    border-top: 1px solid #eee;
    margin-top: 0.2rem;
    padding-top: 0.3rem;
}

.picker-group-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.2rem 0.8rem 0.1rem;
}

.picker-option {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.35rem 0.8rem 0.35rem 1.2rem;
    border: none;
    background: none;
    font-size: 0.85rem;
    color: #444;
    cursor: pointer;
    border-radius: 4px;
}
.picker-option:hover {
    background: var(--lightbg, #fdf0f7);
    color: var(--dark);
}

/* ── Client / Field Grid ────────────────────────────────── */
.field-grid { display: grid; grid-template-columns: 1fr; gap: 0.3rem; }
.field { font-size: 0.9rem; }

/* ── Locations ──────────────────────────────────────────── */
.location-row {
    font-size: 0.9rem;
    margin-bottom: 0.2rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

/* ── Data Tables (artists, teaching artists, open items, program) ── */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.3rem;
    font-size: 0.88rem;
}
.data-table thead th {
    background: var(--lightbg, #FDF0F7);
    color: var(--dark);
    padding: 0.5rem 0.6rem;
    text-align: left;
    font-weight: 700;
    font-size: 0.85rem;
    border-bottom: 2px solid var(--accent);
    border-top: none;
    border-left: none;
    border-right: none;
}
.data-table td {
    padding: 0.35rem 0.6rem;
    border: none;
    border-bottom: 1px solid #e8e8e8;
    vertical-align: top;
}
.data-table tbody tr:nth-child(odd) td { background: white; }
.data-table tbody tr:nth-child(even) td { background: var(--lightbg, #FDF0F7); }

/* ── Staff Tables ───────────────────────────────────────── */
.staff-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.3rem;
    font-size: 0.88rem;
}

.staff-table .crew-header {
    background: var(--lightbg, #FDF0F7);
    color: var(--dark);
    padding: 0.5rem 0.6rem;
    text-align: center;
    font-weight: 700;
    font-size: 0.85rem;
    border-bottom: 2px solid var(--accent);
}

.staff-table thead th { border: none; }

.staff-table td {
    padding: 0.35rem 0.6rem;
    border: none;
    border-bottom: 1px solid #e8e8e8;
    vertical-align: top;
}

.staff-table tbody tr:nth-child(odd) td { background: white; }
.staff-table tbody tr:nth-child(even) td { background: var(--lightbg, #FDF0F7); }

.staff-table .role {
    font-weight: 700;
    color: var(--dark);
    white-space: nowrap;
}

.staff-table .name { position: relative; }
.staff-table .name.lead .editable { font-weight: 700; }

.staff-table .notes {
    font-size: 0.8rem;
    color: #888;
    font-style: italic;
    margin-left: 0.3rem;
}

.staff-table.two-col .crew-header { border-bottom: 2px solid var(--accent); }
.staff-table.two-col thead th:nth-child(3) { border-right: 3px solid white; }

/* ── Row Arrows (▲/▼) ──────────────────────────────────── */
.row-arrows {
    display: inline-flex;
    flex-direction: column;
    gap: 0px;
    margin-right: 0.3rem;
    opacity: 0;
    transition: opacity 0.15s;
}
.location-row:hover .row-arrows,
tr:hover .row-arrows-cell .arrow-btn { opacity: 1; }

.row-arrows-cell {
    width: 24px;
    padding: 0.2rem !important;
    vertical-align: middle;
}
.row-arrows-cell .arrow-btn { opacity: 0; transition: opacity 0.15s; }
tr:hover .row-arrows-cell .arrow-btn { opacity: 1; }

.arrow-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.6rem;
    color: #aaa;
    padding: 0 2px;
    line-height: 1;
    display: block;
}
.arrow-btn:hover:not(:disabled) { color: var(--accent); }
.arrow-btn:disabled { color: #e0e0e0; cursor: default; }

/* ── Lead toggle (★) ───────────────────────────────────── */
.lead-toggle {
    display: inline-block;
    cursor: pointer;
    font-size: 0.75rem;
    color: #aaa;
    margin-left: 0.3rem;
    transition: color 0.15s, transform 0.15s;
    user-select: none;
    opacity: 0.5;
}
tr:hover .lead-toggle { opacity: 1; }
.lead-toggle:hover { color: var(--accent); transform: scale(1.2); }
.lead-toggle.active { color: var(--accent); opacity: 1; }

/* ── Schedule ───────────────────────────────────────────── */
.schedule-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.3rem;
    font-size: 0.9rem;
}

.schedule-table td {
    padding: 0.4rem 0.6rem;
    border: none;
    border-bottom: 1px solid #e8e8e8;
    position: relative;
}

.schedule-table .time {
    width: 80px;
    font-weight: 700;
    white-space: nowrap;
}

.schedule-table .desc { position: relative; }

.schedule-table tr.show-moment td {
    background: var(--lightbg, #FDF0F7);
    font-weight: 700;
    color: var(--dark);
}
.schedule-table tr.show-moment td:first-child { border-left: 4px solid var(--accent); }
.schedule-table tr.show-moment td { border-top: 1px solid #ddd; }

/* ── Show moment toggle (◆) ────────────────────────────── */
.show-toggle {
    display: inline-block;
    cursor: pointer;
    font-size: 0.7rem;
    color: #ccc;
    margin-left: 0.4rem;
    transition: color 0.15s, transform 0.15s;
    user-select: none;
}
.show-toggle:hover { color: var(--accent); transform: scale(1.3); }
.show-toggle.active { color: var(--accent); }

/* ── Row remove button (×) ─────────────────────────────── */
.row-actions {
    width: 28px;
    padding: 0.2rem 0 !important;
    text-align: center;
    vertical-align: middle;
    background: transparent !important;
    border: none !important;
}
.row-remove {
    display: inline-block;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    color: #ccc;
    padding: 0 0.2rem;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
    vertical-align: middle;
}
tr:hover .row-remove,
.location-row:hover .row-remove { opacity: 1; }
.row-remove:hover { color: #cc0000; }

/* ── Add row button (+) ────────────────────────────────── */
.add-row-cell {
    padding: 0.4rem 0.6rem !important;
    border: none !important;
    background: transparent !important;
}

.btn-add {
    background: none;
    border: 1px dashed #ccc;
    border-radius: 4px;
    padding: 0.3rem 0.8rem;
    font-size: 0.8rem;
    color: #999;
    cursor: pointer;
    transition: all 0.15s;
    margin-top: 0.3rem;
}
.btn-add:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--lightbg, #fdf0f7);
}

/* ── Subsections ────────────────────────────────────────── */
.subsection {
    position: relative;
    margin: 0.6rem 0 0.6rem 1.2rem;
    padding-left: 0.8rem;
    border-left: 2px solid var(--lightbg, #eee);
}

.subsection-heading {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 0.2rem;
}

.subsection-controls {
    position: absolute;
    right: 0;
    top: 0;
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.15s;
}
.subsection:hover .subsection-controls { opacity: 1; }

/* ── Hidden Tray ────────────────────────────────────────── */
.hidden-tray {
    max-width: 8.5in;
    margin: 0 auto 2rem auto;
    background: #f8f8f8;
    border: 1px dashed #ccc;
    border-radius: 8px;
    overflow: hidden;
}

.hidden-tray-header {
    padding: 0.5rem 1rem;
    cursor: pointer;
    color: #888;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}
.hidden-tray-header:hover { color: #555; }

.tray-toggle { transition: transform 0.2s; }
.hidden-tray.expanded .tray-toggle { transform: rotate(180deg); }

.hidden-tray-body {
    display: none;
    padding: 0 1rem 0.5rem;
}
.hidden-tray.expanded .hidden-tray-body { display: block; }

.hidden-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0;
    border-bottom: 1px solid #eee;
}
.hidden-item:last-child { border-bottom: none; }

.hidden-label {
    font-size: 0.85rem;
    color: #666;
}

.btn-restore {
    background: none;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 0.2rem 0.6rem;
    font-size: 0.75rem;
    color: #666;
    cursor: pointer;
}
.btn-restore:hover {
    border-color: var(--accent, #C4196F);
    color: var(--accent, #C4196F);
}

/* ── FOH ────────────────────────────────────────────────── */
.foh-list {
    list-style: disc;
    margin-left: 1.5rem;
    font-size: 0.9rem;
}
.foh-list li { margin-bottom: 0.2rem; }

/* ── Custom sections ────────────────────────────────────── */
.custom-content {
    font-size: 0.9rem;
    white-space: pre-wrap;
    line-height: 1.6;
    min-height: 1.6em;
}
.custom-content:empty::before {
    content: "Click to add content…";
    color: #bbb;
    font-style: italic;
}

/* ── Editable fields ────────────────────────────────────── */
.editable {
    cursor: text;
    border-radius: 2px;
    transition: background 0.15s;
    padding: 0 2px;
}
.editable:hover {
    background: rgba(0, 0, 0, 0.04);
    outline: 1px dashed var(--accent);
    outline-offset: 1px;
}
.editable:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

/* ── Inline edit inputs ─────────────────────────────────── */
.edit-input {
    font: inherit;
    color: inherit;
    background: #fffde0;
    border: 2px solid var(--accent);
    border-radius: 3px;
    padding: 0.15rem 0.3rem;
    width: 100%;
    outline: none;
}
.edit-input.multiline {
    width: 100%;
    min-height: 80px;
    resize: vertical;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* ── Column Gear Button ────────────────────────────────── */
.col-gear {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.75rem;
    color: #ccc;
    margin-left: 0.4rem;
    padding: 0;
    vertical-align: middle;
    opacity: 0.5;
    transition: opacity 0.15s, color 0.15s;
}
.section-heading:hover .col-gear { opacity: 1; }
.col-gear:hover { color: var(--accent); }

.layout-toggle {
    background: none;
    border: 1px solid #ccc;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.65rem;
    color: #999;
    margin-left: 0.3rem;
    padding: 0.15rem 0.4rem;
    vertical-align: middle;
    opacity: 0.5;
    transition: opacity 0.15s, color 0.15s;
}
.section-heading:hover .layout-toggle { opacity: 1; }
.layout-toggle:hover { color: var(--accent); border-color: var(--accent); }

/* ── Column Picker Modal ──────────────────────────────── */
.column-picker-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.3);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}
.column-picker-overlay.hidden { display: none; }

.column-picker-modal {
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    min-width: 320px;
    max-width: 420px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.column-picker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1.2rem;
    border-bottom: 1px solid #eee;
}
.column-picker-header h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: #333;
    margin: 0;
}
.column-picker-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #999;
    cursor: pointer;
    padding: 0 4px;
}
.column-picker-close:hover { color: #333; }

.column-picker-body {
    padding: 0.6rem 1.2rem;
    overflow-y: auto;
    flex: 1;
}

.col-picker-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid #f0f0f0;
}
.col-picker-row:last-child { border-bottom: none; }

.col-picker-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent, #C4196F);
    cursor: pointer;
}

.col-picker-row label {
    flex: 1;
    font-size: 0.88rem;
    color: #444;
    cursor: pointer;
}
.col-picker-row label.custom-col-label {
    font-style: italic;
}

.col-remove-btn {
    background: none;
    border: none;
    color: #ccc;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0 4px;
}
.col-remove-btn:hover { color: #cc0000; }

.col-arrows {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-left: auto;
}

.column-picker-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 1.2rem;
    border-top: 1px solid #eee;
}

.btn-add-col {
    background: none;
    border: 1px dashed #ccc;
    border-radius: 4px;
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
    color: #999;
    cursor: pointer;
}
.btn-add-col:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-save-cols {
    background: var(--accent, #C4196F);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0.4rem 1.2rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}
.btn-save-cols:hover { opacity: 0.9; }

/* ── Print styles ───────────────────────────────────────── */
@media print {
    .toolbar { display: none; }
    body { background: white; }
    .packet { box-shadow: none; margin: 0; padding: 0.75in; }
    .lead-toggle, .show-toggle, .row-remove, .btn-add,
    .add-section-bar, .section-controls, .hidden-tray,
    .arrow-btn, .row-arrows, .row-arrows-cell,
    .subsection-controls, .col-gear, .column-picker-overlay, .email-overlay { display: none; }
}

/* ── Email Draft Modal ─────────────────────────────────── */
.email-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
}
.email-modal {
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25);
    width: 560px;
    max-width: 90vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.email-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1.2rem;
    border-bottom: 1px solid #eee;
    font-weight: 600;
}
.email-modal-header button {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: #999;
}
.email-modal-header button:hover { color: #333; }
.email-body {
    padding: 1.2rem;
    font-family: -apple-system, system-ui, sans-serif;
    font-size: 0.9rem;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-y: auto;
    flex: 1;
    margin: 0;
}
.email-modal > .btn {
    margin: 0.8rem 1.2rem;
    align-self: flex-start;
}
