/* maptool layout overrides */
body.maptool-body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    height: 100vh;
    font-family: var(--font-sans);
}

.maptool-layout {
    display: flex;
    height: 100vh;
    width: 100vw;
}

.map-container {
    flex-grow: 1;
    height: 100%;
    z-index: 1;
}

.sidebar {
    width: 380px;
    height: 100vh; /* Force fixed height */
    overflow: hidden; /* Prevent sidebar growth */
    flex-shrink: 0;
    background: var(--color-surface);
    border-left: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    z-index: 10;
    box-shadow: -4px 0 24px rgba(45,42,38,0.05);
}

.sidebar-header {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg);
}

.sidebar-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dark-toggle {
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-pill);
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--color-text-muted);
    transition: background var(--transition-fast), color var(--transition-fast);
    font-size: 0.9rem;
    flex-shrink: 0;
}

.dark-toggle:hover {
    background: rgba(45,42,38,0.06);
    color: var(--color-text);
}

[data-theme="dark"] .dark-toggle:hover {
    background: rgba(255,255,255,0.06);
}

.sidebar-title {
    font-size: var(--text-lg);
    font-weight: 600;
    margin-top: var(--space-3);
    margin-bottom: 0;
    font-family: var(--font-pixel);
    letter-spacing: 0.02em;
}

.sidebar-tools {
    flex: 1; /* Shorthand for flex-grow: 1, flex-shrink: 1, flex-basis: 0% */
    overflow-y: auto;
    min-height: 0;
    padding: var(--space-5);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    scrollbar-gutter: stable;
}

.tool-section {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    flex-shrink: 0; /* Prevents squishing, allowing overflow content to scroll */
}

.section-title {
    font-size: var(--text-sm);
    font-weight: 600;
    font-family: var(--font-sans);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 4px 0;
}

/* Dropzone */
.dropzone {
    border: 2px dashed var(--color-border-soft);
    border-radius: var(--radius-md);
    padding: var(--space-6) var(--space-4);
    text-align: center;
    background: var(--color-bg);
    transition: all var(--transition-fast);
    position: relative;
}

.dropzone.dragover {
    border-color: var(--color-accent);
    background: var(--color-accent-light);
}

.dropzone p {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    margin-bottom: var(--space-4);
}

.dropzone code {
    background: var(--color-surface-alt);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.85em;
}

.dropzone .drop-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: var(--space-2);
}

.file-label {
    display: inline-block;
    cursor: pointer;
}

/* Inputs & Forms */
.input-field {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    background: var(--color-surface-alt);
    color: var(--color-text);
    transition: border-color var(--transition-fast);
}

.input-field:focus {
    outline: none;
    border-color: var(--color-accent);
}

.inat-input-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.chunking-group {
    display: flex;
    gap: var(--space-2);
    align-items: center;
}

.chunk-input {
    width: 80px;
}

.separator-or {
    text-align: center;
    font-family: var(--font-pixel);
    font-size: 0.7rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    margin: var(--space-4) 0;
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.separator-or::before,
.separator-or::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--color-border-soft);
}

/* Base Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-sans);
    font-weight: 600;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
}

.btn-sm {
    font-size: var(--text-xs);
    padding: var(--space-2) var(--space-4);
}

.btn-primary {
    background: linear-gradient(180deg, var(--color-text) 0%, #1a1814 100%);
    color: var(--color-surface);
    border-color: #1a1814;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-ghost {
    background: var(--color-surface-alt);
    color: var(--color-text);
    border-color: var(--color-border);
}

.btn-ghost:hover {
    background: var(--color-bg);
    border-color: var(--color-border-soft);
}

.btn-error {
    background: var(--color-error-light);
    color: var(--color-error);
    border-color: rgba(184,92,74,0.2);
}

.btn-error:hover {
    background: var(--color-error);
    color: #fff;
}

.action-divider {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: var(--space-1) 0;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.action-buttons > button {
    width: 100%;
}

/* Sidebar Footer Stats */
.sidebar-footer {
    padding: var(--space-4) var(--space-5);
    background: var(--color-bg);
    border-top: 1px solid var(--color-border);
}

.stats-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: var(--font-pixel);
    font-size: 0.6rem;
    color: var(--color-text);
    background: var(--color-surface);
    padding: 2px 6px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--color-border);
}

.stat-badge .badge-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--color-accent);
}

.stat-badge.error .badge-dot {
    background: var(--color-error);
}

/* Location details panel */
.loc-data-panel {
    background: var(--color-bg);
    padding: var(--space-3);
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    font-family: var(--font-mono);
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.sv-preview-container {
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: var(--space-3);
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
}

.sv-preview {
    width: 100%;
    height: 100%;
    display: block;
}

.loc-actions {
    display: flex;
    gap: var(--space-2);
    margin-top: var(--space-2);
}
.loc-actions button {
    flex: 1;
}

/* Map overlay controls */
.map-overlay-controls {
    position: absolute;
    bottom: 24px;
    left: 16px;
    z-index: 999;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
}

.map-control-btn {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 5px rgba(0,0,0,0.15);
    transition: background var(--transition-fast);
    color: var(--color-text-muted);
}

.map-control-btn:hover {
    background: var(--color-surface-alt);
    color: var(--color-text);
}

.settings-menu {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: var(--space-3) var(--space-4);
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    min-width: 190px;
}

.settings-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    margin-bottom: var(--space-3);
}

.settings-group:last-child {
    margin-bottom: 0;
}

.settings-label {
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
}

.filter-row {
    display: flex;
    gap: var(--space-2);
    align-items: flex-end;
}

.filter-row .input-field {
    flex: 1;
    min-width: 0;
}

.filter-row-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    min-width: 0;
}

.filter-num {
    width: 72px;
    flex: none !important;
}

.month-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-1) var(--space-2);
}

.gen-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-1) var(--space-2);
}

.filter-check {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    cursor: pointer;
    user-select: none;
}

.filter-check input[type="checkbox"] {
    accent-color: var(--color-accent);
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    cursor: pointer;
}

.settings-hint {
    font-weight: 400;
    font-size: 0.65rem;
    text-transform: none;
    letter-spacing: 0;
    color: var(--color-text-muted);
    opacity: 0.7;
}

.generate-subsection-label {
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
    margin: 0 0 var(--space-2) 0;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    accent-color: var(--color-accent);
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    cursor: pointer;
}

.activity-log {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--color-text-muted);
    max-height: 100px;
    overflow-y: auto;
    margin-top: var(--space-2);
}

/* Logo */
.logo {
  font-family: var(--font-pixel);
  font-size: 0.9rem;
  color: var(--color-text);
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
}
.logo-dot {
  width: 7px;
  height: 7px;
  background: var(--color-accent);
  border-radius: 50%;
  display: inline-block;
}

/* Accordions */
details.tool-section {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    overflow: hidden;
}

summary.accordion-header {
    margin: 0;
    padding: var(--space-2) var(--space-3);
    background: var(--color-bg);
    cursor: pointer;
    list-style: none; /* Hide default triangle */
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    transition: background var(--transition-fast);
}

summary.accordion-header::-webkit-details-marker {
    display: none;
}

summary.accordion-header:hover {
    background: var(--color-surface-alt);
}

summary.accordion-header::after {
    content: '+';
    font-family: var(--font-mono);
    font-size: 1.2em;
    font-weight: 400;
    color: var(--color-text-muted);
}

details[open] summary.accordion-header::after {
    content: '−';
}

details[open] summary.accordion-header {
    border-bottom: 1px solid var(--color-border);
}

.accordion-content {
    padding: var(--space-4);
    background: var(--color-surface);
}

/* Formatted Location List */
.loc-property-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.loc-prop-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    border-bottom: 1px dotted var(--color-border);
    padding-bottom: 4px;
}

.loc-prop-item:last-child {
    border-bottom: none;
}

.loc-prop-label {
    color: var(--color-text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.loc-prop-value {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--color-text);
    text-align: right;
    max-width: 60%;
    word-break: break-all;
}

.status-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    color: #fff;
}
.status-badge.ok { background: #4A9076; }
.status-badge.err { background: #B85C4A; }
.status-badge.warn { background: #7A7469; }

/* Overpass accordion */
.overpass-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-1);
}

.overpass-cog-btn {
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    padding: 2px 6px;
    line-height: 1;
    transition: color var(--transition-fast), background var(--transition-fast);
}

.overpass-cog-btn:hover {
    color: var(--color-text);
    background: var(--color-surface-alt);
}

.overpass-textarea {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    resize: vertical;
    min-height: 100px;
    width: 100%;
    line-height: 1.5;
    box-sizing: border-box;
}

/* Overpass settings dialog */
dialog.overpass-settings-dialog {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    padding: var(--space-5);
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    min-width: 320px;
    color: var(--color-text);
}

dialog.overpass-settings-dialog::backdrop {
    background: rgba(0,0,0,0.35);
}

.settings-modal-title {
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    margin: 0 0 var(--space-4) 0;
}

.settings-modal-actions {
    display: flex;
    gap: var(--space-2);
    margin-top: var(--space-4);
}
