/* ===== RESET BASE ===== */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

/* ===== BODY ===== */
body {
  font-family: "Segoe UI", Arial, sans-serif;
  background: linear-gradient(120deg, #e3f2fd, #f5f5f5);
  display: flex;
  flex-direction: column;
}

/* ===== HEADER ===== */
header {
  background: #0d47a1;
  color: white;
  padding: 15px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header h1 {
  font-size: 20px;
  margin: 0;
}

.logout {
  color: white;
  text-decoration: none;
  background: #c62828;
  padding: 8px 14px;
  border-radius: 4px;
  font-size: 14px;
}

/* ===== CONTENEDOR GENERAL ===== */
.container {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px;
  gap: 15px;
}

/* ===== TARJETAS ===== */
.card {
  background: white;
  border-radius: 6px;
  padding: 20px;
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
  margin-bottom: 20px;
}

/* ===== FORM ===== */
input, textarea, select {
  width: 100%;
  padding: 10px;
  margin-top: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-sizing: border-box; /* Previene que se desborden de la tarjeta */
}

textarea {
  height: 80px;
  resize: vertical;
}

/* ===== BOTONES ===== */
button {
  background: #1565c0;
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 10px;
}

button:hover {
  background: #0d47a1;
}

/* ===== 🆕 PESTAÑAS (TABS) MEJORADAS ===== */
.tabs-contenedor {
  margin-top: 15px;
  background: white;
  padding: 20px;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,.08);
}

.tabs-botones {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 12px;
}

.tab-btn {
  padding: 10px 22px;
  cursor: pointer;
  border: none;
  background: #edf2f7;
  font-weight: bold;
  border-radius: 6px;
  color: #4a5568;
  font-size: 14px;
  transition: all 0.3s ease;
}

.tab-btn:hover {
  background: #e2e8f0;
}

.tab-btn.activo {
  background: #007bff;
  color: white;
  box-shadow: 0 2px 6px rgba(0, 123, 255, 0.3);
}

/* ===== 🆕 TABLAS LIMPIAS Y RESPONSIVAS =====
.tab-contenido {
  animation: fadeIn 0.3s ease;
}

.tabla-cartas {
  width: 100%;
  border-collapse: collapse;
  background: white;
  margin-top: 10px;
}

.tabla-cartas th, .tabla-cartas td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
  font-size: 14px;
  color: #2d3748;
}

.tabla-cartas th {
  background-color: #f7fafc;
  color: #4a5568;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.5px;
}

.tabla-cartas tr:hover {
  background-color: #f8fafc;
} */

/* ===== OPTIMIZACIÓN Y COMPACTACIÓN DE LA TABLA ===== */

.tabla-cartas {
  width: 100%;
  max-width: 1000px; /* 🔥 Limita el ancho para que no se estire al infinito en pantallas grandes */
  margin: 15px auto 20px auto; /* 🔥 El 'auto' de los lados centra la tabla perfectamente dentro de la tarjeta blanca */
  border-collapse: collapse;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

/* 🆕 Controlar el ancho proporcional de cada columna para que no se dispersen */
.tabla-cartas th:nth-child(1),
.tabla-cartas td:nth-child(1) { 
  width: 12%; /* N° Carta (Compacto) */
}

.tabla-cartas th:nth-child(2),
.tabla-cartas td:nth-child(2) { 
  width: 40%; /* Destinatario / Remitente (Le damos más espacio) */
}

.tabla-cartas th:nth-child(3),
.tabla-cartas td:nth-child(3) { 
  width: 18%; /* Fecha (Tamaño justo para DD/MM/AAAA) */
}

.tabla-cartas th:nth-child(4),
.tabla-cartas td:nth-child(4) { 
  width: 30%; /* Acciones (Espacio cómodo para los botones) */
  text-align: right; /* 🔥 Alineamos los botones a la derecha para un acabado más limpio */
}

/* Asegurar que las cabeceras de acciones también se alineen a la derecha */
.tabla-cartas th:nth-child(4) {
  text-align: right;
  padding-right: 25px;
}

/* Ajuste de padding interno para que las filas se vean más aireadas pero compactas */
.tabla-cartas th, .tabla-cartas td {
  padding: 12px 18px !important;
}

/* ===== 🆕 BOTONES DE ACCIÓN PARA LA TABLA ===== */
.btn-accion {
  padding: 6px 12px;
  border: none;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  margin-right: 5px;
  transition: background 0.2s;
}

.btn-accion.pdf { background: #e1f5fe; color: #0288d1; }
.btn-accion.pdf:hover { background: #b3e5fc; }

.btn-accion.detalle { background: #e8f5e9; color: #2e7d32; }
.btn-accion.detalle:hover { background: #c8e6c9; }

.btn-accion.eliminar { background: #ffebee; color: #c62828; }
.btn-accion.eliminar:hover { background: #ffcdd2; }

.btn-accion.restaurar { background: #fff3e0; color: #ef6c00; }
.btn-accion.restaurar:hover { background: #ffe0b2; }

/* ===== BADGES DE ESTADO (Para la papelera) ===== */
.badge {
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
}
.badge.recibida { background: #e8f5e9; color: #2e7d32; border: none; }
.badge.enviada { background: #e1f5fe; color: #0288d1; border: none; }

/* ===== CSS MODALES GENERALES ===== */
.modal {
  display: none;
  position: fixed;
  z-index: 100;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(2px);
}

.modal-content {
  background: white;
  padding: 25px;
  width: 400px;
  max-width: 90%;
  margin: 10% auto;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
  animation: slideDown 0.3s ease;
}

/* ===== ANIMACIONES ===== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slideDown {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ===== DISEÑO COMPACTO DEL FORMULARIO ===== */

/* Limitar el ancho de la tarjeta contenedora y centrarla */
.card-formulario-compacto {
  max-width: 750px; /* Evita que ocupe toda la pantalla */
  margin: 0 auto 25px auto; /* Centra horizontalmente y da margen abajo */
  border-top: 4px solid #1565c0; /* Un detalle visual azul en la parte superior */
}

/* Crear la cuadrícula de dos columnas */
.formulario-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr); /* Divide en 2 columnas iguales */
  gap: 15px 20px; /* Espaciado entre filas y columnas */
  margin-top: 15px;
}

/* Forzar que las etiquetas queden arriba del campo con un diseño limpio */
.form-grupo {
  display: flex;
  flex-direction: column;
}

.form-grupo label {
  font-size: 13px;
  font-weight: 600;
  color: #4a5568;
  margin-bottom: 4px;
}

/* Ajustes finos para los controles del formulario */
.form-grupo input, 
.form-grupo select, 
.form-grupo textarea {
  margin-top: 0 !important; /* Resetea el margen molesto anterior */
  padding: 8px 12px !important;
  font-size: 14px;
  border: 1px solid #cbd5e0;
  border-radius: 5px;
  background-color: #fff;
}

.form-grupo input:focus, 
.form-grupo select:focus, 
.form-grupo textarea:focus {
  border-color: #3182ce;
  outline: none;
  box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.15);
}

/* Forzar que el textarea abarque las dos columnas */
.form-grupo.ancho-completo {
  grid-column: span 2;
}

/* Alinear los botones de acción al fondo de manera estética */
.formulario-botones {
  display: flex;
  justify-content: flex-end; /* Alinea los botones a la derecha */
  gap: 12px;
  margin-top: 20px;
  border-top: 1px solid #edf2f7;
  padding-top: 15px;
}

/* Estilos de botones limpios */
.btn-principal {
  background: #1565c0 !important;
  margin-top: 0 !important;
}
.btn-principal:hover { background: #0d47a1 !important; }

.btn-secundario {
  background: #edf2f7 !important;
  color: #4a5568 !important;
  border: 1px solid #cbd5e0 !important;
  margin-top: 0 !important;
}
.btn-secundario:hover { background: #e2e8f0 !important; color: #2d3748 !important; }

/* Hacerlo completamente responsivo por si entran desde celulares */
@media (max-width: 600px) {
  .formulario-grid {
    grid-template-columns: 1fr; /* Pasa a 1 columna en pantallas chicas */
  }
  .form-grupo.ancho-completo {
    grid-column: span 1;
  }
  .formulario-botones {
    flex-direction: column-reverse;
  }
  .formulario-botones button {
    width: 100%;
  }
}

/* ===== OPTIMIZACIONES EXTRAS DE DISEÑO ===== */

/* Contenedor de herramientas superior (Pestañas) */
.bandeja-herramientas {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px dashed #e2e8f0;
}

.titulo-bandeja {
  font-size: 16px;
  font-weight: 700;
  color: #2d3748;
}

/* Botones de reporte estilizados como etiquetas ejecutivas */
.btn-reporte {
  text-decoration: none;
  background: #ffffff;
  color: #4a5568;
  border: 1px solid #cbd5e0;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  margin-left: 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s;
}

.btn-reporte:hover {
  background: #f7fafc;
  color: #1a0dab;
  border-color: #a0aec0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* Forzar la alineación perfecta de los botones del formulario */
.formulario-botones {
  display: flex;
  justify-content: flex-end !important; /* Fuerza el alineado a la derecha */
  gap: 12px;
  margin-top: 25px;
  border-top: 1px solid #edf2f7;
  padding-top: 18px;
}

/* Asegurar espaciado superior en el contenedor general */
.container {
  padding: 30px 20px !important; /* Más respiro para que no se pegue al header */
}

/* Ajuste fino al grosor de los títulos de la tabla */
.tabla-cartas th {
  font-size: 13px !important;
  letter-spacing: 0.8px !important;
  color: #718096 !important; /* Un gris oscuro más corporativo */
}

/* ===== BOTONES DE PAGINACIÓN ===== */
.paginacion {
  display: flex;
  justify-content: center;
  gap: 5px;
  margin-top: 15px;
  margin-bottom: 10px;
}

.pag-link {
  display: inline-block;
  padding: 6px 12px;
  text-decoration: none;
  background: #fff;
  border: 1px solid #cbd5e0;
  color: #4a5568;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s;
}

.pag-link:hover {
  background: #edf2f7;
  border-color: #a0aec0;
}

.pag-link.activo {
  background: #007bff;
  color: white;
  border-color: #007bff;
}