/* app-base-classic.css - the Classic template's design tokens, reset and the
   components that a CSS framework would otherwise provide (.btn, .form-control,
   .card, .alert, .badge, tables, .app-modal). Loaded by the Classic shell only;
   the Deppy template gets these from Bootstrap + assets/templates/deppy/app-ui.css. */
/* =====================================================================
   b2maps - shared application styles
   Mobile-first, no external CSS framework.
   ===================================================================== */

:root {
  --color-bg: #f2f4f8;
  --color-surface: #ffffff;
  --color-surface-alt: #f8f9fb;
  --color-primary: #4f6bf6;
  --color-primary-dark: #3a53d9;
  --color-primary-soft: rgba(79, 107, 246, 0.12);
  --color-text: #171b24;
  --color-muted: #6b7785;
  --color-border: #e3e7ee;
  --color-danger: #e5484d;
  --color-danger-dark: #c73338;
  --color-success: #23a566;
  --color-map-btn: #1877f2;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 32, 0.06), 0 4px 14px rgba(16, 24, 32, 0.06);
  --shadow-lg: 0 8px 24px rgba(16, 24, 32, 0.1), 0 2px 6px rgba(16, 24, 32, 0.06);
  --sidebar-width: 230px;
  --topbar-height: 60px;
}

html[data-theme="dark"] {
  --color-bg: #0f1520;
  --color-surface: #171d29;
  --color-surface-alt: #1d2432;
  --color-primary: #6c85ff;
  --color-primary-dark: #8fa2ff;
  --color-primary-soft: rgba(108, 133, 255, 0.16);
  --color-text: #e7eaf1;
  --color-muted: #8b95a5;
  --color-border: #2a3140;
  --color-danger: #f16368;
  --color-danger-dark: #ff8a8e;
  --color-success: #3ecf8e;
  --color-map-btn: #4d94ff;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 14px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 10px 28px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

html { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }

body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s ease, color 0.2s ease;
}

/* Plain text links - no classic "blue + underlined" look. Affordance
   comes from a color shift + a subtle animated underline that only
   appears on hover/focus (drawn as a background-size trick rather than
   text-decoration, so it doesn't clip descenders like "g"/"y"). */
a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
  background-image: linear-gradient(var(--color-primary-dark), var(--color-primary-dark));
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 0 1px;
  transition: color 0.15s ease, background-size 0.15s ease;
}
a:hover, a:focus-visible {
  color: var(--color-primary-dark);
  background-size: 100% 1px;
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 0.6em; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--color-primary);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(16, 24, 32, 0.08);
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}
.btn:hover { background: var(--color-primary-dark); text-decoration: none; transform: translateY(-1px); box-shadow: 0 4px 10px rgba(79, 107, 246, 0.25); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.btn-secondary { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border); box-shadow: none; }
.btn.btn-secondary:hover { background: var(--color-surface-alt); box-shadow: none; }
.btn.btn-danger { background: var(--color-danger); }
.btn.btn-danger:hover { background: var(--color-danger-dark); box-shadow: 0 4px 10px rgba(229, 72, 77, 0.25); }
.btn.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn.btn-map { background: var(--color-map-btn); }
.btn.btn-map:hover { background: var(--color-map-btn); filter: brightness(0.9); box-shadow: 0 4px 10px rgba(24, 119, 242, 0.25); }
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 13px;
  color: var(--color-muted);
}
.form-control {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 15px;
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-control:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}
/* A plain <input type="color"> inheriting .form-control's generous
   text-input padding (10px 12px) squishes the browser's own color swatch
   down to a thin sliver, making it unclear it's even a color picker or
   what's currently selected (seen in the Layer style / Notes style
   modals). Match the already-established look used elsewhere
   (.theme-grid-row input[type="color"]) instead: a proper, clearly
   visible swatch block. */
.form-control[type="color"] {
  width: 64px;
  height: 38px;
  padding: 3px;
  cursor: pointer;
}
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 22px;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 16px;
}
.alert-error { background: #fdecec; color: #a02525; border: 1px solid #f3c6c6; }
.alert-success { background: #e9f7ef; color: #1d7a45; border: 1px solid #bfe8d0; }
.alert-info { background: #eaf2fe; color: #1e4e8c; border: 1px solid #c6d9f3; }
html[data-theme="dark"] .alert-error { background: rgba(241, 99, 104, 0.14); color: #ff9a9d; border-color: rgba(241, 99, 104, 0.3); }
html[data-theme="dark"] .alert-success { background: rgba(62, 207, 142, 0.14); color: #7fe6b8; border-color: rgba(62, 207, 142, 0.3); }
html[data-theme="dark"] .alert-info { background: rgba(58, 130, 224, 0.14); color: #8bb8f5; border-color: rgba(58, 130, 224, 0.3); }

.view-as-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ---------------------------------------------------------------------
   Tables
   --------------------------------------------------------------------- */
table.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data-table th, table.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
  vertical-align: middle;
}
table.data-table th { color: var(--color-muted); font-weight: 600; font-size: 13px; }
table.data-table tr:hover td { background: var(--color-surface-alt); }
.table-responsive { overflow-x: auto; }
.text-right { text-align: right; }

/* In dark mode, --color-border (#2a3140) has very low contrast against
   --color-surface (#171d29), making the row/header divider lines in
   every data table nearly invisible. Use a light/white line instead,
   specifically for tables, in dark mode only - scoped to table.data-table
   (present on every app table whether or not DataTables has enhanced it)
   rather than changing --color-border itself, which is also used by
   cards/inputs/sidebars elsewhere and should stay subtle there. */
html[data-theme="dark"] table.data-table th,
html[data-theme="dark"] table.data-table td {
  border-bottom-color: rgba(255, 255, 255, 0.22);
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-admin { background: #fde6cf; color: #93540c; }
.badge-user { background: #e4e9f0; color: #45505e; }
.badge-active { background: #e9f7ef; color: #1d7a45; }
.badge-inactive { background: #f0f0f0; color: #8a8a8a; }
html[data-theme="dark"] .badge-admin { background: rgba(253, 176, 88, 0.18); color: #f5b862; }
html[data-theme="dark"] .badge-user { background: rgba(180, 190, 205, 0.14); color: #b7c0cd; }
html[data-theme="dark"] .badge-active { background: rgba(62, 207, 142, 0.16); color: #7fe6b8; }
html[data-theme="dark"] .badge-inactive { background: rgba(140, 148, 160, 0.16); color: #9aa3af; }

.app-modal-backdrop {
  position: fixed; inset: 0; background: rgba(10, 14, 20, 0.6);
  display: flex; align-items: center; justify-content: center; z-index: 2000; padding: 16px;
}
/* Default modal size. A dialog gets at least half the width and most of
   the height of the screen, so a form is not read through a letterbox -
   :not() exempts every variant that states its own size (.modal-compact,
   .modal-wide, .modal-80, .modal-90), which keep exactly what they ask
   for. The minimums are dropped on a small screen, where "half the width"
   is meaningless and the modal should simply fill it. */
.app-modal {
  background: var(--color-surface); border-radius: var(--radius-lg); padding: 24px; width: 100%; max-width: 460px;
  box-shadow: var(--shadow-lg); max-height: calc(100vh - 32px); overflow-y: auto;
}
@media (min-width: 801px) {
  .app-modal:not(.modal-compact):not(.modal-wide):not(.modal-80):not(.modal-90) {
    min-width: 50vw;
    max-width: 50vw;
    min-height: 80vh;
    /* Content shorter than the box should sit at the top, not be
       stretched down it. */
    display: flex;
    flex-direction: column;
  }
  /* Whatever the content ends up being, the buttons stay at the bottom
     of the taller box rather than floating in the middle of it. */
  .app-modal:not(.modal-compact):not(.modal-wide):not(.modal-80):not(.modal-90) > .modal-actions,
  .app-modal:not(.modal-compact):not(.modal-wide):not(.modal-80):not(.modal-90) > form > .modal-actions {
    margin-top: auto;
  }
  .app-modal:not(.modal-compact):not(.modal-wide):not(.modal-80):not(.modal-90) > form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
  }
}
.app-modal h3 { margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* Legend editor's static text fields (label/value pairs - see
   openLegendEditor() in report_legends.js, also reused by report_edit.js's
   own "Manage legends" shortcut). */
.legend-static-field-row { display: flex; gap: 6px; margin-bottom: 4px; }
.legend-static-field-row input { flex: 1; }

/* Compact variant for small option-only modals (e.g. "Layer style" - see
   openStyleModal() in map_viewer.js) that would otherwise look sparse/
   oversized with the default modal's generous width and each field
   stacked (label above input) with a full 16px gap - here every field is
   one tight label-left/control-right row instead, and the modal itself
   is narrower and less padded. */
.modal-compact { max-width: 320px; padding: 18px 20px; }
.modal-compact h3 { margin-bottom: 12px; }
.modal-compact .form-group {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px;
}
.modal-compact .form-group label { margin-bottom: 0; flex-shrink: 0; }
.modal-compact .form-group input[type="number"] { width: 80px; flex: 0 0 auto; }
.modal-compact .form-group input[type="color"] { flex: 0 0 auto; }
.modal-compact .form-group select.form-control { width: auto; flex: 1; min-width: 0; }
.modal-compact .modal-actions { margin-top: 16px; }
/* The "Classify by column" section has a label + select + button all in
   one form-group (more than the simple label/single-control rows above
   are designed for) - keep it as a normal stacked block instead of a
   compact row, so the button never gets squeezed/overflows. */
.modal-compact #categorizeSection .form-group { display: block; }
.modal-compact #categorizeSection .form-group label { display: block; margin-bottom: 4px; }
.modal-compact #categorizeSection select.form-control { width: auto; }

/* Wide variant for data-heavy modals (e.g. the attribute table - see
   openAttributeTableForLayers() in map_viewer.js), which also makes its
   own title bar a drag handle (see makeModalDraggable()) so the modal can
   be moved out of the way of the map underneath instead of always
   sitting fixed dead-center. */
.modal-wide { max-width: 900px; padding: 16px 20px; }
.modal-wide h3 { margin-bottom: 10px; cursor: move; user-select: none; }

/* "Show coordinates" modal (Attribute Table page's per-row Actions button
   - see openCoordinatesModal() in attribute_table.js). Sized in vw/vh
   (viewport-relative), NOT a fixed max-width like the other modal
   variants above, so it scales with the browser window: a left ~40%
   column with the raw coordinate list + a Copy button, and a right
   column with a small read-only Leaflet map of the same geometry. */
.modal-coords { width: 92vw; max-width: 92vw; height: 85vh; padding: 0; display: flex; flex-direction: column; }
.modal-coords-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 18px; border-bottom: 1px solid var(--color-border); flex-shrink: 0;
}
.modal-coords-header h3 { margin: 0; font-size: 16px; }
.modal-coords-body { flex: 1; display: flex; min-height: 0; }
.modal-coords-left {
  width: 40%; flex: 0 0 40%; max-width: 40%; min-width: 0;
  display: flex; flex-direction: column; padding: 14px 18px; border-right: 1px solid var(--color-border);
}
.modal-coords-left-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; flex-shrink: 0; }
.modal-coords-text {
  flex: 1; margin: 0; overflow: auto; white-space: pre; font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 12px; line-height: 1.6; background: var(--color-surface-alt); border-radius: var(--radius); padding: 10px;
}
.modal-coords-right { flex: 1; min-width: 0; padding: 14px 18px; }
.modal-coords-map { width: 100%; height: 100%; border-radius: var(--radius); overflow: hidden; }

/* Large variant sized to 80% of the viewport in both dimensions (not a
   fixed max-width like .modal-wide) - for content that can get long/tall
   regardless of window size, e.g. the release "Compare..." diff (see
   runCompare() in releases.js). Title/notes and the action bar stay
   pinned; only the middle ".modal-80-body" wrapper scrolls. */
.modal-80 { width: 80vw; max-width: 80vw; height: 80vh; max-height: 80vh; padding: 20px 24px; display: flex; flex-direction: column; }
.modal-80 h3, .modal-80 > p { flex-shrink: 0; }
.modal-80 .modal-80-body { flex: 1; min-height: 0; overflow-y: auto; }

.modal-80 .modal-actions { flex-shrink: 0; }
.modal-80 .file-change-list { max-height: none; }
