:root {
    --bg: #f6f7f9;
    --card: #ffffff;
    --border: #e0e3e8;
    --text: #1f2937;
    --muted: #6b7280;
    --accent: #2563eb;
    --accent-soft: #dbeafe;
    --accent-hard: #f02020;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 1rem;
    background: var(--bg);
    font-family:
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        'Segoe UI',
        Roboto,
        Ubuntu,
        sans-serif;
    color: var(--text);
}

h1 {
    margin-bottom: 1.5rem;
    font-size: 1.6rem;
}

fieldset {
    border: 1px solid var(--border);
    background: var(--card);
    border-radius: 8px;
    padding: 0.5rem;
    margin-bottom: 2rem;
}

legend {
    padding: 0.5rem 0.5rem;
    background-color: rgb(168, 235, 238);
    font-weight: 600;
    color: var(--muted);
}

label {
    display: block;
    margin-top: 1rem;
    font-size: 0.9rem;
    color: var(--muted);
}

input,
select {
    width: 100%;
    margin-top: 0.4rem;
    padding: 0.5rem 0.6rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    font-size: 0.95rem;
}

.left {
    width: auto;
    left: 0%;
}
.right {
    width: auto;
    right: 0pnt;
}

/* .ctrl-row {
    display: flex;
    gap: 12px;
} */

.ctrl-row {
    background-color: rgb(168, 235, 238);
    margin-top: 1rem;
    padding: 0.5rem;
    display: flex;
    gap: 1rem;
    overflow: hidden;
    /* max-height: 500px; */
    opacity: 1;
    transition:
        max-height 1s ease,
        opacity 0.5s ease;
}

.ctrl-row.admin {
    background-color: rgb(237, 243, 173);
}

/* .ctrl-row.is-hidden { */
.is-hidden {
    max-height: 0;
    opacity: 0;
    pointer-events: none;
}

.ctrl-row label {
    flex: 1;
}

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

button {
    margin-top: 1rem;
    padding: 0.5rem 0.9rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--accent);
    color: white;
    font-size: 0.9rem;
    cursor: pointer;
}

button:hover {
    background: #7add91;
}

button:disabled {
    background: #b4b7c1;
}

button + button {
    margin-left: 0.5rem;
}

.actions {
    display: flex;
    justify-content: space-between; /* pushes buttons to left & right */
    align-items: center;
    padding: 10px;
}

.status {
    margin-left: 1rem;
    font-size: 0.85rem;
    color: var(--muted);
}

.wait-icon {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-left: 1rem;
    color: var(--muted);
    font-size: 0.85rem;
}

.wait-icon[hidden] {
    display: none !important;
}

.wait-icon-spinner {
    width: 0.9rem;
    height: 0.9rem;
    border: 2px solid #cbd5e1;
    border-top-color: var(--accent-hard);
    border-radius: 50%;
    animation: wait-spin 0.8s linear infinite;
}

@keyframes wait-spin {
    to {
        transform: rotate(360deg);
    }
}

.api-base-switch {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-left: 1rem;
    font-size: 0.8rem;
    color: var(--muted);
}

.api-base-switch select {
    width: auto;
    min-width: 10rem;
    margin-top: 0;
    padding: 0.25rem 0.4rem;
    font-size: 0.8rem;
}

hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1rem 0;
}

/* Upload drop zone */
#dropZone {
    height: 5rem;
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    text-align: center;
    color: var(--muted);
    background: #fafafa;
    transition:
        border-color 0.15s ease,
        background 0.15s ease;
}

#dropZone.dragover {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--text);
}

#uploadJsonText {
    width: 100%;
    margin-top: 0.4rem;
    min-height: 8rem;
    font-family:
        ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New',
        monospace;
}

#edit-container {
    margin-top: 1.5rem;
}

#view-container {
    margin-top: 1.5rem;
}

#doc-editor {
    max-width: 100%;
}

#doc-viewer {
    max-width: 100%;
}

.doc-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.75rem;
}

#doc-editor-status {
    min-width: 10rem;
    font-size: 0.9rem;
    color: var(--muted);
}

#doc-viewer-status {
    min-width: 10rem;
    font-size: 0.9rem;
    color: var(--muted);
}

#doc-editor-textarea {
    width: 100%;
    min-height: 22rem;
    margin-top: 0.4rem;
    font-family:
        ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New',
        monospace;
}

#doc-viewer-textarea {
    width: 100%;
    min-height: 22rem;
    margin-top: 0.4rem;
    font-family:
        ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New',
        monospace;
    background: #f8fafc;
}

#doc-editor-textarea[data-mode='view'] {
    background: #f8fafc;
}

/* Progress */
progress {
    width: 100%;
    height: 0.8rem;
    margin-top: 1rem;
}

#uploadInfo {
    font-size: 0.85rem;
    color: var(--muted);
    margin-top: 0.3rem;
}

pre {
    background: #f3f4f6;
    border-radius: 6px;
    padding: 0.8rem;
    font-size: 0.8rem;
    overflow-x: auto;
}

/* TRANSFER LOG ELEMENTS */

#sse-log {
    margin-top: 1.5rem;
    padding: 1rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fafafa;
    max-width: 600px;
}

.progress-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: #555;
    margin-bottom: 0.5rem;
}

.progress-note {
    font-size: 0.85rem;
    color: var(--muted);
    margin: 0.25rem 0 0.5rem 0;
}

.progress-bar {
    height: 14px;
    background: #e5e7eb;
    border-radius: 7px;
    overflow: hidden;
}

#progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #3b82f6, #2563eb);
    transition: width 0.3s ease;
}

#map-container {
    margin-top: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card);
    padding: 0.5rem;
}

#map {
    height: 720px;
    width: 100%;
    border-radius: 6px;
}
