/* ============================================================================
   Centro de Notificaciones · Réplica local con la identidad visual de Vector GPS
   Estructura y medidas: réplica original (replicador-web-integral/notificaciones)
   Colores y componentes: GUIA_ESTILOS_UI.md
   ============================================================================ */

:root {
  --v-primary: #0f8995;
  --v-primary-border: #0d7d88;
  --v-primary-dark: #0a6670;
  --v-primary-tint: #e6f4f5;
  --v-primary-ring: rgba(15, 137, 149, .18);
  --v-info: #2196f3;
  --v-success: #28a745;
  --v-warning: #ff9800;
  --v-danger: #dc3545;

  --v-page: #eef2f5;
  --v-surface: #ffffff;
  --v-carbon: #343a40;
  --v-text: #26313d;
  --v-title: #1f2a35;
  --v-muted: #607080;
  --v-label: #485664;
  --v-th-bg: #f4f7f9;
  --v-input-bg: #f9fbfc;
  --v-input-border: #bfcbd6;
  --v-border: #cfd9e2;
  --v-border-soft: #e1e8ee;

  --v-map: #e9eef1;
  --v-road: #ffffff;
  --v-water: #cfe3ec;
  --v-satellite: #55634f;
  --v-satellite-line: #475443;

  --v-shadow-card: 0 3px 12px rgba(31, 45, 61, .08);
  --v-shadow-pop: 0 12px 24px rgba(26, 36, 44, .22);
}

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  font: 13px/1.45 Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  color: var(--v-text);
  background: var(--v-page);
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------------------------------------------------------------------------
   Controles
   --------------------------------------------------------------------------- */

button, input, select {
  min-height: 30px;
  font: inherit;
  color: inherit;
  background: var(--v-surface);
  border: 1px solid var(--v-input-border);
  border-radius: 6px;
}

button {
  padding: 3px 12px;
  font-weight: 600;
  color: var(--v-label);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

button:hover:not(:disabled) {
  color: var(--v-primary);
  border-color: var(--v-primary);
  background: var(--v-primary-tint);
}

button:disabled { opacity: .45; cursor: not-allowed; }

input:not([type="checkbox"]):not([type="radio"]),
select {
  padding: 5px 9px;
  background: var(--v-input-bg);
}

input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus {
  outline: none;
  border-color: var(--v-primary);
  box-shadow: 0 0 0 3px var(--v-primary-ring);
}

button:focus-visible, [role="row"]:focus-visible, .map-action:focus-visible, .map-surface:focus-visible {
  outline: 2px solid var(--v-primary);
  outline-offset: 1px;
}

input[type="checkbox"], input[type="radio"] {
  min-height: auto;
  accent-color: var(--v-primary);
}

/* ---------------------------------------------------------------------------
   Barra de título
   --------------------------------------------------------------------------- */

.notifications-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 65px;
  padding: 0 20px;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  background: var(--v-carbon);
  border-bottom: 5px solid var(--v-primary);
}

.connection { display: inline-block; font-size: 18px; color: #ff6b6b; }
.connection.connected { color: #4cd964; }
.connection.connecting { color: #ffc107; outline: 1px dashed rgba(255, 255, 255, .5); outline-offset: 2px; }

/* ---------------------------------------------------------------------------
   Estructura
   --------------------------------------------------------------------------- */

.workspace {
  display: grid;
  grid-template-columns: 5fr 7fr;
  width: 100%;
  height: calc(100vh - 65px);
}

.alerts-pane {
  position: relative;
  min-width: 0;
  height: 100%;
  background: var(--v-surface);
}

/* ---------------------------------------------------------------------------
   Filtros
   --------------------------------------------------------------------------- */

.filter-accordion {
  height: 165px;
  border-bottom: 1px solid var(--v-border);
}

.collapse-trigger {
  width: 100%;
  height: 35px;
  padding-right: 40px;
  font-size: 18px;
  text-align: right;
  color: var(--v-muted);
  background: var(--v-th-bg);
  border: 0;
  border-bottom: 1px solid var(--v-border);
  border-radius: 0;
}

.filter-panel {
  position: relative;
  display: grid;
  grid-template-columns: repeat(6, calc((100% + 15px) / 6));
  align-items: start;
  height: 130px;
  padding: 15px 0 10px 15px;
  gap: 0;
}

.filter-field { position: relative; min-width: 0; }

.filter-field label,
.sound-filter > label:first-child {
  display: block;
  width: 55px;
  min-height: 20px;
  font-size: 12px;
  font-weight: 700;
  line-height: 20px;
  color: var(--v-label);
}

.multi-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 54px;
  height: 34px;
  margin-top: 4px;
  padding: 2px 5px;
  overflow: hidden;
  font-size: 12px;
  white-space: nowrap;
}

.multi-menu {
  position: absolute;
  z-index: 30;
  top: 58px;
  left: 0;
  width: 240px;
  max-height: calc(100vh - 190px);
  padding: 6px;
  overflow: auto;
  background: var(--v-surface);
  border: 1px solid var(--v-border);
  border-radius: 8px;
  box-shadow: var(--v-shadow-pop);
}

.menu-actions { display: flex; gap: 4px; padding-bottom: 6px; }
.menu-actions button { flex: 1; min-height: 26px; font-size: 11px; padding: 2px 6px; }

.multi-option {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 4px 6px;
  font-size: 12px;
  border-top: 1px solid var(--v-border-soft);
  border-radius: 4px;
  cursor: pointer;
}
.multi-option:hover { background: var(--v-primary-tint); }

.sound-filter { position: absolute; left: 72.7%; top: 15px; min-width: 0; }

.sound-toggle {
  position: relative;
  display: grid !important;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  width: 62px !important;
  height: 24px !important;
  margin-top: 4px;
  overflow: hidden;
  font-size: 11px;
  font-weight: 600 !important;
  border: 1px solid var(--v-input-border);
  border-radius: 6px;
}
.sound-toggle input { position: absolute; opacity: 0; }
.sound-option { display: grid; place-items: center; width: 100%; height: 100%; color: var(--v-muted); background: var(--v-surface); }
.sound-toggle input:checked ~ .sound-on { color: #fff; background: var(--v-primary); }
.sound-toggle input:not(:checked) ~ .sound-off { color: #fff; background: var(--v-muted); }
.sound-toggle:has(input:focus-visible) { outline: 2px solid var(--v-primary); outline-offset: 1px; }

.filter-button {
  position: absolute;
  left: 72.7%;
  top: 61px;
  width: 62px;
  height: 34px;
  color: #fff;
  background: var(--v-primary);
  border-color: var(--v-primary-border);
}
.filter-button:hover:not(:disabled) { color: #fff; background: var(--v-primary-dark); border-color: var(--v-primary-dark); }

/* ---------------------------------------------------------------------------
   Tabla de alertas
   --------------------------------------------------------------------------- */

.table-shell {
  position: absolute;
  top: 185px;
  left: 15px;
  width: calc(100% - 30px);
  height: calc(100vh - 270px);
  min-height: 250px;
  overflow: hidden;
  background: var(--v-surface);
  border: 1px solid var(--v-border);
  border-radius: 8px;
  box-shadow: var(--v-shadow-card);
}

.search-row { height: 51px; padding: 8px; }
.search-row input {
  width: 100%;
  height: 34px;
  padding: 6px 9px 6px 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%23607080' stroke-width='2.2' stroke-linecap='round' d='M11 4a7 7 0 1 0 0 14 7 7 0 0 0 0-14zm9 16-4.2-4.2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 9px center;
  background-size: 16px;
}

.table-head, .alert-row {
  display: grid;
  grid-template-columns: 12% 21% 20% 15% 19% 13%;
  width: 100%;
}

.table-head {
  height: 35px;
  font-size: 11.5px;
  font-weight: 800;
  color: #536171;
  background: var(--v-th-bg);
  border-top: 1px solid var(--v-border-soft);
  border-bottom: 2px solid var(--v-border);
}

.table-head > * {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  font-size: 11.5px;
  font-weight: 800;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: 0;
}
.table-head > button:hover:not(:disabled) { color: var(--v-primary); background: rgba(15, 137, 149, .08); }

.sort-button::after { content: ""; }
.sort-button[data-direction="asc"]::after { content: " ▲"; color: var(--v-primary); font-size: 9px; }
.sort-button[data-direction="desc"]::after { content: " ▼"; color: var(--v-primary); font-size: 9px; }

.table-body {
  width: 102%;
  height: calc(100vh - 357px);
  min-height: 164px;
  overflow-x: hidden;
  overflow-y: auto;
}

.alert-row {
  min-height: 64px;
  align-items: stretch;
  font-size: 11.5px;
  color: var(--v-text);
  background: var(--v-surface);
  border-bottom: 1px solid var(--v-border-soft);
  cursor: pointer;
  transition: background 120ms ease;
}
.alert-row:nth-child(even) { background: #fafcfd; }
.alert-row:hover { background: rgba(15, 137, 149, .07); }
.alert-row.selected {
  background: var(--v-primary-tint);
  box-shadow: inset 4px 0 0 var(--v-primary);
}

.alert-cell { display: flex; align-items: flex-start; padding: 11px 7px; overflow-wrap: anywhere; line-height: 17px; }
.alert-icon { align-items: flex-start; justify-content: center; padding-top: 10px; }
.alert-icon span {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  font-size: 11px;
  font-weight: 700;
  border: 2px solid currentColor;
  border-radius: 50%;
}
.severity-high { color: var(--v-danger); }
.severity-medium { color: var(--v-warning); }
.severity-low { color: var(--v-info); }

.alert-actions { justify-content: center; }
.attend-button {
  width: 26px;
  height: 24px;
  min-height: 24px;
  padding: 0;
  font-weight: 700;
  color: var(--v-primary);
  background: var(--v-surface);
  border-color: var(--v-primary);
}

/* ---------------------------------------------------------------------------
   Mapa
   --------------------------------------------------------------------------- */

.map-pane {
  --map-scale: 1;
  --map-x: 0px;
  --map-y: 0px;
  position: relative;
  height: calc(100vh - 85px);
  overflow: hidden;
  background: var(--v-map);
  border-left: 1px solid var(--v-border);
}

.map-surface {
  position: absolute;
  inset: -12%;
  transform: translate(var(--map-x), var(--map-y)) scale(var(--map-scale));
  transform-origin: center;
  cursor: grab;
}
.map-surface.dragging { cursor: grabbing; }

.map-grid {
  position: absolute;
  inset: 0;
  background-color: var(--v-map);
  background-image:
    linear-gradient(32deg, transparent 47%, var(--v-road) 48%, var(--v-road) 51%, transparent 52%),
    linear-gradient(92deg, transparent 48%, var(--v-road) 49%, var(--v-road) 51%, transparent 52%),
    linear-gradient(152deg, transparent 48%, var(--v-water) 49%, var(--v-water) 53%, transparent 54%);
  background-size: 130px 95px, 180px 140px, 260px 220px;
}

.map-pane.satellite .map-grid {
  background-color: var(--v-satellite);
  background-image:
    repeating-linear-gradient(28deg, var(--v-satellite) 0, var(--v-satellite) 18px, var(--v-satellite-line) 19px, var(--v-satellite-line) 22px),
    repeating-linear-gradient(118deg, transparent 0, transparent 35px, rgba(255, 255, 255, .12) 36px, rgba(255, 255, 255, .12) 38px);
}

.map-pane.traffic .map-grid { outline: 3px double var(--v-warning); outline-offset: -16px; }

.map-pane.incidents::after {
  content: "!  !  !";
  position: absolute;
  left: 25%;
  top: 22%;
  z-index: 2;
  font-weight: 700;
  letter-spacing: 70px;
  color: var(--v-danger);
}

.map-label { position: absolute; font-size: 16px; font-weight: 700; letter-spacing: 3px; color: rgba(72, 86, 100, .65); pointer-events: none; }
.label-one { top: 9%; left: 15%; }
.label-two { top: 45%; left: 62%; }

.map-marker { position: absolute; z-index: 3; left: 52%; top: 45%; font-size: 32px; color: var(--v-danger); text-shadow: 0 2px 4px rgba(0, 0, 0, .25); }

.alert-info {
  position: absolute;
  z-index: 8;
  left: 50%;
  top: 43%;
  width: min(460px, 80%);
  max-height: 65%;
  padding: 14px;
  overflow: auto;
  font-size: 12px;
  line-height: 18px;
  transform: translate(-50%, -50%);
  background: var(--v-surface);
  border: 1px solid var(--v-border);
  border-top: 4px solid var(--v-primary);
  border-radius: 8px;
  box-shadow: var(--v-shadow-pop);
}

.info-close { position: absolute; right: 6px; top: 6px; width: 28px; min-height: 26px; padding: 0; font-size: 16px; line-height: 1; }

.info-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--v-border-soft); }
.info-actions button, .map-action {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--v-label);
  text-decoration: none;
  background: var(--v-surface);
  border: 1px solid var(--v-input-border);
  border-radius: 6px;
}
.map-action:hover { color: var(--v-primary); border-color: var(--v-primary); background: var(--v-primary-tint); }

.command-panel { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--v-border-soft); }
.command-panel label { display: block; margin-bottom: 4px; font-weight: 700; color: var(--v-label); }
.command-panel select { width: 100%; margin-bottom: 6px; }
.command-panel button { margin-right: 4px; }
#sendCommand { color: #fff; background: var(--v-primary); border-color: var(--v-primary-border); }
#sendCommand:hover:not(:disabled) { color: #fff; background: var(--v-primary-dark); border-color: var(--v-primary-dark); }

.map-layer-control {
  position: absolute;
  z-index: 12;
  right: 85px;
  top: 8px;
  display: grid;
  place-items: center;
  width: 30px;
  min-height: 30px;
  height: 30px;
  padding: 0;
  font-size: 18px;
  box-shadow: var(--v-shadow-card);
}

.map-type-menu {
  position: absolute;
  z-index: 11;
  right: 125px;
  top: 16px;
  width: 180px;
  padding: 10px;
  font-size: 12px;
  background: var(--v-surface);
  border: 1px solid var(--v-border);
  border-radius: 8px;
  box-shadow: var(--v-shadow-pop);
}
.map-type-menu strong { display: block; margin-bottom: 6px; font-size: 11px; letter-spacing: .05em; color: var(--v-muted); }
.map-type-menu label { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; cursor: pointer; }

.map-zoom { position: absolute; right: 8px; top: 8px; display: flex; box-shadow: var(--v-shadow-card); border-radius: 6px; }
.map-zoom button { width: 34px; min-height: 30px; height: 30px; padding: 0; font-size: 20px; line-height: 1; }
.map-zoom button:first-child { border-radius: 6px 0 0 6px; }
.map-zoom button:last-child { margin-left: -1px; border-radius: 0 6px 6px 0; }

.map-scale {
  position: absolute;
  right: 8px;
  bottom: 30px;
  min-width: 56px;
  padding: 2px 6px;
  font-size: 11px;
  text-align: center;
  background: var(--v-surface);
  border: 1px solid var(--v-border);
  border-bottom: 2px solid var(--v-carbon);
  border-radius: 4px;
}

.geo-toggle { position: absolute; right: 8px; bottom: 66px; height: 48px; font-weight: 700; box-shadow: var(--v-shadow-card); }
.geo-toggle span { color: var(--v-muted); }
.geo-toggle.on span { color: var(--v-primary); }

.map-attribution {
  position: absolute;
  z-index: 4;
  left: 8px;
  bottom: 30px;
  display: flex;
  gap: 6px;
  max-width: calc(100% - 90px);
  padding: 2px 6px;
  overflow: hidden;
  font-size: 10px;
  white-space: nowrap;
  color: var(--v-muted);
  background: rgba(255, 255, 255, .88);
  border: 1px solid var(--v-border);
  border-radius: 4px;
}
.map-attribution a { color: var(--v-primary); }

.georeference-shape {
  position: absolute;
  left: 30%;
  top: 28%;
  width: 180px;
  height: 130px;
  background: rgba(15, 137, 149, .12);
  border: 3px dashed var(--v-primary);
}

/* ---------------------------------------------------------------------------
   Pie de página
   --------------------------------------------------------------------------- */

.footer {
  position: fixed;
  z-index: 20;
  left: 0;
  right: 0;
  bottom: 0;
  height: 25px;
  padding-top: 5px;
  font-size: 11px;
  text-align: center;
  color: #d7dde3;
  background: var(--v-carbon);
}

/* ---------------------------------------------------------------------------
   Diálogos (cerrados permanecen ocultos: no forzar display fuera de [open])
   --------------------------------------------------------------------------- */

dialog {
  padding: 18px;
  color: var(--v-text);
  background: var(--v-surface);
  border: 1px solid var(--v-border);
  border-top: 4px solid var(--v-primary);
  border-radius: 8px;
  box-shadow: var(--v-shadow-pop);
}
dialog::backdrop { background: rgba(26, 36, 44, .5); }

.attend-dialog { width: 530px; max-width: calc(100vw - 24px); }
.attend-dialog h2 { margin: 0 0 12px; font-size: 16px; font-weight: 700; color: var(--v-title); }
.attend-dialog input { width: 100%; height: 34px; }

.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
#acceptAttend, #closeLocalMessage { color: #fff; background: var(--v-primary); border-color: var(--v-primary-border); }
#acceptAttend:hover:not(:disabled), #closeLocalMessage:hover:not(:disabled) { color: #fff; background: var(--v-primary-dark); border-color: var(--v-primary-dark); }

.message-dialog { max-width: 420px; }
.message-dialog p { margin: 0 0 12px; font-size: 13.5px; }

/* ---------------------------------------------------------------------------
   Responsive (mismos cortes que la réplica original)
   --------------------------------------------------------------------------- */

@media (max-width: 1199px) {
  html, body { overflow: auto; }
  .workspace { display: block; height: auto; }
  .alerts-pane { height: 760px; }
  .map-pane { height: 600px; border-left: 0; border-top: 1px solid var(--v-border); }
  .footer { position: static; }
  .table-shell { height: 555px; }
  .table-body { height: 468px; }
}

@media (max-width: 620px) {
  .notifications-bar { padding-left: 10px; }
  .filter-accordion { height: 305px; }
  .filter-panel { grid-template-columns: repeat(2, 1fr); height: 270px; row-gap: 8px; }
  .table-shell { top: 325px; left: 6px; width: calc(100% - 12px); height: 430px; }
  .table-body { height: 343px; }
  .table-head, .alert-row { grid-template-columns: 10% 22% 20% 18% 20% 10%; }
  .alert-cell { padding: 6px 3px; }
  .map-pane { height: 480px; }
  .alert-info { width: 94%; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* v3: tablas a ancho completo del contenedor */
table { width: 100%; }