/* ============================================
   uGIS — Georeferencing Tool Styles
   ============================================ */

.georef-page {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--navbar-height));
}

/* ── Toolbar ── */
.georef-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    flex-wrap: wrap;
}
.georef-toolbar .btn {
    padding: 6px 14px;
    font-size: 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-strong);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.15s;
    white-space: nowrap;
}
.georef-toolbar .btn:hover { background: var(--bg-hover); border-color: var(--accent); color: var(--text-primary); }
.georef-toolbar .btn:disabled { opacity: 0.4; cursor: not-allowed; }
.georef-toolbar .btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.georef-toolbar .btn.primary:hover { background: var(--accent-hover); }
.georef-toolbar .btn.success { background: var(--success); color: #fff; border-color: var(--success); }
.georef-toolbar .btn.active { background: rgba(59,130,246,0.2); border-color: var(--accent); color: var(--accent); }

.georef-toolbar select {
    padding: 5px 8px;
    font-size: 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-strong);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    outline: none;
}
.georef-toolbar select:focus { border-color: var(--accent); }

.georef-toolbar .sep {
    width: 1px;
    height: 22px;
    background: var(--border-strong);
    flex-shrink: 0;
}

.georef-toolbar .rmse-display {
    font-size: 12px;
    color: var(--text-muted);
    margin-left: auto;
}
.georef-toolbar .rmse-display strong {
    color: var(--success-light);
    font-family: var(--font-mono);
}

/* ── Split Panes ── */
.georef-panels {
    display: flex;
    flex: 1;
    min-height: 0;
}

.georef-image-panel,
.georef-map-panel {
    flex: 1;
    position: relative;
    overflow: hidden;
    border-right: 1px solid var(--border-color);
}
.georef-map-panel { border-right: none; }

.georef-panel-label {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 10;
    font-size: 11px;
    color: var(--text-muted);
    background: rgba(12,18,32,0.85);
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    pointer-events: none;
}

/* ── Image Canvas ── */
.georef-canvas-wrap {
    width: 100%;
    height: 100%;
    cursor: grab;
    background: var(--bg-primary);
    position: relative;
}
.georef-canvas-wrap.placing { cursor: crosshair; }
.georef-canvas-wrap:active { cursor: grabbing; }
.georef-canvas-wrap.placing:active { cursor: crosshair; }

#georefCanvas {
    position: absolute;
    top: 0;
    left: 0;
}

/* ── Dropzone ── */
.georef-dropzone {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--text-muted);
    font-size: 14px;
    z-index: 5;
    border: 2px dashed var(--border-strong);
    margin: 24px;
    border-radius: var(--radius-lg);
    transition: all 0.2s;
}
.georef-dropzone.dragover {
    border-color: var(--accent);
    background: rgba(59,130,246,0.06);
    color: var(--accent);
}
.georef-dropzone svg {
    opacity: 0.4;
}
.georef-dropzone input[type="file"] {
    display: none;
}
.georef-dropzone .drop-btn {
    padding: 8px 20px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-strong);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
}
.georef-dropzone .drop-btn:hover { border-color: var(--accent); color: var(--text-primary); }

/* ── Map ── */
#georefMap {
    width: 100%;
    height: 100%;
}
#georefMap .ol-control button {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

/* ── GCP Table ── */
.georef-table-panel {
    flex-shrink: 0;
    max-height: 220px;
    overflow: auto;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.georef-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.georef-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
}
.georef-table th {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    font-weight: 600;
    text-align: left;
    padding: 6px 10px;
    border-bottom: 1px solid var(--border-color);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.georef-table td {
    padding: 5px 10px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 12px;
}
.georef-table tr:hover td { background: var(--bg-hover); }
.georef-table tr.active td { background: rgba(59,130,246,0.12); }
.georef-table tr.incomplete td { opacity: 0.5; }
.georef-table .gcp-num {
    width: 30px;
    text-align: center;
    font-weight: 700;
    color: var(--accent);
}
.georef-table .gcp-residual {
    font-size: 11px;
    color: var(--text-muted);
}
.georef-table .gcp-delete {
    width: 30px;
    text-align: center;
}
.georef-table .gcp-delete button {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 2px;
}
.georef-table .gcp-delete button:hover { color: var(--danger); }

.georef-empty-table {
    padding: 16px;
    text-align: center;
    color: var(--text-dim);
    font-size: 13px;
}

/* ── GCP Markers (canvas) ── */
.gcp-marker-label {
    background: var(--danger);
    color: #fff;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

/* ── Register Modal ── */
.georef-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.georef-modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    padding: 24px;
    width: 380px;
    max-width: 90vw;
}
.georef-modal h3 {
    margin-bottom: 16px;
    font-size: 16px;
    color: var(--text-primary);
}
.georef-modal label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.georef-modal input {
    width: 100%;
    padding: 8px 10px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-strong);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 13px;
    margin-bottom: 14px;
    outline: none;
}
.georef-modal input:focus { border-color: var(--accent); }
.georef-modal .modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}
.georef-modal .modal-actions .btn {
    padding: 7px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-strong);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
}
.georef-modal .modal-actions .btn.primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ── Clip Mode Options ── */
.clip-mode-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 6px 0 12px;
}
.clip-option {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 13px;
    transition: border-color .15s;
}
.clip-option:has(input:checked) {
    border-color: var(--accent);
    background: rgba(59,130,246,0.06);
}
.clip-option input[type="radio"] {
    width: auto;
    margin: 0;
    padding: 0;
}
.clip-option span {
    font-weight: 500;
    color: var(--text-primary);
}
.clip-option small {
    width: 100%;
    margin-left: 22px;
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.3;
}

/* ── Basemap Selector ── */
.georef-basemap-sel {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
}
.georef-basemap-sel select {
    padding: 4px 8px;
    font-size: 11px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: rgba(12,18,32,0.85);
    color: var(--text-secondary);
    outline: none;
}

/* ── Coord Display ── */
.georef-coord-display {
    position: absolute;
    bottom: 6px;
    left: 8px;
    z-index: 10;
    font-size: 11px;
    color: var(--text-dim);
    font-family: var(--font-mono);
    background: rgba(12,18,32,0.8);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
}
