/* ============================================
   Shahrkavi - USGS Earth Explorer Clone
   Persian (Farsi) RTL Theme
   ============================================ */

/* --- CSS Variables --- */
:root {
    --header-height: 56px;
    --cart-footer-height: auto;
    --tab-height: 48px;
    --map-toolbar-size: 44px;
    --primary: #0d6efd;
    --primary-dark: #0b5ed7;
    --success: #198754;
    --warning: #ffc107;
    --danger: #dc3545;
    --bg-dark: #1a1d23;
    --bg-panel: #f8f9fa;
    --border-color: #dee2e6;
    --text-muted: #6c757d;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.12);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.15);
    --radius-sm: 6px;
    --radius-md: 8px;
    --transition: 0.2s ease;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Vazirmatn', 'Vazirmatn FD', Tahoma, sans-serif;
    direction: rtl;
    font-size: 14px;
    color: #212529;
    background: #f0f2f5;
}

/* --- Header --- */
.app-header {
    height: var(--header-height);
    background: linear-gradient(135deg, #1a3a4a 0%, #1a5276 50%, #1a6e50 100%);
    color: #fff;
    padding: 0 16px;
    display: flex;
    align-items: center;
    box-shadow: var(--shadow-md);
    z-index: 1000;
    position: relative;
}

.app-logo {
    width: 36px;
    height: 36px;
    filter: brightness(0) invert(1);
}

.app-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
    line-height: 1.3;
}

.app-subtitle {
    font-size: 0.7rem;
    margin: 0;
    opacity: 0.8;
}

/* --- Main Layout --- */
.app-container {
    display: flex;
    height: calc(100vh - var(--header-height));
    width: 100%;
    position: relative;
}

/* --- Map Panel --- */
.map-panel {
    flex: 1;
    position: relative;
    min-width: 0;
    background: #d4d4d4;
}

#mapContainer {
    width: 100%;
    height: 100%;
}

#map {
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* --- Map Toolbar --- */
.map-toolbar {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 1000;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.basemap-control {
    min-width: 175px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
}

.basemap-control label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 5px;
    color: #343a40;
    font-size: 0.75rem;
    font-weight: 600;
}

.basemap-control .form-select {
    cursor: pointer;
}

.map-toolbar .btn-group-vertical {
    box-shadow: var(--shadow-md);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.map-tool-btn {
    width: var(--map-toolbar-size);
    height: var(--map-toolbar-size);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0 !important;
    border: 1px solid rgba(0,0,0,0.1);
    font-size: 1.1rem;
    transition: var(--transition);
}

.map-tool-btn:hover {
    background: #e9ecef;
}

.map-tool-btn.active {
    background: var(--primary) !important;
    color: #fff !important;
    border-color: var(--primary) !important;
}

/* --- Coordinates Display --- */
.coord-display {
    position: absolute;
    bottom: 12px;
    left: 12px;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    box-shadow: var(--shadow-sm);
    direction: ltr;
    text-align: left;
}

.coord-divider {
    margin: 0 8px;
    opacity: 0.5;
}

/* --- Zoom Info --- */
.map-zoom-info {
    position: absolute;
    bottom: 12px;
    right: 60px;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    box-shadow: var(--shadow-sm);
}

/* --- Side Panel --- */
.side-panel {
    width: 480px;
    min-width: 320px;
    max-width: 650px;
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}

/* Ensure summary box sits above tabs and scrolls properly */
.summary-box {
    flex-shrink: 0;
    margin: 0px 5px;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
    z-index: 10;
}

/* --- Summary Box --- */
.summary-box {
    flex-shrink: 0;
    margin: 0px 5px;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
    z-index: 10;
}

.summary-header {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: #f8f9fa;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.75rem;
    font-weight: 600;
    color: #495057;
}

.summary-header i {
    color: var(--primary);
    font-size: 0.7rem;
}

.summary-clear {
    margin-right: auto;
    padding: 0;
    color: var(--text-muted) !important;
    text-decoration: none !important;
    font-size: 0.7rem;
    line-height: 1;
}

.summary-clear:hover {
    color: var(--danger) !important;
}

.summary-body {
    padding: 4px 8px;
    max-height: 160px;
    overflow-y: auto;
    font-size: 0.73rem;
    line-height: 1.4;
}

.summary-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 10px 6px;
    color: var(--text-muted);
    font-size: 0.7rem;
    text-align: center;
}

.summary-empty i {
    font-size: 1.1rem;
    opacity: 0.4;
}

.summary-row {
    display: flex;
    align-items: baseline;
    gap: 4px;
    padding: 1px 0;
    font-size: 0.73rem;
}

.summary-key {
    color: var(--text-muted);
    flex-shrink: 0;
    min-width: 48px;
}

.summary-value {
    color: #212529;
    word-break: break-all;
}

.summary-value.highlight {
    color: var(--primary);
    font-weight: 500;
}

.summary-badge {
    display: inline-flex;
    align-items: center;
    padding: 0 4px;
    background: #e8f0fe;
    border: 1px solid #c5d8f8;
    border-radius: 2px;
    font-size: 0.65rem;
    color: #0d6efd;
    font-weight: 600;
    margin-right: 4px;
}

.summary-count {
    display: inline-flex;
    align-items: center;
    padding: 0 5px;
    background: #d1e7dd;
    border: 1px solid #a3cfbb;
    border-radius: 8px;
    font-size: 0.65rem;
    color: #0f5132;
    font-weight: 500;
}

/* --- Panel Resize Handle --- */
.panel-resize-handle {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    cursor: col-resize;
    z-index: 100;
    background: transparent;
    transition: background var(--transition);
}

.panel-resize-handle:hover,
.panel-resize-handle.active {
    background: var(--primary);
}

/* --- Tabs --- */
.app-tabs {
    flex-shrink: 0;
    height: var(--tab-height);
    border-bottom: 2px solid var(--border-color);
    background: #fff;
}

.app-tabs .nav-link {
    border: none;
    border-radius: 0;
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 10px 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
    position: relative;
}

.app-tabs .nav-link:hover {
    color: #495057;
    background: rgba(13, 110, 253, 0.04);
}

.app-tabs .nav-link.active {
    color: var(--primary);
    background: transparent;
    border-bottom: 3px solid var(--primary);
}

.results-badge {
    font-size: 0.65rem;
    font-family: 'Vazirmatn', Tahoma, sans-serif;
}

/* --- Tab Content --- */
.app-tab-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
}

.pane-content {
    padding: 14px;
}

/* --- Search Form --- */
.search-form {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.search-section {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin-bottom: 4px;
}

.section-title {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: #495057;
    display: flex;
    align-items: center;
    gap: 6px;
}

.section-title i {
    color: var(--primary);
}

/* --- Range Slider --- */
.range-container {
    padding: 4px 0;
}

.range-value {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Form Label */
.form-label {
    font-size: 0.75rem;
    margin-bottom: 4px;
    color: var(--text-muted);
    font-weight: 500;
}

.form-control-sm {
    font-size: 0.8rem;
}

/* --- Dataset Tree --- */
.dataset-intro {
    padding: 4px 2px 16px;
}

.dataset-step-label {
    color: var(--primary);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    margin-bottom: 9px;
}

.dataset-step-label span {
    display: inline-block;
    width: 4px;
    height: 4px;
    margin: 0 7px;
    border-radius: 50%;
    background: var(--border-color);
    vertical-align: middle;
}

.dataset-intro-heading {
    display: flex;
    align-items: center;
    gap: 11px;
}

.dataset-intro-icon {
    display: grid;
    place-items: center;
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    color: #fff;
    background: linear-gradient(135deg, #0d6efd, #487cff);
    box-shadow: 0 7px 16px rgba(13, 110, 253, 0.2);
    font-size: 1.15rem;
}

.dataset-intro h2 {
    margin: 0 0 3px;
    color: #1b2b42;
    font-size: 1.06rem;
    font-weight: 800;
}

.dataset-intro p {
    max-width: 330px;
    margin: 0;
    color: var(--text-muted);
    font-size: 0.75rem;
    line-height: 1.7;
}

.dataset-selection-card {
    min-height: 68px;
    margin-bottom: 14px;
    padding: 10px 12px;
    border: 1px solid #d9e5f5;
    border-radius: 12px;
    background: linear-gradient(135deg, #f7faff, #eef5ff);
}

.dataset-selection-empty,
.dataset-selection-filled {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 46px;
}

.dataset-selection-empty > i,
.dataset-selection-icon {
    display: grid;
    place-items: center;
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    color: var(--primary);
    background: #dceaff;
    font-size: 1rem;
}

.dataset-selection-empty > i {
    flex-basis: 32px;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    font-size: 0.8rem;
}

.dataset-selection-empty strong,
.dataset-selection-copy strong {
    display: block;
    color: #243852;
    font-size: 0.78rem;
}

.dataset-selection-empty span,
.dataset-selection-copy span {
    display: block;
    color: var(--text-muted);
    font-size: 0.68rem;
    line-height: 1.5;
}

.dataset-selection-copy {
    min-width: 0;
    flex: 1;
}

.dataset-selection-label {
    color: var(--primary) !important;
    font-size: 0.62rem !important;
    font-weight: 700;
}

.dataset-selection-copy strong,
.dataset-selection-copy span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dataset-selection-check {
    color: var(--success);
    font-size: 1.1rem;
}

.dataset-picker-section {
    padding: 12px;
    border: 1px solid #e5eaf1;
    border-radius: 12px;
    background: #fbfcfe;
}

.dataset-picker-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 9px;
}

.dataset-required-badge {
    flex: 0 0 auto;
    padding: 4px 7px;
    border-radius: 999px;
    color: #65758b;
    background: #eef2f7;
    font-size: 0.62rem;
    white-space: nowrap;
}

.dataset-required-badge i {
    color: var(--danger);
    font-size: 0.45rem;
    vertical-align: middle;
}

.dataset-picker-hint {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin-top: 9px;
    color: #738198;
    font-size: 0.65rem;
    line-height: 1.6;
}

.dataset-picker-hint i {
    flex: 0 0 auto;
    margin-top: 2px;
    color: var(--primary);
}

.dataset-search {
    position: relative;
}

.dataset-actions {
    display: flex;
    gap: 8px;
    padding: 0 4px;
}

.dataset-actions .btn-link {
    font-size: 0.75rem;
    text-decoration: none;
    padding: 0;
}

.dataset-tree {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 8px;
    max-height: calc(100vh - 390px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #c5d3e6 transparent;
}

/* Quercus.js treeview RTL overrides */
.custom-treeview-wrapper {
    background: transparent;
    border: none;
    padding: 0;
    box-shadow: none;
    max-width: none;
    margin: 0;
    font-size: 0.85rem;
}

.custom-treeview-wrapper ul {
    padding-right: 0;
    padding-left: 0;
}

.custom-treeview-wrapper .treeview-node-content {
    min-height: 40px;
    padding: 5px 7px;
    border-radius: 8px;
    transition: background-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

.custom-treeview-wrapper .treeview-node-content:hover {
    background-color: #eef5ff;
    transform: translateX(-1px);
}

.custom-treeview-wrapper li.selected > .treeview-node-content {
    background: linear-gradient(90deg, #e5efff, #f1f6ff) !important;
    color: #164b9b !important;
    box-shadow: inset -3px 0 0 var(--primary), 0 2px 7px rgba(13, 110, 253, 0.08);
}

.custom-treeview-wrapper .treeview-checkbox {
    width: 16px;
    height: 16px;
    margin-left: 6px !important;
    accent-color: var(--primary);
    cursor: pointer !important;
}

.custom-treeview-wrapper .treeview-node-text {
    font-size: 0.85rem;
    line-height: 1.35;
}

.custom-treeview-wrapper .dataset-tree-info {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.custom-treeview-wrapper .treeview-search-input {
    font-size: 0.82rem;
    min-height: 36px;
    padding: 6px 30px 6px 10px;
    border: 1px solid #d9e2ee;
    border-radius: 9px;
    background: #fff;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.custom-treeview-wrapper .treeview-search-input:focus {
    border-color: #8bb5f4;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.1);
    outline: none;
}

.custom-treeview-wrapper .treeview-search-clear {
    right: 8px;
}

.custom-treeview-wrapper .treeview-expander {
    width: 22px;
    height: 22px;
    margin-right: 2px;
    border-radius: 6px;
    margin-left: 0;
    font-size: 0.75rem;
    line-height: 22px;
}

.custom-treeview-wrapper .treeview-expander-placeholder {
    width: 22px;
    margin-right: 2px;
    margin-left: 0;
}

.custom-treeview-wrapper .treeview-expander:hover {
    color: var(--primary);
    background: #dceaff;
}

.custom-treeview-wrapper li.has-children > .treeview-node-content {
    min-height: 36px;
    color: #354961;
    background: #f2f5f9;
    font-weight: 700;
    opacity: 1;
}

.custom-treeview-wrapper .dataset-category-icon {
    width: 22px;
    margin-left: 7px;
    color: var(--primary);
    font-size: 0.9rem;
}

.custom-treeview-wrapper .dataset-category-name {
    font-size: 0.76rem;
    letter-spacing: 0.01em;
}

.custom-treeview-wrapper li.has-children > ul {
    padding-right: 7px;
    margin-top: 3px;
    border-right: 1px solid #dce5f1;
}

.custom-treeview-wrapper li.highlight > .treeview-node-content {
    font-style: normal;
    color: inherit;
    background-color: #fff3cd;
}

.dataset-category {
    margin-bottom: 2px;
}

.dataset-category-header {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    cursor: pointer;
    border-radius: 4px;
    transition: background var(--transition);
    font-weight: 500;
    font-size: 0.85rem;
}

.dataset-category-header:hover {
    background: #f0f4ff;
}

.dataset-category-header .bi-chevron-left {
    transition: transform var(--transition);
    margin-left: 4px;
    font-size: 0.7rem;
}

.dataset-category-header.expanded .bi-chevron-left {
    transform: rotate(-90deg);
}

.dataset-children {
    padding-right: 22px;
    display: none;
}

.dataset-children.show {
    display: block;
}

.dataset-item {
    display: flex;
    align-items: center;
    padding: 4px 8px;
    font-size: 0.8rem;
    cursor: pointer;
    border-radius: 4px;
    transition: background var(--transition);
}

.dataset-item:hover {
    background: #f0f4ff;
}

.dataset-item .form-check-input {
    margin-left: 8px;
}

.dataset-item.selected {
    background: #e8f0fe;
}

.dataset-item .dataset-info {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-right: auto;
}

/* --- Layer List --- */
.layer-list {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.layer-item {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    transition: background var(--transition);
    gap: 10px;
}

.layer-item:last-child {
    border-bottom: none;
}

.layer-item:hover {
    background: #f8f9fa;
}

.layer-item.dragging {
    opacity: 0.5;
    background: #e9ecef;
}

.layer-item .layer-drag-handle {
    cursor: grab;
    color: #adb5bd;
    font-size: 1rem;
}

.layer-item .layer-drag-handle:active {
    cursor: grabbing;
}

.layer-item .layer-icon {
    font-size: 1.2rem;
    color: var(--primary);
}

.layer-item .layer-name {
    flex: 1;
    font-size: 0.8rem;
    font-weight: 500;
}

.layer-item .layer-opacity {
    width: 80px;
}

.layer-item .layer-opacity input {
    height: 4px;
}

.layer-item .layer-actions {
    display: flex;
    gap: 4px;
}

.layer-item .layer-actions .btn {
    padding: 2px 6px;
    font-size: 0.75rem;
}

/* --- Results Table --- */
.results-header {
    background: #fff;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.results-count {
    font-weight: 600;
    font-size: 0.9rem;
}

.results-table-container {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow-x: auto;
    overflow-y: hidden;
}

.results-table {
    margin-bottom: 0;
}

.results-table thead {
    background: #f1f3f5;
    position: sticky;
    top: 0;
    z-index: 2;
}

.results-table th {
    font-size: 0.75rem;
    font-weight: 600;
    color: #495057;
    white-space: nowrap;
    padding: 8px 8px;
    border-bottom-width: 1px;
}

.results-table td {
    font-size: 0.8rem;
    vertical-align: middle;
    padding: 6px 8px;
}

.results-table tr.scene-selected td {
    background: rgba(25, 135, 84, 0.08);
}

.results-table tr.row-selected td {
    background: rgba(13, 110, 253, 0.08);
}

.results-selection-count {
    white-space: nowrap;
}

.result-thumb-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.col-select {
    width: 36px;
    text-align: center;
}

.col-thumb {
    width: 64px;
}

.result-thumb {
    width: 56px;
    height: 42px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background: #e9ecef;
}

/* Condensed scene cell: long IDs truncate instead of widening the table */
.results-table .scene-cell {
    max-width: 220px;
}

.results-table .scene-id-text {
    font-size: 0.78rem;
}

.result-cloud-badge {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 12px;
}

.cloud-low {
    background: #d4edda;
    color: #155724;
}

.cloud-mid {
    background: #fff3cd;
    color: #856404;
}

.cloud-high {
    background: #f8d7da;
    color: #721c24;
}

.results-table .btn-action {
    padding: 3px 8px;
    font-size: 0.75rem;
}

.results-table .form-check-input {
    width: 1.1rem;
    height: 1.1rem;
    margin-top: 0;
}

.results-empty td {
    padding: 30px !important;
}

/* --- OSM layer type chips --- */
.osm-type-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: #f8f9fa;
    color: #495057;
    line-height: 1;
    cursor: default;
}

.osm-type-chip svg {
    display: block;
    color: var(--primary, #0d6efd);
}

/* --- Process Scene Selection --- */
.process-scene-list {
    max-height: 220px;
    overflow-y: auto;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    background: var(--bg-panel);
}

/* --- Pagination --- */
.results-pagination {
    margin-top: 12px;
}

.results-pagination .page-link {
    font-size: 0.8rem;
    padding: 4px 10px;
}

/* --- Wizard Navigation --- */
.wizard-nav {
    display: flex;
    gap: 8px;
    margin-top: 14px;
}

.wizard-nav .btn-prev {
    margin-left: auto;   /* Push next button to the far end in RTL */
}

/* --- Cart Footer --- */
.cart-footer {
    flex-shrink: 0;
    padding: 5px 0px;
    background: #fff;
    border-top: 1px solid var(--border-color);
    height: var(--cart-footer-height);
}

/* --- Leaflet Overrides for RTL --- */
.leaflet-control-attribution {
    font-family: 'Vazirmatn', Tahoma, sans-serif !important;
    font-size: 0.65rem !important;
    direction: rtl;
}

.leaflet-draw-toolbar {
    margin-top: 0 !important;
}

.leaflet-draw-toolbar a {
    background-image: none !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
}

.leaflet-draw-draw-polygon {
    /* Hidden - we use our custom toolbar */
}

/* --- Scrollbar Styling --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* --- Animations --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

/* --- Loading Spinner --- */
.spinner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

/* --- Toast --- */
.app-toast {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 9999;
    min-width: 280px;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .map-panel {
        order: 1;
        height: 45vh;
    }

    .side-panel {
        order: 2;
        width: 100%;
        min-width: unset;
        max-width: unset;
        height: 55vh;
    }

    .panel-resize-handle {
        display: none;
    }

    .app-tabs .nav-link span {
        font-size: 0.7rem;
    }

    .app-tabs .nav-link {
        padding: 8px 10px;
    }

    .coord-display {
        bottom: 8px;
        left: 8px;
        font-size: 0.7rem;
    }

    .dataset-tree {
        max-height: 220px;
    }

    .dataset-intro {
        padding-bottom: 12px;
    }

    .dataset-intro h2 {
        font-size: 0.98rem;
    }

    .dataset-picker-section {
        padding: 10px;
    }

    .results-table th,
    .results-table td {
        font-size: 0.7rem;
        padding: 6px 8px;
    }

    .col-thumb {
        width: 60px;
    }

    .result-thumb {
        width: 48px;
        height: 36px;
    }
}

@media (max-width: 480px) {
    .app-title {
        font-size: 1rem;
    }

    .app-subtitle {
        display: none;
    }

    .app-header {
        padding: 0 10px;
    }

    .dataset-picker-header {
        display: block;
    }

    .dataset-required-badge {
        display: inline-block;
        margin-top: 7px;
    }

    .dataset-intro-heading {
        align-items: flex-start;
    }

    .dataset-intro-icon {
        flex-basis: 34px;
        width: 34px;
        height: 34px;
        border-radius: 10px;
    }

    .map-toolbar {
        top: 8px;
        right: 8px;
    }

    .basemap-control {
        min-width: 145px;
        padding: 6px;
    }

    .basemap-control label span {
        display: none;
    }

    .map-tool-btn {
        width: 36px;
        height: 36px;
    }
}

/* --- Print --- */
@media print {
    .app-header,
    .side-panel,
    .map-toolbar,
    .basemap-control,
    .coord-display {
        display: none !important;
    }

    .map-panel {
        width: 100%;
        height: 100vh;
    }
}

/* --- OSM tag pair comboboxes --- */
.osm-combo-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1050;
    max-height: 260px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, .15);
    border-radius: .25rem;
    margin-top: 2px;
}

.osm-combo-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .5rem;
    width: 100%;
    padding: .35rem .75rem;
    background: none;
    border: none;
    text-align: start;
    font-size: .8rem;
    cursor: pointer;
}

.osm-combo-item:hover,
.osm-combo-item.active {
    background: #f1f3f5;
}

.osm-combo-empty {
    padding: .5rem .75rem;
    font-size: .75rem;
    color: #6c757d;
}

/* --- Jalali inline range calendar --- */
.jalali-range-calendar {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    user-select: none;
}

.jdp-months {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.jdp-month { min-width: 0; }

.jdp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.jdp-title {
    display: flex;
    gap: 4px;
    flex: 1;
    justify-content: center;
}

.jdp-title select {
    font-size: .74rem;
    padding: 2px 3px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: #f8f9fa;
    max-width: 76px;
}

.jdp-nav {
    border: none;
    background: none;
    font-size: 1.2rem;
    line-height: 1;
    color: #495057;
    cursor: pointer;
    padding: 0 6px;
}

.jdp-nav:hover { color: #0d6efd; }

.jdp-weekdays,
.jdp-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    text-align: center;
}

.jdp-weekdays span {
    font-size: .66rem;
    color: #6c757d;
    padding: 2px 0;
}

.jdp-day {
    position: relative;
    border: none;
    background: none;
    font-size: .72rem;
    padding: 4px 0;
    border-radius: 4px;
    cursor: pointer;
}

.jdp-day:hover:not(.jdp-empty) { background: #e9ecef; }
.jdp-day.jdp-today { outline: 1px solid #0d6efd; }
.jdp-day.jdp-inrange { background: #e7f1ff; border-radius: 0; }

/* Days that have imagery for the current region + dataset */
.jdp-day.jdp-hasdata { font-weight: 700; color: #198754; }

.jdp-day.jdp-hasdata::after {
    content: '';
    position: absolute;
    bottom: 1px;
    left: 50%;
    transform: translateX(-50%);
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #198754;
}

.jdp-day.jdp-hasdata:hover:not(.jdp-selected) { background: #d1e7dd; }
.jdp-day.jdp-selected,
.jdp-day.jdp-inrange.jdp-selected {
    background: #0d6efd;
    color: #fff;
}

.jdp-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border-top: 1px solid var(--border-color);
    margin-top: 10px;
    padding-top: 8px;
}

.jdp-footer-label {
    font-size: .76rem;
    color: #495057;
}

.jdp-footer-actions { display: flex; gap: 4px; }

.jdp-btn {
    font-size: .7rem;
    padding: 2px 8px;
}

/* --- Product-wide UX refresh --- */
:root {
    --bg-panel: #f4f7fb;
    --border-color: #dce4ee;
    --shadow-panel: 0 16px 40px rgba(28, 52, 84, 0.08);
}

body {
    background: #eef2f7;
}

.app-header {
    background: linear-gradient(120deg, #142c43 0%, #145273 58%, #18725f 100%);
    box-shadow: 0 4px 18px rgba(12, 31, 50, 0.2);
}

.app-title {
    letter-spacing: -0.02em;
}

.side-panel {
    background: var(--bg-panel);
    border-right-color: #d5dfeb;
    box-shadow: var(--shadow-panel);
}

.app-tabs {
    height: 54px;
    padding: 0 7px;
    gap: 2px;
    border-bottom: 1px solid #d9e2ed;
    background: rgba(255, 255, 255, 0.94);
}

.app-tabs .nav-item {
    display: flex;
    min-width: 0;
    flex: 1 1 0;
}

.app-tabs .nav-link {
    width: 100%;
    justify-content: center;
    border-radius: 9px 9px 0 0;
    color: #75849a;
    font-size: 0.78rem;
    padding: 8px 7px;
    gap: 5px;
}

.app-tabs .nav-link i {
    font-size: 0.9rem;
}

.app-tabs .nav-link:hover {
    color: #29496b;
    background: #f3f7fc;
}

.app-tabs .nav-link.active {
    color: #0c67d8;
    background: #f2f7ff;
    border-bottom: 3px solid #0d6efd;
}

.app-tab-content {
    scroll-behavior: smooth;
}

.pane-content {
    padding: 18px 16px 20px;
    animation: paneIn 0.22s ease-out;
}

.search-section,
.results-header,
.results-table-container {
    border-color: #dfe7f0;
    border-radius: 12px;
    box-shadow: 0 3px 13px rgba(37, 64, 93, 0.035);
}

.search-section {
    padding: 15px;
    margin-bottom: 9px;
}

.section-title {
    color: #263d59;
    font-size: 0.82rem;
    font-weight: 750;
}

.section-title i {
    display: inline-grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 7px;
    background: #eaf2ff;
    font-size: 0.78rem;
}

.form-control,
.form-select,
.form-range {
    border-color: #d2deeb;
}

.form-control:focus,
.form-select:focus {
    border-color: #86b3ef;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.11);
}

.form-control-sm,
.form-select-sm {
    min-height: 36px;
    border-radius: 8px;
}

.btn {
    min-height: 36px;
    border-radius: 8px;
    font-weight: 600;
    transition: transform var(--transition), box-shadow var(--transition), background-color var(--transition);
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
}

.btn:active:not(:disabled) {
    transform: translateY(0);
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.58;
}

.btn-primary,
.btn-success {
    box-shadow: 0 5px 13px rgba(13, 110, 253, 0.15);
}

.wizard-nav {
    position: sticky;
    bottom: 0;
    z-index: 3;
    margin: 15px -16px -20px;
    padding: 12px 16px;
    border-top: 1px solid #dfe7f0;
    background: rgba(244, 247, 251, 0.93);
    backdrop-filter: blur(8px);
}

.wizard-nav .btn {
    min-width: 104px;
}

.summary-box {
    margin: 0 9px 8px;
    border-color: #dce5ef;
    border-radius: 10px;
    box-shadow: 0 3px 12px rgba(37, 64, 93, 0.05);
}

.summary-header {
    padding: 7px 10px;
    background: #f8fafd;
}

.summary-body {
    padding: 7px 10px;
}

.results-header {
    padding: 13px 15px;
}

.results-count {
    color: #213b59;
}

.results-table-container {
    box-shadow: 0 5px 18px rgba(37, 64, 93, 0.05);
}

.results-table thead {
    background: #f3f6fa;
}

.results-table tbody tr {
    transition: background-color var(--transition), box-shadow var(--transition);
}

.results-table tbody tr:hover td {
    background: #f7faff;
}

.results-table tr.scene-selected td,
.results-table tr.row-selected td {
    background: #eef6ff;
}

.results-table .btn-action {
    min-width: 34px;
    min-height: 34px;
    border-radius: 7px;
}

.process-scene-list {
    border-color: #d7e1ec;
    background: #f8fafd;
    border-radius: 9px;
}

.process-scene-list .form-check {
    padding: 7px 8px;
    border-radius: 7px;
}

.process-scene-list .form-check:hover {
    background: #edf4fd;
}

.map-toolbar .basemap-control,
.map-toolbar .btn-group-vertical {
    box-shadow: 0 7px 20px rgba(19, 39, 61, 0.18);
}

.map-toolbar {
    right: 12px;
    left: 12px;
    justify-content: space-between;
}

.map-toolbar .basemap-control {
    order: 1;
}

.map-toolbar .btn-group-vertical {
    order: 2;
}

.map-toolbar .btn-group-vertical {
    border-radius: 9px;
}

.map-tool-btn {
    width: 42px;
    height: 42px;
}

@keyframes paneIn {
    from { opacity: 0.65; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) {
    .app-tabs {
        overflow-x: auto;
        padding: 0 3px;
    }

    .app-tabs .nav-item {
        flex: 0 0 auto;
    }

    .app-tabs .nav-link {
        min-width: 72px;
    }

    .pane-content {
        padding: 14px 12px 18px;
    }

    .wizard-nav {
        margin: 14px -12px -18px;
        padding: 10px 12px;
    }

    .wizard-nav .btn {
        flex: 1;
        min-width: 0;
    }
}

@media (max-width: 480px) {
    .app-tabs .nav-link {
        min-width: 64px;
        padding: 8px 5px;
        font-size: 0.66rem;
    }

    .app-tabs .nav-link i {
        font-size: 0.82rem;
    }

    .search-section {
        padding: 12px;
    }

    .map-toolbar {
        right: 8px;
        left: 8px;
    }
}
