/* ===========================
   Variables y reset
=========================== */
:root {
  --rojo: #c0392b;
  --negro: #222222;
  --blanco: #ffffff;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: Arial, sans-serif;
  background: #f4f4f4;
  color: var(--negro);
  font-size: 16px;
  padding-top: 110px; /* espacio para topbar + menú en escritorio */
}

/* Enlaces generales */
a {
  color: var(--rojo);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ===========================
   LOGIN
=========================== */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--negro), var(--rojo));
  padding: 15px; /* margen interno para móviles */
  padding-top: 0; /* anula el padding-top general del body en la pantalla de login */
}

.login-box {
  background: var(--blanco);
  padding: 20px 25px;
  border-radius: 8px;
  width: 320px;
  max-width: 100%; /* que no se salga en pantallas pequeñas */
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.login-box h1 {
  text-align: center;
  color: var(--rojo);
  margin-bottom: 15px;
}

.login-box input {
  width: 100%;
  padding: 8px;
  margin-bottom: 10px;
  border-radius: 4px;
  border: 1px solid #ccc;
}

.login-box button {
  width: 100%;
  padding: 10px;
  background: var(--rojo);
  color: var(--blanco);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
}

.login-box button:hover {
  background: #a6291d;
}

.alerta.error {
  background: #ffdddd;
  color: #900;
  padding: 6px 8px;
  margin-bottom: 10px;
  border-left: 4px solid #900;
}

/* ===========================
   LAYOUT GENERAL
=========================== */
/* Nav genérico (por si lo usas en alguna otra vista) */
nav {
  background: var(--rojo);
  padding: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

nav a {
  color: var(--blanco);
  text-decoration: none;
  margin-right: 10px;
  font-weight: bold;
  white-space: nowrap;
}

nav a:hover {
  text-decoration: underline;
}

.contenedor {
  max-width: 1100px;
  margin: 15px auto;
  padding: 0 10px;
}

/* ===========================
   CARDS / BLOQUES
=========================== */
.card {
  background: var(--blanco);
  padding: 12px 15px;
  margin-bottom: 10px;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.card h3 {
  margin-bottom: 8px;
  border-bottom: 2px solid var(--rojo);
  display: inline-block;
  padding-bottom: 3px;
  color: var(--rojo);
}

/* ===========================
   FORMULARIOS / CAMPOS
=========================== */
label {
  display: block;
  margin-top: 5px;
  margin-bottom: 3px;
  font-size: 14px;
  color: var(--negro);
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="file"],
textarea,
select {
  width: 100%;
  padding: 6px;
  border-radius: 4px;
  border: 1px solid #ccc;
  font-size: 14px;
}

textarea {
  resize: vertical;
}

/* Botones principales */
.btn-principal {
  background: var(--rojo);
  color: var(--blanco);
  border: none;
  padding: 10px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
  margin-top: 10px;
  display: inline-block;
}

.btn-principal:hover {
  background: #a6291d;
}

/* Botones secundarios (grises) */
.btn-secundario {
  background: #777;
  color: var(--blanco);
  border: none;
  padding: 8px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
  margin-top: 10px;
  display: inline-block;
}
.btn-secundario:hover {
  background: #555;
}

/* ===========================
   GRID (formularios en columnas)
=========================== */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

/* Checkboxes en línea (para tipos de trámite, etc.) */
.chk-linea {
  display: flex;
  align-items: center;
  margin-bottom: 5px;
  font-size: 14px;
}

.chk-linea input[type="checkbox"] {
  margin-right: 6px;
}

.chk-linea .input-valor {
  width: 120px;
  margin-left: auto;
}

/* ===========================
   TABLAS
=========================== */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table th, table td {
  padding: 6px 4px;
  border: 1px solid #ddd;
}

table th {
  background: var(--negro);
  color: var(--blanco);
}

/* Estados de trámite */
.estado-en-curso {
  color: #d35400;
  font-weight: bold;
}
.estado-terminado {
  color: #27ae60;
  font-weight: bold;
}
.estado-pendiente-documentación {
  color: #f1c40f;
  font-weight: bold;
}
.estado-rechazado {
  color: #e74c3c;
  font-weight: bold;
}

/* Contenedor auxiliar para tablas grandes */
.tabla-scroll {
  width: 100%;
  overflow-x: auto;
}

/* ===========================
   RESPONSIVE GENERAL
=========================== */

/* Tablets / pantallas medianas */
@media (max-width: 992px) {
  .contenedor {
    max-width: 100%;
  }

  .card {
    padding: 10px 12px;
  }
}

/* Móviles (hasta 768px) */
@media (max-width: 768px) {
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }

  .contenedor {
    padding: 0 8px;
  }

  /* Nav genérico, pero SIN afectar al menú principal de la app */
  nav:not(.main-nav) {
    flex-direction: column;
    align-items: flex-start;
  }

  nav:not(.main-nav) a {
    margin-right: 0;
    margin-bottom: 4px;
  }

  nav:not(.main-nav) a[style*="float:right"] {
    float: none !important;
  }

  table {
    font-size: 12px;
  }
}

/* Móviles pequeños (hasta 480px) */
@media (max-width: 480px) {
  .btn-principal,
  .btn-secundario {
    width: 100%;
    text-align: center;
  }

  .card {
    padding: 8px 10px;
  }

  label {
    font-size: 13px;
  }

  input[type="text"],
  input[type="email"],
  input[type="number"],
  input[type="date"],
  input[type="file"],
  textarea,
  select {
    font-size: 13px;
    padding: 5px;
  }

  table,
  thead,
  tbody,
  th,
  td,
  tr {
    font-size: 11px;
  }
}

/* ===========================
   TABLA MODO "CARDS" VERTICAL
   (para móviles muy estrechos)
=========================== */
@media (max-width: 600px) {
  .tabla-scroll table,
  .tabla-scroll thead,
  .tabla-scroll tbody,
  .tabla-scroll th,
  .tabla-scroll td,
  .tabla-scroll tr {
    display: block;
    width: 100%;
  }

  .tabla-scroll thead {
    display: none;
  }

  .tabla-scroll tr {
    margin-bottom: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: var(--blanco);
    overflow: hidden;
  }

  .tabla-scroll td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    border: none;
    border-bottom: 1px solid #eee;
    font-size: 13px;
  }

  .tabla-scroll td:last-child {
    border-bottom: none;
  }

  .tabla-scroll td::before {
    content: attr(data-label);
    font-weight: bold;
    color: var(--rojo);
    margin-right: 8px;
    text-align: left;
    flex: 0 0 45%;
  }

  .tabla-scroll td span,
  .tabla-scroll td a {
    word-break: break-word;
    text-align: right;
    flex: 1;
  }

  /* En móvil la barra (topbar + menú) es un poco más alta:
     damos más espacio para que no tape contenido */
  body {
    padding-top: 145px; /* súbelo a 150/155 si todavía roza algo */
  }
}

/* ===========================
   TOPBAR ESTILO APP
=========================== */

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--negro);
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

.topbar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px; /* compacto */
  background: var(--negro);
  color: var(--blanco);
}

/* Logo y texto izquierda */
.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-logo-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--rojo);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--blanco);
  font-size: 16px;
}

.topbar-logo-circle i {
  margin: 0;
}

.topbar-logo {
  height: 32px;
  width: auto;
}

.topbar-text h1 {
  font-size: 18px;
  line-height: 1.1;
}

.topbar-subtitle {
  font-size: 11px;
  color: #f1f1f1;
}

/* Usuario / logout derecha */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-size: 12px;
}

.topbar-user span {
  font-weight: bold;
}

.topbar-user small {
  font-size: 11px;
  color: #ddd;
}

.topbar-logout {
  color: var(--blanco);
  background: var(--rojo);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.topbar-logout:hover {
  background: #a6291d;
}

/* NAV con iconos (menú principal de la app) */
.main-nav {
  display: flex;
  flex-direction: row;   /* SIEMPRE horizontal */
  flex-wrap: nowrap;
  overflow-x: auto;
  padding: 3px 8px 4px 8px;
  background: #b52f23;
}

.main-nav::-webkit-scrollbar {
  height: 6px;
}
.main-nav::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.4);
  border-radius: 3px;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  padding: 3px 6px;
  margin-right: 6px;
  color: var(--blanco);
  text-decoration: none;
  font-size: 11px;
}

.nav-item i {
  font-size: 15px;
  margin-bottom: 2px;
}

.nav-item span {
  white-space: nowrap;
}

.nav-item:hover {
  background: rgba(0,0,0,0.2);
  border-radius: 6px;
}

/* Móvil: topbar y menú más compactos, pero HORIZONTALES */
@media (max-width: 600px) {
  .topbar-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .topbar-text h1 {
    font-size: 16px;
  }

  .topbar-subtitle {
    font-size: 10px;
  }

  .topbar-right {
    align-self: stretch;
    justify-content: space-between;
  }

  .topbar-user {
    align-items: flex-start;
  }

  .nav-item {
    min-width: 68px;
    padding: 2px 4px;
    font-size: 10px;
  }

  .nav-item i {
    font-size: 14px;
  }
}
