/* ------------------------------------------------------------------ tokens */

:root {
    --ngis-panel-bg: #0d0d0d;
    --ngis-popup-bg: #1b1b1b;
    --ngis-border: #2a2a2a;
    --ngis-muted: #8a8a8a;
    --ngis-input-bg: #141414;
    --ngis-input-border: #3a3a3a;
    color-scheme: dark;
}

/* ------------------------------------------------------------------ dark form controls */

/* Cyborg ships white inputs; make them match the dark UI. */
.form-control,
.form-select {
    background-color: var(--ngis-input-bg);
    border-color: var(--ngis-input-border);
    color: var(--bs-body-color);
}

.form-control:focus,
.form-select:focus {
    background-color: var(--ngis-input-bg);
    border-color: var(--bs-primary);
    color: #fff;
    box-shadow: 0 0 0 .2rem rgba(42, 159, 214, .25);
}

.form-control::placeholder {
    color: #6a6a6a;
    opacity: 1;
}

.form-control:disabled,
.form-control[readonly] {
    background-color: #0b0b0b;
    color: var(--ngis-muted);
}

.form-control.is-invalid,
.form-control.is-invalid:focus {
    border-color: var(--bs-danger);
}

.form-check-input {
    background-color: var(--ngis-input-bg);
    border-color: #555;
}

.form-check-input:checked {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
}

.form-check-input:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 .2rem rgba(42, 159, 214, .25);
}

.form-switch .form-check-input:not(:checked) {
    --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23888'/%3e%3c/svg%3e");
}

.form-switch .form-check-input:disabled {
    opacity: .45;
}

/* ------------------------------------------------------------------ layout */

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

#content {
    flex: 1 0 auto;
}

/* Kept for the controllers that toggle visibility with jQuery. */
.app-navbar {
    border: 0;
    border-bottom: 1px solid var(--ngis-border);
}

/* Neutral outline button (Cyborg's "secondary" is too low-contrast on black). */
.btn-neutral {
    --bs-btn-color: #d0d0d0;
    --bs-btn-border-color: #444;
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #2a2a2a;
    --bs-btn-hover-border-color: #666;
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: #333;
    --bs-btn-active-border-color: #666;
    --bs-btn-disabled-color: #666;
    --bs-btn-disabled-border-color: #333;
}

.map-sidebar.offcanvas-lg {
    --bs-offcanvas-bg: var(--ngis-panel-bg);
    --bs-offcanvas-color: var(--bs-body-color);
}

.hidden {
    display: none !important;
}

/* ------------------------------------------------------------------ full-bleed map page */

body.page-map {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

body.page-map #content {
    flex: 1 1 auto;
    min-height: 0;
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 0 !important;
}

body.page-map .footer {
    display: none;
}

.map-layout {
    display: flex;
    height: 100%;
}

.map-wrapper {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
}

.map {
    position: absolute;
    inset: 0;
}

.map-sidebar-toggle {
    position: absolute;
    top: .5rem;
    left: 2.75rem;
    z-index: 2;
}

/* ------------------------------------------------------------------ sidebar */

@media (min-width: 992px) {
    .map-sidebar {
        width: 320px;
        flex: 0 0 320px;
        border-right: 1px solid var(--ngis-border);
        background-color: var(--ngis-panel-bg);
        display: flex;
        flex-direction: column;
        min-height: 0;
    }
}

.map-sidebar .map-sidebar-body {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-height: 0;
    padding: 0 !important;
    overflow-y: auto !important;
}

.sidebar-section {
    padding: .875rem 1rem;
    border-bottom: 1px solid var(--ngis-border);
}

.sidebar-section:last-child {
    border-bottom: 0;
}

.sidebar-section-grow {
    flex: 1 0 auto;
}

.sidebar-heading {
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--ngis-muted);
    margin-bottom: .625rem;
}

#base-map-options .btn {
    font-size: .75rem;
    white-space: nowrap;
}

.project-item + .project-item {
    border-top: 1px solid var(--ngis-border);
}

.project-row,
.layer-row,
.legend-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    min-width: 0;
}

.project-row {
    padding: .375rem 0;
}

.project-row .form-check-input,
.layer-row .form-check-input {
    flex-shrink: 0;
    margin-top: 0;
}

.project-name {
    flex: 1 1 auto;
    min-width: 0;
    font-weight: 500;
    cursor: pointer;
}

.project-row .btn-link,
.layer-row .btn-link {
    padding: 0 .25rem;
    color: var(--ngis-muted);
}

.project-row .btn-link:hover,
.layer-row .btn-link:hover {
    color: var(--bs-body-color);
}

.layer-list {
    margin: 0 0 .5rem 1.5rem;
}

.layer-row {
    padding: .1875rem 0;
    font-size: .875rem;
}

.layer-row .form-check-label {
    flex: 1 1 auto;
    min-width: 0;
    cursor: pointer;
}

.layer-count {
    font-size: .75rem;
    color: var(--ngis-muted);
    font-variant-numeric: tabular-nums;
}

.legend-row {
    padding: .1875rem 0;
    font-size: .875rem;
}

.legend-swatch {
    display: inline-flex;
    flex: 0 0 24px;
    justify-content: center;
    background: rgba(255, 255, 255, .85);
    border-radius: 3px;
}

.legend-label {
    flex: 1 1 auto;
}

/* Types not drawn at the current zoom level (CAD parcels and buildings when zoomed out). */
.legend-hidden .legend-swatch,
.legend-hidden .legend-label,
.legend-hidden .layer-count {
    opacity: .45;
}

.legend-hint {
    font-size: .75rem;
    font-style: italic;
}

/* ------------------------------------------------------------------ popup */

.ol-popup {
    position: absolute;
    min-width: 220px;
    max-width: 320px;
    background-color: var(--ngis-popup-bg);
    color: var(--bs-body-color);
    box-shadow: 0 .25rem 1rem rgba(0, 0, 0, .5);
    padding: .75rem 1rem;
    border-radius: var(--bs-border-radius-lg);
    border: 1px solid var(--ngis-border);
    bottom: 12px;
    left: -50px;
    font-size: .875rem;
}

.ol-popup:after,
.ol-popup:before {
    top: 100%;
    border: solid transparent;
    content: " ";
    height: 0;
    width: 0;
    position: absolute;
    pointer-events: none;
}

.ol-popup:after {
    border-top-color: var(--ngis-popup-bg);
    border-width: 10px;
    left: 48px;
    margin-left: -10px;
}

.ol-popup:before {
    border-top-color: var(--ngis-border);
    border-width: 11px;
    left: 48px;
    margin-left: -11px;
}

.ol-popup-closer {
    text-decoration: none;
    position: absolute;
    top: .375rem;
    right: .625rem;
    color: var(--ngis-muted);
}

.ol-popup-closer:hover {
    color: var(--bs-body-color);
}

.ol-popup-closer:after {
    content: "✖";
}

.ol-popup-title {
    font-weight: 600;
    font-size: 1rem;
    padding-right: 1.25rem;
}

.ol-popup-layer {
    color: var(--ngis-muted);
    font-size: .75rem;
    margin-bottom: .5rem;
}

.ol-popup-props {
    width: 100%;
}

.ol-popup-props th {
    color: var(--ngis-muted);
    font-weight: normal;
    padding: .125rem .75rem .125rem 0;
    vertical-align: top;
    white-space: nowrap;
}

.ol-popup-props td {
    padding: .125rem 0;
    word-break: break-word;
}

/* Keep the map controls readable on dark and light base maps. */
.ol-scale-line {
    left: auto;
    right: .5em;
    bottom: 2.5em;
}

/* ------------------------------------------------------------------ page scaffolding */

.min-w-0 {
    min-width: 0;
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-title {
    font-size: 2rem;
    font-weight: 500;
    margin-bottom: .25rem;
}

.page-subtitle {
    color: var(--ngis-muted);
    margin-bottom: 0;
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
}

.page-actions input[type="search"] {
    width: 18rem;
    max-width: 100%;
}

@media (max-width: 575.98px) {
    .page-actions,
    .page-actions input[type="search"] {
        width: 100%;
    }
}

.breadcrumb {
    font-size: .875rem;
    margin-bottom: .75rem;
}

.card {
    --bs-card-bg: var(--ngis-panel-bg);
    --bs-card-border-color: var(--ngis-border);
    --bs-card-cap-bg: rgba(255, 255, 255, .03);
}

.card .table {
    --bs-table-bg: transparent;
}

.card .table > :not(caption) > * > * {
    border-bottom-color: var(--ngis-border);
}

.card .table tbody tr:last-child > * {
    border-bottom: 0;
}

.card .table thead th {
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--ngis-muted);
}

.card .list-group {
    --bs-list-group-bg: transparent;
    --bs-list-group-border-color: var(--ngis-border);
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
}

.empty-state-icon {
    font-size: 2.5rem;
    color: var(--ngis-muted);
    margin-bottom: .75rem;
    display: block;
}

/* ------------------------------------------------------------------ project page */

.file-row {
    display: flex;
    align-items: center;
    gap: .875rem;
}

.file-icon {
    font-size: 1.5rem;
    color: var(--ngis-muted);
}

.file-main {
    flex: 1 1 auto;
    min-width: 0;
}

.file-title {
    font-weight: 500;
    word-break: break-word;
}

.file-meta {
    font-size: .8125rem;
    color: var(--ngis-muted);
}

.file-actions {
    display: flex;
    gap: .5rem;
    flex-shrink: 0;
}

.dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .375rem;
    padding: 2rem 1rem;
    border: 2px dashed var(--ngis-border);
    border-radius: var(--bs-border-radius-lg);
    text-align: center;
    cursor: pointer;
    transition: border-color .15s, background-color .15s;
}

.dropzone:hover,
.dropzone.is-dragover {
    border-color: var(--bs-primary);
    background-color: rgba(42, 159, 214, .08);
}

.dropzone:focus-within {
    outline: 2px solid var(--bs-primary);
    outline-offset: 2px;
}

.dropzone-icon {
    font-size: 1.75rem;
    color: var(--ngis-muted);
}

.dropzone-hint {
    font-size: .8125rem;
    color: var(--ngis-muted);
}

.upload-item {
    display: flex;
    align-items: baseline;
    gap: .5rem;
    padding: .125rem 0;
}

/* ------------------------------------------------------------------ file page */

.file-preview-map {
    height: 420px;
    min-height: 100%;
}

.attribute-search {
    width: 12rem;
}

.attribute-table-wrapper {
    max-height: 480px;
    overflow: auto;
}

.attribute-table thead th {
    position: sticky;
    top: 0;
    background-color: var(--ngis-panel-bg);
    z-index: 1;
    white-space: nowrap;
    text-transform: none !important;
    letter-spacing: 0 !important;
}

.attribute-row {
    cursor: pointer;
}

.raw-json summary {
    color: var(--ngis-muted);
    cursor: pointer;
    margin-bottom: .5rem;
}

.raw-json-content {
    max-height: 480px;
    overflow: auto;
    padding: 1rem;
    background-color: var(--ngis-panel-bg);
    border: 1px solid var(--ngis-border);
    border-radius: var(--bs-border-radius);
    color: var(--bs-body-color);
    font-size: .8125rem;
}

/* ------------------------------------------------------------------ auth */

.auth-wrapper {
    display: flex;
    justify-content: center;
    padding: 3rem 0;
}

.auth-card {
    width: 100%;
    max-width: 420px;
}

.list-group-item.legend-row {
    padding: .5rem 1rem;
}

/* ------------------------------------------------------------------ profile */

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: linear-gradient(135deg, #2a9fd6, #1a5f86);
    color: #fff;
    font-weight: 600;
    overflow: hidden;
    user-select: none;
}

.avatar-lg {
    width: 4.5rem;
    height: 4.5rem;
    font-size: 1.5rem;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.account-details dt {
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--ngis-muted);
}

.account-details dd {
    margin-bottom: 1rem;
}

.account-details dd:last-child {
    margin-bottom: 0;
}

.account-details code {
    color: var(--bs-body-color);
}

/* ------------------------------------------------------------------ footer */

.footer a {
    text-decoration: none;
}

/* Dark scrollbars (the sidebar and tables scroll on short screens) */
.map-sidebar-body,
.attribute-table-wrapper,
.raw-json-content {
    scrollbar-color: #3a3a3a transparent;
    scrollbar-width: thin;
}
