/* ==================== NINA SEQUENCE SET MAKER ==================== */
/* Shared tokens/reset from base.css; panel-wrap, cp-grid, compact-*,
   survey-*, info-row, tile-centers, notification come from
   telescope_simulator_main.css. This file only covers layout and
   controls unique to this page. */

.container-main {
    max-width: 1600px;
    margin: 0 auto 40px;
    padding: 20px;
}

.nsm-danger {
    color: var(--error-color) !important;
}

/* ==================== TOOLBAR + OPEN-FILE STATUS STRIP ==================== */
.nsm-toolbar-group {
    display: inline-flex;
    gap: 8px;
    padding-right: 12px;
    margin-right: 4px;
    border-right: 1px solid var(--border-hairline-strong);
}

.nsm-filebar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 20px;
    padding: 10px 16px;
    background: var(--surface-1);
    border: 1px solid var(--border-hairline);
    border-radius: var(--border-radius);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.nsm-filebar-icon {
    font-size: 0.7rem;
    color: var(--text-faint);
    flex-shrink: 0;
}

.nsm-filebar-icon.is-disk {
    color: var(--success-color);
}

.nsm-filebar-icon.is-upload {
    color: var(--warning-color);
}

.nsm-filebar-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--font-mono);
    font-size: 0.74rem;
}

/* ==================== TWO-COLUMN LAYOUT ==================== */
.nsm-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, 1fr);
    gap: 20px;
    align-items: start;
}

.nsm-sky-col .sky-map-container {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    padding: 16px 18px;
    box-shadow: var(--shadow-primary);
    display: flex;
    flex-direction: column;
}

.sky-map-header h2 {
    font-size: 1.05em;
    color: var(--accent-color);
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* ==================== ROTATION WIDGET (always visible on the map, live preview) ==================== */
.nsm-map-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin-bottom: 8px;
}

.nsm-rotation-widget {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nsm-rotation-widget .cp-label {
    color: var(--secondary-purple);
    white-space: nowrap;
}

.nsm-rotation-widget input[type="range"] {
    width: 140px;
    accent-color: var(--primary-purple);
    cursor: pointer;
}

.nsm-rotation-widget input[type="number"] {
    width: 62px !important;
}

.nsm-rotation-hint {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-style: italic;
    flex-basis: 100%;
}

.sky-map-content {
    flex: 1;
    position: relative;
    min-height: 620px;
    border-radius: var(--border-radius-sm);
    overflow: hidden;
    background: rgba(0, 0, 0, 0.3);
    margin-top: 10px;
}

#aladin-lite-div {
    width: 100%;
    height: 100%;
    min-height: 620px;
    border-radius: var(--border-radius-sm);
}

.nsm-editor-col {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* panel-wrap brings its own margin-top (see telescope_simulator_main.css) for
   when it's used standalone; inside these flex containers the gap already
   spaces siblings, so the extra margin would double it up. */
.nsm-editor-col > .panel-wrap,
.nsm-modal-body > .panel-wrap {
    margin-top: 0;
}

@media (max-width: 1100px) {
    .nsm-layout {
        grid-template-columns: 1fr;
    }
}

/* ==================== EDITOR PANELS (Add / Edit / Batch) ==================== */
/* Add, Edit and Batch all share ONE identical card frame — same surface,
   border, radius and padding — so the page reads as a single system. They are
   told apart only by the header text and a small colour-coded mode badge, not
   by tinting the whole panel. */
.nsm-modal-panel {
    background: var(--surface-1);
    border: 1px solid var(--border-hairline);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-primary);
    padding: 18px 20px;
}

.nsm-edit-panel,
.nsm-batch-panel {
    margin-bottom: 16px;
}

.nsm-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    gap: 12px;
}

.nsm-modal-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Small pill that names the mode, coloured to match that mode's map box:
   green = Add draft, gold = Edit, blue/purple = Batch. */
.nsm-mode-badge {
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 3px 9px;
    border-radius: 999px;
    flex-shrink: 0;
}

.nsm-mode-badge.mode-add {
    color: #46ffaf;
    background: rgba(70, 255, 175, 0.12);
    border: 1px solid rgba(70, 255, 175, 0.4);
}

.nsm-mode-badge.mode-edit {
    color: #f0b84f;
    background: rgba(240, 184, 79, 0.12);
    border: 1px solid rgba(240, 184, 79, 0.4);
}

.nsm-mode-badge.mode-batch {
    color: var(--secondary-purple);
    background: rgba(139, 108, 247, 0.12);
    border: 1px solid rgba(139, 108, 247, 0.4);
}

.nsm-modal-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nsm-modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 6px;
}

.nsm-modal-actions .nsm-add-target-btn {
    flex: 1;
    margin-top: 0;
}

.nsm-position-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px 16px;
}

/* ==================== PLACEMENT (click/drag on map) ==================== */
/* Neutral by default and consistent across every panel; only the active
   ("armed") state lights up, in the app's primary purple, so chrome colour
   never jumps between Add and Edit. */
.nsm-place-btn {
    padding: 6px 12px;
    border: 1px solid var(--border-hairline-strong);
    border-radius: 8px;
    font-size: 12px;
    background: var(--surface-2);
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.nsm-place-btn:hover {
    background: var(--surface-3);
    color: var(--text-primary);
    border-color: var(--border-accent);
}

.nsm-place-btn.active {
    background: var(--primary-gradient);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 0 12px rgba(139, 108, 247, 0.5);
}

/* ==================== BATCH EDIT ==================== */
.nsm-batch-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 14px;
    align-items: start;
}

.nsm-batch-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--border-radius-sm);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nsm-batch-card-wide {
    grid-column: 1 / -1;
}

.nsm-batch-section-title {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--secondary-purple);
}

.nsm-batch-pa-current {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.nsm-batch-warning {
    font-size: 0.68rem;
    line-height: 1.4;
    color: var(--warning-color);
    background: rgba(240, 184, 79, 0.08);
    border: 1px solid rgba(240, 184, 79, 0.25);
    border-radius: 6px;
    padding: 6px 8px;
}

.nsm-batch-tristate-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nsm-batch-tristate-row,
.nsm-batch-af-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.nsm-batch-tristate-row span,
.nsm-batch-af-row span {
    flex: 1;
    min-width: 0;
}

.nsm-batch-tristate-row select {
    flex-shrink: 0;
    width: 100px;
}

.nsm-batch-af-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nsm-batch-af-row select {
    flex-shrink: 0;
    width: 90px;
}

.nsm-batch-af-row input {
    flex-shrink: 0;
    width: 56px;
}

.nsm-batch-tristate-row select,
.nsm-batch-af-row select,
.nsm-batch-af-row input {
    padding: 3px 6px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 6px;
    font-size: 11px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    outline: none;
    box-sizing: border-box;
}

.nsm-list-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nsm-batch-btn {
    padding: 6px 14px;
    font-size: 0.78rem;
}

/* ==================== BEHAVIOR / FLAGS ==================== */
.nsm-flag-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 14px;
}

.nsm-check {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
}

.nsm-check input[type="checkbox"] {
    accent-color: var(--primary-purple);
    width: 14px;
    height: 14px;
    cursor: pointer;
    flex-shrink: 0;
}

.nsm-inline-field {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.nsm-af-triggers {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.nsm-af-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.nsm-af-row .nsm-check {
    flex: 1;
}

.nsm-af-row .cp-ctrl {
    width: 60px !important;
}

@media (max-width: 500px) {
    .nsm-flag-grid {
        grid-template-columns: 1fr;
    }
}

/* ==================== TABLES (filter wheel / capture plan / target list) ==================== */
.nsm-table-wrap {
    overflow-x: auto;
    border-radius: var(--border-radius-sm);
}

.nsm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.74rem;
}

.nsm-table th {
    text-align: left;
    padding: 6px 8px;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    white-space: nowrap;
}

.nsm-table td {
    padding: 4px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    vertical-align: middle;
    white-space: nowrap;
}

.nsm-table tbody tr:hover {
    background: rgba(139, 108, 247, 0.06);
}

.nsm-table input[type="text"],
.nsm-table input[type="number"],
.nsm-table select {
    padding: 3px 6px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 6px;
    font-size: 11px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    outline: none;
    box-sizing: border-box;
}

.nsm-table input[type="number"] {
    width: 56px;
}

.nsm-table input.nsm-w-narrow {
    width: 40px;
}

.nsm-table input[type="text"].nsm-filter-name {
    width: 64px;
}

.nsm-table select {
    max-width: 110px;
}

.nsm-table input:focus,
.nsm-table select:focus {
    border-color: var(--secondary-purple);
    box-shadow: 0 0 8px rgba(162, 155, 254, 0.3);
}

.nsm-bin-pair {
    display: flex;
    align-items: center;
    gap: 3px;
}

.nsm-bin-pair input {
    width: 32px !important;
}

/* Gain/Offset field paired with an "Auto (-1, follow NINA default)" checkbox */
.nsm-gain-cell {
    display: flex;
    align-items: center;
    gap: 5px;
}

.nsm-gain-cell input[type="number"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.nsm-auto-check {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 0.65rem;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}

.nsm-auto-check input[type="checkbox"] {
    accent-color: var(--primary-purple);
    width: 12px;
    height: 12px;
    cursor: pointer;
}

/* This is a single-row form (not a dense multi-row list), so give it room
   to breathe instead of the compact capture-plan-table sizing. */
.nsm-batch-add-table input[type="number"] {
    width: 74px;
}

.nsm-batch-add-table .nsm-bin-pair input {
    width: 46px !important;
}

.nsm-batch-add-table .nsm-gain-cell input[type="number"] {
    width: 58px;
}

.nsm-batch-add-table select {
    max-width: 140px;
}

.nsm-row-remove {
    background: none;
    border: 1px solid rgba(239, 90, 90, 0.4);
    color: var(--error-color);
    border-radius: 6px;
    width: 22px;
    height: 22px;
    line-height: 1;
    cursor: pointer;
    font-size: 13px;
    transition: var(--transition-fast);
}

.nsm-row-remove:hover {
    background: rgba(239, 90, 90, 0.15);
    border-color: var(--error-color);
}

.nsm-add-row-btn {
    margin-top: 8px;
}

.nsm-nested-panel {
    margin-top: 14px;
}

.nsm-nested-panel .panel-header {
    padding: 6px 12px;
}

.nsm-flatdefaults-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px 14px;
}

/* ==================== ADD TARGET BUTTON ==================== */
.nsm-add-target-btn {
    width: 100%;
    margin-top: 4px;
    justify-content: center;
    font-size: 0.9rem;
    padding: 12px 20px;
}

/* ==================== TARGET LIST ==================== */
.nsm-target-list-card {
    margin-top: 20px;
    padding: 22px;
}

.nsm-target-table th:first-child,
.nsm-target-table td:first-child {
    width: 24px;
}

.nsm-target-table input[type="checkbox"] {
    accent-color: var(--primary-purple);
    width: 14px;
    height: 14px;
    cursor: pointer;
}

.nsm-target-table td.nsm-name-cell {
    color: var(--text-primary);
    font-weight: 500;
    white-space: normal;
    max-width: 220px;
    cursor: text;
}

.nsm-target-table td.nsm-name-cell:hover {
    text-decoration: underline dotted;
    text-underline-offset: 3px;
}

.nsm-rename-input {
    width: 100%;
    box-sizing: border-box;
    padding: 3px 6px;
    border: 1px solid var(--secondary-purple);
    border-radius: 6px;
    font-size: 0.74rem;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    outline: none;
}

.nsm-target-row {
    cursor: pointer;
}

.nsm-actions-cell {
    display: flex;
    gap: 4px;
    align-items: center;
}

.nsm-icon-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-secondary);
    border-radius: 6px;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    transition: var(--transition-fast);
    flex-shrink: 0;
}

.nsm-icon-btn:hover {
    background: rgba(139, 108, 247, 0.2);
    border-color: var(--secondary-purple);
    color: var(--text-primary);
}

.nsm-icon-btn.nsm-danger:hover {
    background: rgba(239, 90, 90, 0.15);
    border-color: var(--error-color);
    color: var(--error-color);
}

.nsm-empty-state {
    padding: 30px 10px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.nsm-target-row.nsm-highlighted {
    background: rgba(139, 108, 247, 0.14);
}

/* ==================== FLOATING SAVE BUTTON ==================== */
.nsm-floating-save-btn {
    position: fixed;
    right: 28px;
    bottom: 28px;
    z-index: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 22px;
    border: none;
    border-radius: 999px;
    background: var(--primary-gradient);
    color: #fff;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.2px;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(139, 108, 247, 0.45);
    transition: var(--transition);
}

.nsm-floating-save-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 36px rgba(139, 108, 247, 0.55);
}

.nsm-floating-save-btn:active {
    transform: translateY(0);
}

/* ==================== SERVER FILE BROWSER ==================== */
.nsm-fs-overlay {
    position: fixed;
    inset: 0;
    z-index: 900;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.nsm-fs-modal {
    width: 100%;
    max-width: 560px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    background: var(--surface-1);
    border: 1px solid var(--border-hairline-strong);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-hover);
    padding: 18px 20px;
}

.nsm-fs-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.nsm-fs-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.nsm-fs-pathbar {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.nsm-fs-pathbar .compact-input {
    flex: 1;
    padding: 7px 10px;
    border: 1px solid var(--border-hairline-strong);
    border-radius: var(--border-radius-sm);
    background: var(--surface-sunken);
    color: var(--text-primary);
    font-size: 0.78rem;
    font-family: var(--font-mono);
    outline: none;
}

.nsm-fs-list {
    flex: 1;
    overflow-y: auto;
    min-height: 200px;
    border: 1px solid var(--border-hairline);
    border-radius: var(--border-radius-sm);
    background: var(--surface-sunken);
    padding: 4px;
}

.nsm-fs-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: var(--border-radius-xs);
    cursor: pointer;
    font-size: 0.82rem;
    color: var(--text-secondary);
    transition: var(--transition-fast);
}

.nsm-fs-item:hover {
    background: rgba(139, 108, 247, 0.14);
    color: var(--text-primary);
}

.nsm-fs-item.nsm-fs-file {
    color: var(--text-primary);
}

.nsm-fs-icon {
    flex-shrink: 0;
    width: 18px;
    text-align: center;
}

.nsm-fs-empty {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.nsm-fs-saverow {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.nsm-fs-saverow .compact-input {
    flex: 1;
    padding: 9px 12px;
    border: 1px solid var(--border-hairline-strong);
    border-radius: var(--border-radius-sm);
    background: var(--surface-sunken);
    color: var(--text-primary);
    font-size: 0.82rem;
    outline: none;
}

.nsm-fs-save-btn {
    padding: 9px 20px;
    flex-shrink: 0;
}
