/* --- Reinicio Básico y Estilos Globales --- */
:root {
  --color-primario: #ff6600; /* Naranja para acentos y botones */
  --color-fondo: #009dff; /* Azul para el fondo exterior */
  --color-texto: #334155; /* Slate 700 */
  --color-texto-claro: #64748b; /* Slate 500 */
  --color-blanco: #ffffff;
  --color-fondo-tarjeta: #ffffff;
  --color-borde: #cbd5e1; /* Slate 300 */
  --color-fondo-input: #f8fafc; /* Slate 50 */
  --color-error: #ef4444; /* red-500 */
  --sombra: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --ficha-titulo: #ff6501;
  --ficha-info-general: #059af9;
  --ficha-correctivo: #ffc100;
  --ficha-diagnostico: #f4b085;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Inter", sans-serif, -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji",
    "Segoe UI Emoji", "Segoe UI Symbol";
  background-color: var(--color-fondo);
  color: var(--color-texto);
  padding: 1rem;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

/* --- ESTILOS DE LOGIN --- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-container {
  width: 100%;
  max-width: 400px;
  padding: 2.5rem;
  background-color: var(--color-fondo-tarjeta);
  border-radius: 0.75rem;
  box-shadow: var(--sombra);
  text-align: center;
}
.login-logo {
  width: 80%;
  max-width: 12rem;
  margin-bottom: 2rem;
  margin-left: auto;
  margin-right: auto;
}
.login-title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}
.login-subtitle {
  color: var(--color-texto-claro);
  margin-bottom: 2rem;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  text-align: left;
}
.error-message {
  color: var(--color-error);
  font-size: 0.875rem;
  min-height: 1.25rem;
}
#login-button {
  padding: 0.75rem;
}

/* --- ESTILOS DE LA APP PRINCIPAL --- */
.container {
  width: 90%;
  max-width: 1024px;
  margin: auto;
}
.main-header {
  margin-bottom: 1.5rem;
  color: var(--color-blanco);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.main-header h1 {
  font-size: 1.875rem;
  font-weight: 700;
}
#logout-button {
  background-color: transparent;
  border: 1px solid var(--color-blanco);
  color: var(--color-blanco);
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  cursor: pointer;
  font-weight: 600;
  transition: background-color 0.2s, color 0.2s;
}
#logout-button:hover {
  background-color: var(--color-blanco);
  color: var(--color-primario);
}

/* Pestañas */
.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: -1px;
}
.tab-button {
  padding: 0.75rem 1.5rem;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 0.5rem 0.5rem 0 0;
  background-color: #e0f2fe; /* light blue */
  color: var(--color-texto-claro);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.tab-button.active {
  background-color: var(--color-fondo-tarjeta);
  border-color: var(--color-borde);
  color: var(--color-primario);
}

/* Formulario y Tarjetas */
form,
.gestion-header {
  background-color: var(--color-fondo-tarjeta);
  padding: 1.5rem;
  border: 1px solid var(--color-borde);
  border-radius: 0 0.5rem 0.5rem 0.5rem;
  box-shadow: var(--sombra);
}
.gestion-header {
  border-radius: 0.5rem;
  margin-bottom: 1.5rem;
}
.gestion-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}
.gestion-header p {
  color: var(--color-texto-claro);
}

form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
form h2 {
  font-size: 1.25rem;
  font-weight: 600;
  border-bottom: 1px solid var(--color-borde);
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}
.grid-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}
@media (min-width: 768px) {
  .grid-container {
    grid-template-columns: 1fr 1fr;
  }
}
.form-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Estilos de Campos */
label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
}
select,
input[type="text"],
input[type="email"],
input[type="password"],
textarea {
  width: 100%;
  border: 1px solid var(--color-borde);
  border-radius: 0.375rem;
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  padding: 0.75rem 1rem;
  font-size: 0.685rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  height: 3.5rem;
  text-wrap: wrap;
}
select:focus,
input:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-primario);
  box-shadow: 0 0 0 2px var(--color-primario);
}
select:disabled,
input:read-only,
textarea:read-only {
  background-color: #f3f4f6;
  cursor: not-allowed;
  opacity: 0.7;
}
input:read-only,
textarea:read-only {
  border-color: #e5e7eb;
}
textarea {
  resize: vertical;
}

/* Botón de Envío */
.submit-container {
  padding-top: 1.25rem;
  border-top: 1px solid var(--color-borde);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}
button {
  background-color: var(--color-primario);
  color: var(--color-blanco);
  font-weight: 600;
  padding: 0.6rem 1.5rem;
  border: none;
  border-radius: 0.375rem;
  box-shadow: var(--sombra);
  cursor: pointer;
  transition: background-color 0.3s, opacity 0.3s;
}
button:hover {
  opacity: 0.9;
}
button:disabled {
  background-color: #fdba74;
  cursor: not-allowed;
}

.button-secondary {
  background-color: var(--color-fondo-input);
  color: var(--color-texto-claro);
  border: 1px solid var(--color-borde);
}
.button-secondary:hover {
  background-color: #e2e8f0;
} /* slate-200 */

/* Lista de Tareas */
.task-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}
.task-card {
  background-color: var(--color-fondo-tarjeta);
  border-radius: 0.5rem;
  padding: 1.5rem;
  box-shadow: var(--sombra);
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}
.task-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}
.task-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}
.task-card-title {
  font-size: 1.25rem;
  font-weight: 700;
}
.task-card-status {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  color: var(--color-blanco);
}
.task-card-status.Creado,
.task-card-status.Asignado {
  background-color: #3b82f6;
} /* blue-500 */
.task-card-status.Realizado,
.task-card-status.Completado {
  background-color: #22c55e;
} /* green-500 */
.task-card-status.NUEVO {
  background-color: #a855f7;
} /* purple-500 */
.task-card-body {
  flex-grow: 1;
  color: var(--color-texto-claro);
  font-size: 0.875rem;
}
.task-card-body p {
  margin-bottom: 0.5rem;
}
.task-card-body strong {
  color: var(--color-texto);
  font-weight: 600;
}
.task-card-footer {
  margin-top: 1.5rem;
  border-top: 1px solid var(--color-borde);
  padding-top: 1rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}
.task-card-button {
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
}
.task-card-button.edit {
  background-color: #3b82f6;
}
.task-card-button.edit:hover {
  background-color: #2563eb;
}
.task-card-button.delete {
  background-color: var(--color-error);
}
.task-card-button.delete:hover {
  background-color: #dc2626;
}

/* --- ¡NUEVOS ESTILOS PARA LA FICHA DE INFORME! --- */
.ficha-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background-color: var(--color-fondo-tarjeta);
  border-radius: 0.5rem;
  box-shadow: var(--sombra);
}

.ficha-mantenimiento {
  background-color: var(--color-blanco);
  padding: 2.5rem;
  border-radius: 0.5rem;
  box-shadow: var(--sombra);
  font-size: 12px;
  color: #000;
}

.ficha-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #000;
  padding-bottom: 1rem;
  margin-bottom: 1rem;
}
.ficha-logo {
  height: 50px;
}
.ficha-logo-cnel {
  height: 7.5rem;
}
.ficha-title-container {
  text-align: center;
}
.ficha-title {
  font-size: 1.5rem;
  font-weight: 700;
}
.ficha-subtitle {
  font-size: 0.8rem;
}

.ficha-section {
  border: 1px solid #000;
  margin-top: 0 !important;
}
.ficha-section h3 {
  background-color: #d9d9d9;
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
  font-weight: 700;
  border-bottom: 1px solid #000;
  text-align: center;
}
.ficha-section h4 {
  padding: 0.25rem 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
}
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 0.5rem;
}
.info-item {
  padding: 0.25rem;
  display: flex;
  gap: 0.5rem;
}
.info-item.full-width {
  grid-column: span 2;
}
.info-item label {
  font-weight: 700;
  margin-bottom: 0;
  font-size: 0.75rem;
}
.info-item span {
  border-bottom: 1px dotted #000;
  flex-grow: 1;
}

.actividades-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background-color: #000;
  border-top: 1px solid #000;
}
.actividades-col {
  background-color: var(--color-blanco);
  padding: 0.5rem;
}
.actividades-col textarea {
  width: 100%;
  margin-top: 0.5rem;
  font-size: 11px;
  border: 1px solid #ccc;
  padding: 0.25rem;
}
.actividades-table td,
.actividades-table th {
  padding: 0.35rem 0.5rem; /* Ajusta el padding */
  border: 1px solid #000; /* Borde negro para celdas */
  vertical-align: top; /* Alinea el texto arriba */
}

/* --- Estilos para tablas Preventivo/Correctivo (4 columnas) --- */
#tabla-preventivo td:nth-child(1),
#tabla-preventivo th:nth-child(1),
#tabla-correctivo td:nth-child(1),
#tabla-correctivo th:nth-child(1) {
  width: 20px;
  text-align: center;
}
#tabla-preventivo td:nth-child(2),
#tabla-preventivo th:nth-child(2),
#tabla-correctivo td:nth-child(2),
#tabla-correctivo th:nth-child(2) {
  width: 65%; /* Más ancho para la tarea */
  white-space: normal; /* ¡PERMITE EL TEXT-WRAP! */
  word-break: break-word; /* Rompe palabras largas */
}
#tabla-preventivo td:nth-child(3),
#tabla-preventivo th:nth-child(3),
#tabla-correctivo td:nth-child(3),
#tabla-correctivo th:nth-child(3) {
  width: 30px;
  text-align: center;
  font-weight: bold; /* ¡X EN NEGRITA! */
}
#tabla-preventivo td:nth-child(4),
#tabla-preventivo th:nth-child(4),
#tabla-correctivo td:nth-child(4),
#tabla-correctivo th:nth-child(4) {
  width: auto; /* Resto del espacio para Observación */
}

/* --- Estilos para tabla Diagnóstico (6 columnas) --- */
.diagnostico-table td,
.diagnostico-table th {
  vertical-align: middle;
}
.diagnostico-table td:nth-child(1), .diagnostico-table th:nth-child(1), /* # Izq */
.diagnostico-table td:nth-child(4), .diagnostico-table th:nth-child(4) {
  /* # Der */
  width: 20px;
  text-align: center;
}
.diagnostico-table td:nth-child(2), .diagnostico-table th:nth-child(2), /* Tarea Izq */
.diagnostico-table td:nth-child(5), .diagnostico-table th:nth-child(5) {
  /* Tarea Der */
  width: auto;
  white-space: normal;
  word-break: break-word;
}
.diagnostico-table td:nth-child(3), .diagnostico-table th:nth-child(3), /* X Izq */
.diagnostico-table td:nth-child(6), .diagnostico-table th:nth-child(6) {
  /* X Der */
  width: 30px;
  text-align: center;
  font-weight: bold; /* ¡X EN NEGRITA! */
}

.actividades-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  border: 1px solid #000;
  background-color: white;
  margin-top: -1px;
}
.actividades-table thead {
  background-color: #d9d9d9;
  font-weight: bold;
  text-align: center; /* Centra cabeceras */
}

.fotos-grid {
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr); /* 3 columnas */
  grid-template-rows: repeat(2, auto); /* 2 filas */
  gap: 0;
  border-top: 1px solid #000;
  background-color: #000;
  overflow: hidden;
  margin: 0;
}

.foto-item {
  border: 1px solid #000;
  background-color: #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 9 / 16;
  overflow: hidden;
  font-size: 10px;
  color: #999;
}

.foto-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.no-fotos {
  color: var(--color-texto-claro);
  padding: 1rem;
  text-align: center;
  width: 100%;
}

/* --- ESTILOS PARA PDF MULTI-PÁGINA --- */

.pdf-page {
  border: 1px dashed var(--color-borde);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  background: #fdfdfd; /* Un fondo ligeramente diferente para ver los límites */

  /* Simula un "salto de página" */
  page-break-after: always;
}

.pdf-footer {
  text-align: right;
  font-size: 0.8rem;
  color: var(--color-texto-claro);
  margin-top: 1rem;
  border-top: 1px solid var(--color-borde);
  padding-top: 0.5rem;
}

label.obs-label {
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.5rem 0 0.5rem 0.5rem;
  display: block;
}

/* --- ESTILOS PARA SECCIÓN DE FIRMAS --- */
.firmas-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  padding: 2rem;
  min-height: 250px;
}

.firma-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.firma-imagen {
  border: 1px solid var(--color-borde);
  width: 100%;
  height: 150px;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-texto-claro);
  font-style: italic;
}

.firma-box label {
  font-weight: 700;
  font-size: 0.9rem;
  border-top: 1px solid #000;
  padding-top: 0.5rem;
  width: 90%;
}

.firma-box span {
  font-size: 0.8rem;
  color: var(--color-texto-claro);
}

/* Estilos para roles de usuario */

.admin-only,
.supervisor-only {
  display: none;
}

/* --- ESTILOS PARA BORRADO SELECTIVO --- */

/* Modifica el header para alinear el botón */
.gestion-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Estilo visual para la tarjeta seleccionada */
.task-card.selected {
  background-color: #fef9c3; /* Un amarillo claro */
  border-color: var(--color-primario);
}

/* Tabs puestos aquí sólo por scope*/
.tab-content.active {
  display: block;
}
.tab-content {
  display: none;
}

/**/
#diagnostico-container {
  padding: 0 !important;
}
