/* =========================================================
   Muromar - Sistema de Averías | Identidad visual del logo
   Morado #5840B3, Verde #00A738, Amarillo #FBE100, Negro #272727
   (colores extraídos directamente del logo) sobre fondo blanco.
   ========================================================= */
:root {
  --primary: #5840b3;       /* morado del logo ("MUROMAR") */
  --primary-dark: #453092;
  --primary-light: #7a63c9;
  --primary-tint: rgba(88, 64, 179, 0.08);
  --accent: #00a738;        /* verde del logo — usado para hover/éxito */
  --accent-dark: #00822c;
  --accent-tint: rgba(0, 167, 56, 0.10);
  --bg: #ffffff;            /* fondo blanco */
  --surface: #ffffff;
  --text: #1a1a1a;          /* letras negras */
  --muted: #666666;
  --border: #e4e4e4;
  --success: #00a738;
  --warning: #b8860b;
  --danger: #dc3545;
  --info: #1a1a1a;
  --radius: 10px;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.18);
}

* { box-sizing: border-box; }

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', Arial, sans-serif;
}

a { color: var(--primary); }
a:hover { color: var(--accent-dark); }

/* Clases de texto de Bootstrap: quedan atadas a nuestra paleta, no a los
   azules por defecto de Bootstrap (que no cambian solo con --primary). */
.text-primary { color: var(--primary) !important; }
.text-info { color: var(--text) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }

/* ---------- Botones ---------- */
.btn-primary,
.btn-login {
  background-color: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #fff !important;
}
.btn-primary:hover,
.btn-login:hover {
  background-color: var(--accent) !important;
  border-color: var(--accent) !important;
  color: #fff !important;
}
.btn-accent {
  background-color: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-accent:hover {
  background-color: var(--accent-dark);
  border-color: var(--accent-dark);
  color: #fff;
}
.btn-secondary {
  background-color: #fff !important;
  border-color: var(--text) !important;
  color: var(--text) !important;
}
.btn-secondary:hover {
  background-color: var(--accent) !important;
  border-color: var(--accent) !important;
  color: #fff !important;
}
.btn-outline-primary {
  border-color: var(--primary);
  color: var(--primary);
}
.btn-outline-primary:hover {
  background-color: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---------- Login ---------- */
.login-page {
  background:
    linear-gradient(160deg, rgba(20,12,45,0.82) 0%, rgba(88,64,179,0.60) 55%, rgba(15,9,32,0.85) 100%),
    url('../img/login-fondo.jpg') center center / cover no-repeat fixed;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}
.login-box {
  background-color: rgba(255, 255, 255, 0.97);
  padding: 40px 30px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
}
.login-logo {
  display: block;
  max-width: 260px;
  width: 100%;
  height: auto;
  margin: 0 auto 18px;
}
.login-title {
  font-weight: 700;
  color: var(--text);
  text-align: center;
  margin-bottom: 24px;
  font-size: 1rem;
}
.forgot {
  display: block;
  text-align: center;
  margin-top: 10px;
  font-size: 0.9em;
}

/* ---------- Header de app (páginas internas) ---------- */
.app-header {
  background-color: #fff;
  color: var(--text);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.app-header .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 1.1rem;
}
.app-header .brand img {
  height: 42px;
  width: auto;
}
.app-header .user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background-color: var(--primary-tint);
  color: var(--text);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.9rem;
}
.app-header .user-pill img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}
.app-header .btn-header {
  border: 1px solid var(--border);
  color: var(--text);
  background-color: #fff;
}
.app-header .btn-header:hover {
  background-color: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---------- Sidebar ---------- */
.sidebar {
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  width: 250px;
  background-color: #fff;
  color: var(--text);
  border-right: 1px solid var(--border);
  padding-top: 20px;
  overflow-y: auto;
  z-index: 1040;
  transition: transform 0.25s ease;
}
.sidebar .p-3 h4 { font-weight: 700; color: var(--primary); }
.sidebar .nav { list-style: none; padding-left: 0; margin-bottom: 0; } /* mismo motivo que display:block abajo: no depender de Bootstrap */
.sidebar .nav-link {
  display: block; /* explícito: un <a> es inline por defecto; si Bootstrap no
                      carga (CDN caído/bloqueado), sin esto los enlaces se
                      superponen entre sí y roban el toque/clic del vecino. */
  color: var(--text);
  text-decoration: none;
  border-radius: 6px;
  margin: 2px 10px;
  padding: 10px 12px;
  border-left: 3px solid transparent;
}
.sidebar .nav-link:hover,
.sidebar .nav-link.active {
  background-color: var(--accent-tint);
  color: var(--accent-dark);
  border-left-color: var(--accent);
  font-weight: 600;
}
.main-content {
  margin-left: 250px;
  padding: 24px;
}

/* Botones de abrir/cerrar el menú: solo existen visualmente en móvil */
.sidebar-toggle,
.sidebar-close {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background-color: #fff;
  color: var(--text);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}
.sidebar-toggle:hover,
.sidebar-close:hover {
  background-color: var(--accent-tint);
  border-color: var(--accent);
}

/* Fondo oscuro detrás del menú abierto en móvil */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.45);
  z-index: 1035;
}
.sidebar-backdrop.visible { display: block; }

/* Evita que el fondo se desplace mientras el menú móvil está abierto */
body.sidebar-open-lock { overflow: hidden; }

@media (max-width: 768px) {
  /* El sidebar deja de empujar el contenido: se convierte en un panel que
     se desliza por encima, oculto fuera de pantalla hasta que se abre. */
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content { margin-left: 0; }
  .sidebar-toggle,
  .sidebar-close {
    display: inline-flex;
  }
}

/* ---------- Formulario de averías ---------- */
.formulario {
  background-color: var(--surface);
  padding: 30px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.formulario label { font-weight: 600; color: var(--text); }
.formulario select,
.formulario input,
.formulario textarea {
  width: 100%;
  padding: 10px;
  margin-top: 5px;
  margin-bottom: 15px;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: var(--text);
}
.formulario select:focus,
.formulario input:focus,
.formulario textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 0.2rem var(--accent-tint);
}
.formulario textarea { resize: vertical; }
.formulario button {
  background-color: var(--primary);
  color: white;
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
}
.formulario button:hover { background-color: var(--accent); }
.formulario button:disabled { background-color: var(--muted); cursor: not-allowed; }

/* ---------- Tarjetas / KPIs ---------- */
.card { border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); }
.card.shadow, .card.shadow-lg { box-shadow: var(--shadow) !important; }
.kpi-card .card-title { font-size: 0.95rem; color: var(--muted); }
.kpi-card .card-text { font-weight: 700; }

/* ---------- Tablas ---------- */
.table { color: var(--text); }
.table thead.table-primary th {
  background-color: var(--primary);
  color: #fff;
  border-color: var(--primary-dark);
}
.badge-estado {
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}
.badge-estado.ingresado { background-color: #f0f0f0; color: #444444; }
.badge-estado.en-proceso { background-color: var(--primary-tint); color: var(--primary); }
.badge-estado.finalizado { background-color: var(--accent-tint); color: var(--accent-dark); }

/* ---------- Toasts (feedback AJAX) ---------- */
.toast-container-app {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1080;
}

/* ---------- Banner offline ---------- */
#offline-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: var(--danger);
  color: #fff;
  text-align: center;
  padding: 8px;
  font-size: 0.9rem;
  z-index: 1090;
}
#offline-banner.d-none { display: none !important; }

/* El botón "Instalar App" vive dentro del pie de página (.app-footer-pill),
   siempre visible: si el navegador no ofrece instalación automática
   (iOS, ya instalada, etc.) igual responde con instrucciones -- ver
   assets/js/app.js. No necesita reglas propias de visibilidad. */

/* ---------- Modal de confirmación (registrar avería) ---------- */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(20, 20, 20, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1070;
}
.confirm-overlay[hidden] { display: none; }
.confirm-box {
  background-color: #fff;
  border-radius: 16px;
  padding: 36px 30px 28px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.confirm-icono {
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  border-radius: 50%;
  border: 2px solid #c9d6e2;
  color: #7c8fa3;
  font-size: 1.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.confirm-texto {
  color: var(--text);
  font-size: 1rem;
  line-height: 1.5;
  margin-bottom: 26px;
}
.confirm-botones {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}
.confirm-botones button {
  border: none;
  border-radius: 8px;
  padding: 10px 26px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  min-width: 120px;
}
.confirm-botones .btn-confirmar {
  background-color: var(--accent);
  color: #fff;
}
.confirm-botones .btn-confirmar:hover { background-color: var(--accent-dark); }
.confirm-botones .btn-cancelar {
  background-color: #9aa7b5;
  color: #fff;
}
.confirm-botones .btn-cancelar:hover { background-color: #7f8c9a; }

/* ---------- Footer (vanguardista, marca WM Technology) ---------- */
.app-footer {
  position: relative;
  overflow: hidden;
  margin-top: 48px;
  padding: 30px 24px 18px;
  background: linear-gradient(135deg, #150f2e 0%, #241a4a 45%, #0c0818 100%);
  color: #b7b0d6;
  border-top: 3px solid var(--accent);
}
.app-footer-glow {
  position: absolute;
  top: -70px;
  right: -60px;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 167, 56, 0.28), transparent 70%);
  pointer-events: none;
}
.app-footer-glow::after {
  content: '';
  position: absolute;
  bottom: -190px;
  left: -50px;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(88, 64, 179, 0.38), transparent 70%);
}
.app-footer-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  max-width: 1100px;
  margin: 0 auto;
}
.app-footer-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.app-footer-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: #fff;
  font-size: 1.25rem;
  box-shadow: 0 6px 16px rgba(0, 167, 56, 0.28);
}
.app-footer-brand strong { display: block; color: #fff; font-size: 1.05rem; }
.app-footer-tagline { display: block; font-size: 0.8rem; color: #8f88ad; }

.app-footer-status {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.app-footer-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #d7d2ee;
  white-space: nowrap;
}
button.app-footer-pill {
  font-family: inherit;
  line-height: 1;
}
.app-footer-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}
.app-footer-pill--offline .app-footer-dot {
  background: var(--danger);
  box-shadow: 0 0 8px var(--danger);
}
.app-footer-pill--muted { color: #a29ac2; }
.app-footer-pill--action {
  cursor: pointer;
  border-color: rgba(0, 167, 56, 0.4);
  background: rgba(0, 167, 56, 0.14);
  color: #7be89b;
  transition: background-color 0.2s ease, transform 0.15s ease;
}
.app-footer-pill--action:hover { background: rgba(0, 167, 56, 0.24); transform: translateY(-1px); }
.app-footer-pill--done {
  color: #7be89b;
  border-color: rgba(0, 167, 56, 0.4);
  cursor: default;
  transform: none !important;
}

.app-footer-bottom {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 22px auto 0;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  font-size: 0.82rem;
  text-align: center;
  color: #918aac;
}
.app-footer-divider { opacity: 0.4; }
.app-footer-brandlink {
  font-weight: 700;
  background: linear-gradient(135deg, #38bdf8 0%, #818cf8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.app-footer-brandlink:hover { filter: brightness(1.25); }
.app-footer-version {
  font-family: 'Courier New', monospace;
  color: #6f6890;
}

@media (max-width: 576px) {
  .app-footer-inner { flex-direction: column; text-align: center; }
  .app-footer-status { justify-content: center; }
}

/* ---------- Toast de actualización de la PWA ---------- */
#toast-container .btn-light { font-weight: 600; }

/* ---------- Responsividad general ---------- */
@media (max-width: 576px) {
  .login-box { padding: 30px 20px; }
}
