/* ============================================================
   LatinComp · Portal de operaciones fluviales
   Sistema visual formal: petroleo profundo + teal de rio,
   Archivo (titulos) + IBM Plex Sans (cuerpo), foto de rio como atmosfera.
   ============================================================ */

:root {
  --ink: #0c2a39;        /* petroleo profundo */
  --ink-2: #103a4e;      /* petroleo medio (degrades) */
  --accent: #1c7fa6;     /* teal de rio: unico color interactivo */
  --accent-hover: #15688a;
  --accent-soft: #e8f1f5;

  --surface: #ffffff;
  --veil: #eef2f3;       /* fondo de contenido sobre la foto */
  --text: #13232e;
  --muted: #5c6b76;
  --line: #e2e8ec;

  --danger-bg: #fcebea;
  --danger-text: #9b2420;
  --ok-bg: #e7f3ec;
  --ok-text: #1c6b3c;

  --r-card: 8px;
  --r-input: 6px;
  --shadow-card: 0 1px 2px rgba(12, 42, 57, 0.06), 0 8px 24px rgba(12, 42, 57, 0.08);
  --shadow-float: 0 24px 60px rgba(5, 20, 28, 0.38);

  --font-display: "Archivo", "Segoe UI", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--ink); }
body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  color: var(--text);
  background: transparent;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Fondo fotografico compartido ---------- */
.bg-photo {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: var(--ink) url("/background/background.webp") center / cover no-repeat;
}
.bg-photo::after {
  content: "";
  position: absolute;
  inset: 0;
}
/* Login: scrim petroleo de izquierda a derecha, deja ver el rio a la derecha */
.bg-photo--login::after {
  background: linear-gradient(
    100deg,
    rgba(8, 28, 38, 0.93) 0%,
    rgba(8, 28, 38, 0.78) 34%,
    rgba(8, 28, 38, 0.42) 66%,
    rgba(8, 28, 38, 0.16) 100%
  );
}
/* Dashboard: foto visible con scrim petroleo moderado; las cards blancas resaltan */
.bg-photo--app::after {
  background: linear-gradient(180deg, rgba(8, 28, 38, 0.66) 0%, rgba(8, 28, 38, 0.5) 100%);
}

/* ---------- Marca ---------- */
.brand { display: inline-flex; align-items: center; gap: 12px; }
.brand__emblem { display: inline-flex; flex: none; }
.brand__logo { display: block; height: 40px; width: auto; }
.brand__word {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
  line-height: 1;
}
.brand__divider {
  width: 1px;
  height: 26px;
  background: currentColor;
  opacity: 0.28;
}
.brand__context {
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.brand--on-dark { color: #fff; }
.brand--on-dark .brand__context { color: #a9c3cf; }
.brand--on-light { color: var(--ink); }
.brand--on-light .brand__context { color: var(--muted); }

/* ============================================================
   LOGIN
   ============================================================ */
.login-wrap {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
}
.login-col {
  width: min(500px, 100%);
  margin-left: clamp(20px, 7vw, 104px);
  margin-right: 20px;
  padding: 48px 0;
  color: #e8f1f6;
}
.login-col .brand { margin-bottom: 40px; }

.login-head { margin-bottom: 26px; }
.login-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2rem, 1.3rem + 2vw, 2.7rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0 0 10px;
  color: #ffffff;
}
.login-lede {
  margin: 0;
  max-width: 42ch;
  font-size: 1.02rem;
  color: #bcd2dd;
}

.login-card {
  background: var(--surface);
  color: var(--text);
  border-radius: var(--r-card);
  padding: 28px 28px 30px;
  box-shadow: var(--shadow-float);
}
.login-card__title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 18px;
  color: var(--ink);
}

.login-foot {
  margin-top: 28px;
  font-size: 0.82rem;
  color: #8ba7b3;
}

/* ============================================================
   FORMULARIOS
   ============================================================ */
.form { display: grid; gap: 18px; }
.field { display: grid; gap: 7px; }
.field__label { font-size: 0.82rem; font-weight: 600; color: var(--muted); }
.field__input {
  width: 100%;
  padding: 11px 13px;
  font-family: var(--font-body);
  font-size: 0.98rem;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-input);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field__input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(28, 127, 166, 0.16);
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  font-family: var(--font-body);
  font-size: 0.96rem;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--r-input);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-hover); }
.btn--block { width: 100%; margin-top: 4px; }
.btn--sm { padding: 8px 13px; font-size: 0.85rem; }
.btn__ico { display: inline-flex; align-items: center; font-weight: 700; }
.btn--ghost-light {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.28);
  color: #eaf2f6;
}
.btn--ghost-light:hover { background: rgba(255, 255, 255, 0.1); }
.btn--ghost-light[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
/* Boton secundario sobre fondo claro (p. ej. Cancelar en el modal) */
.btn--ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}
.btn--ghost:hover { background: var(--veil); }
/* Acciones destructivas */
.btn--danger { background: var(--danger-text); color: #fff; }
.btn--danger:hover { background: #8e1c17; }
.btn--ghost-danger {
  background: transparent;
  border-color: #e4bdba;
  color: var(--danger-text);
}
.btn--ghost-danger:hover { background: var(--danger-bg); }

/* ---------- Alertas ---------- */
.alert {
  padding: 11px 14px;
  border-radius: var(--r-input);
  font-size: 0.9rem;
  margin-bottom: 18px;
  border: 1px solid transparent;
}
.alert--error { background: var(--danger-bg); color: var(--danger-text); border-color: #f3cfcd; }
.alert--ok { background: var(--ok-bg); color: var(--ok-text); border-color: #c6e4d1; }

/* ============================================================
   PANTALLAS CENTRADAS (cambio de clave / error)
   ============================================================ */
.auth-wrap { position: relative; z-index: 1; min-height: 100vh; display: grid; place-items: center; padding: 28px; }
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-float);
  padding: 32px 30px;
}
.auth-card .brand { margin-bottom: 22px; }
.auth-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: -0.01em;
  margin: 0 0 6px;
  color: var(--ink);
}
.auth-subtitle { margin: 0 0 22px; color: var(--muted); font-size: 0.95rem; }
.auth-foot { margin-top: 20px; font-size: 0.9rem; }
.error-code {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 700;
  color: var(--ink);
  margin: 6px 0 4px;
}

/* ============================================================
   DASHBOARD
   ============================================================ */
.app-body { min-height: 100vh; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  padding: 14px clamp(16px, 4vw, 40px);
  background: linear-gradient(180deg, var(--ink), var(--ink-2));
  border-bottom: 2px solid var(--accent);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar__right { display: flex; align-items: center; gap: clamp(12px, 2vw, 22px); flex-wrap: wrap; justify-content: flex-end; }
.topbar__user { display: flex; align-items: center; gap: 18px; }
.admin-actions { display: flex; align-items: center; gap: 10px; }
.topbar__user-info { display: grid; text-align: right; line-height: 1.3; }
.topbar__name { font-weight: 600; font-size: 0.92rem; color: #fff; }
.topbar__empresa { font-size: 0.78rem; color: #a9c3cf; }

.container { position: relative; z-index: 1; max-width: 1120px; margin: 0 auto; padding: clamp(28px, 5vw, 48px) clamp(16px, 4vw, 40px) 64px; }
.page-head { margin-bottom: 30px; }
.page-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.5rem, 1.1rem + 1.4vw, 2rem);
  letter-spacing: -0.015em;
  margin: 0 0 6px;
  color: #ffffff;
}
.page-subtitle { margin: 0; color: #c7dae2; }

/* ---------- Grilla de cards ---------- */
.cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 22px;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
}
.card { position: relative; display: flex; }
.card__btn {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 0;
  text-align: left;
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.card__btn:hover {
  border-color: #b9ccd6;
  box-shadow: 0 2px 4px rgba(12, 42, 57, 0.08), 0 16px 36px rgba(12, 42, 57, 0.14);
  transform: translateY(-2px);
}
.card__btn:focus-visible { outline: 3px solid rgba(28, 127, 166, 0.45); outline-offset: 2px; }
.card__btn.is-loading { opacity: 0.6; pointer-events: none; }

.card__media { position: relative; width: 100%; aspect-ratio: 16 / 9; background: var(--accent-soft); }
.card__img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card__placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 2.6rem;
  font-weight: 700;
  color: #9db9c6;
  background: linear-gradient(135deg, #e9f1f5, #dbe8ef);
}

.card__body { padding: 16px 18px 20px; display: grid; gap: 7px; }
.card__title { font-family: var(--font-display); font-size: 1.05rem; font-weight: 600; color: var(--ink); }
.card__desc { font-size: 0.92rem; color: var(--muted); line-height: 1.5; max-width: 42ch; }

/* ---------- Edicion de cards (admin) ---------- */
.card__edit {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  border: 2px solid #fff;
  box-shadow: 0 2px 10px rgba(5, 20, 28, 0.35);
  cursor: pointer;
  z-index: 3;
  transition: background 0.15s, transform 0.12s;
}
.card__edit:hover { background: var(--accent-hover); transform: scale(1.06); }
.card__edit:focus-visible { outline: 3px solid rgba(255, 255, 255, 0.7); outline-offset: 2px; }
body.edit-mode .card__edit { display: inline-flex; }
body.edit-mode .card__btn { box-shadow: 0 0 0 2px rgba(28, 127, 166, 0.4), var(--shadow-card); }

/* ---------- Modal de app (admin) ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal[hidden] { display: none; }
.modal__scrim {
  position: absolute;
  inset: 0;
  background: rgba(8, 28, 38, 0.6);
  backdrop-filter: blur(2px);
}
.modal__panel {
  position: relative;
  width: min(540px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--surface);
  border-radius: 10px;
  box-shadow: var(--shadow-float);
  animation: modalIn 0.16s ease-out;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 22px;
  background: linear-gradient(180deg, var(--ink), var(--ink-2));
  color: #fff;
  border-radius: 10px 10px 0 0;
}
.modal__title { font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; margin: 0; }
.modal__close {
  background: transparent; border: 0; color: #cfe0e8;
  font-size: 1.6rem; line-height: 1; cursor: pointer; padding: 0 4px;
}
.modal__close:hover { color: #fff; }
.modal__form { padding: 22px; display: grid; gap: 16px; }
.modal__actions { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.modal__actions-main { display: flex; gap: 10px; margin-left: auto; }
.modal--sm { z-index: 60; }
.modal--sm .modal__panel { width: min(420px, 100%); }
.confirm__text { margin: 0; color: var(--text); line-height: 1.5; }
.confirm__text strong { color: var(--ink); }

textarea.field__input { resize: vertical; min-height: 74px; font-family: var(--font-body); }
.field__file { font-size: 0.9rem; color: var(--text); }
.field__hint { margin: 6px 0 0; font-size: 0.8rem; color: var(--muted); }

.perms { border: 0; padding: 0; margin: 0; min-width: 0; }
.perms legend { padding: 0; }
.perms__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 8px 14px;
  margin-top: 10px;
}
.perm { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--text); }
.perm input { width: 16px; height: 16px; accent-color: var(--accent); flex: none; }

body.modal-open { overflow: hidden; }

/* ---------- Estado vacio ---------- */
.empty {
  padding: 56px 28px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
}
.empty__title { font-family: var(--font-display); font-size: 1.1rem; font-weight: 600; color: var(--ink); margin: 0 0 6px; }
.empty__hint { color: var(--muted); margin: 0; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 860px) {
  .bg-photo--login::after {
    background: linear-gradient(180deg, rgba(8, 28, 38, 0.82), rgba(8, 28, 38, 0.9));
  }
  .login-wrap { align-items: stretch; }
  .login-col {
    width: min(460px, 100%);
    margin: 0 auto;
    padding: 56px 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
}
@media (max-width: 540px) {
  .topbar { padding: 12px 16px; }
  .brand__context, .brand__divider { display: none; }
  .topbar__user { gap: 12px; }
}

/* ---------- Accesibilidad: movimiento reducido ---------- */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .card__btn:hover { transform: none; }
  .modal__panel { animation: none; }
}
