/* ============================
   Variables de diseño (tema)
   ============================ */
:root {
  --font-main: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;

  --color-primary: #1976d2;
  --color-primary-dark: #145ca5;
  --color-primary-soft: #e3f2fd;
  --color-header-grad-2: #1565c0;

  --color-bg: #f5f5f5;
  --color-card: #ffffff;
  --color-border: #e0e0e0;

  --color-text-main: #222222;
  --color-text-muted: #666666;

  --color-success: #2e7d32;
  --color-error: #c62828;

  --font-size-base: 14px;
  --font-size-sm: 13px;
  --font-size-lg: 1.4rem;
  --radius-card: 12px;
}

:host {
  display: block;
  font-family: var(--font-main);
  background-color: var(--color-bg);
  min-height: 100vh;
}

/* === Layout general === */

.container {
  max-width: 1200px;
  margin: 40px auto;
  padding: 0 16px 40px;
  color: var(--color-text-main);
}

/* === Header con logo SALUD UT === */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding: 12px 18px;
  background: linear-gradient(
    90deg,
    var(--color-primary),
    var(--color-header-grad-2)
  );
  border-radius: 12px;
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-saludut {
  height: 52px;
  width: auto;
  object-fit: contain;
}

.header-text h1 {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 700;
}

.subtitle {
  margin: 2px 0 0 0;
  font-size: 0.85rem;
  opacity: 0.9;
}

.header-right .badge-saludut {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* === Tarjeta de búsqueda === */

.search-card {
  background-color: var(--color-card);
  border-radius: var(--radius-card);
  padding: 20px 28px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  margin-bottom: 24px;
  font-size: var(--font-size-base);
}

.form-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.form-row label {
  min-width: 130px;
  font-weight: 600;
}

.form-row input,
.form-row select,
.form-row textarea {
  flex: 1;
  padding: 8px 10px;
  border-radius: 4px;
  border: 1px solid #ccc;
  font-size: var(--font-size-base);
  outline: none;
  background-color: #fff;
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 1px rgba(25, 118, 210, 0.2);
}

/* === Botones === */

button {
  padding: 8px 18px;
  border-radius: 4px;
  border: none;
  background-color: var(--color-primary);
  color: #fff;
  font-size: var(--font-size-base);
  cursor: pointer;
  font-weight: 500;
  transition: background-color 0.15s ease, transform 0.05s ease,
    box-shadow 0.15s ease;
}

button:hover {
  background-color: var(--color-primary-dark);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

button:active {
  transform: scale(0.97);
  box-shadow: none;
}

.btn-secondary {
  background-color: #ffffff;
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
}

.btn-secondary:hover {
  background-color: var(--color-primary-soft);
}

/* Estado */

.estado {
  margin-top: 6px;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.estado.error {
  color: var(--color-error);
  font-weight: 600;
}

.estado.ok {
  color: var(--color-success);
  font-weight: 600;
}

/* === Subir Excel === */

.upload-excel {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.upload-excel .upload-msg {
  font-size: var(--font-size-sm);
  color: var(--color-success);
}

/* === Tabla de resultados === */

.resultados-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  margin-top: 10px;
}

.col-tabla {
  flex: 2;
  min-width: 0;
}

.tabla {
  width: 100%;
  border-collapse: collapse;
  background-color: var(--color-card);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.04);
  font-size: var(--font-size-base);
}

.tabla th,
.tabla td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--color-border);
}

.tabla th {
  background-color: #f2f2f2;
  text-align: left;
  font-weight: 700;
}

.tabla tr:nth-child(even) td {
  background-color: #fafafa;
}

.tabla tr:hover td {
  background-color: #e8f2ff;
}

.tabla td button {
  padding: 6px 12px;
  font-size: var(--font-size-sm);
}

/* === Autorizaciones previas === */

.autorizaciones-previas {
  margin-top: 20px;
  background: var(--color-card);
  border-radius: 8px;
  padding: 16px 20px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.autorizaciones-previas h3 {
  margin-top: 0;
  margin-bottom: 10px;
  font-size: 1.1rem;
}

.tabla-autorizaciones {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-base);
}

.tabla-autorizaciones th,
.tabla-autorizaciones td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--color-border);
}

.tabla-autorizaciones th {
  background-color: #f2f2f2;
  text-align: left;
}

.tabla-autorizaciones tr:nth-child(even) td {
  background-color: #fafafa;
}

.tabla-autorizaciones tr:hover td {
  background-color: #e8f2ff;
}

/* === Modal de autorización === */

.aut-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.aut-modal {
  position: relative;
  background: var(--color-card);
  border-radius: 18px;
  padding: 24px 28px 28px;
  max-width: 820px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.25);
  font-size: var(--font-size-base);
}

.aut-modal h2 {
  margin-top: 0;
  margin-bottom: 10px;
  font-size: var(--font-size-lg);
}

.aut-modal-close {
  position: absolute;
  top: 10px;
  right: 20px;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: none;
  background: #ffffff;
  color: var(--color-error);
  font-size: 25px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 0;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  transition: background 0.15s ease, transform 0.1s ease;
}

.aut-modal-close:hover {
  background: #f5f5f5;
  transform: scale(1.05);
}

.aut-paciente {
  font-size: 0.9rem;
  margin-bottom: 16px;
}

/* === Responsivo === */

@media (max-width: 900px) {
  .resultados-layout {
    flex-direction: column;
  }

  .form-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .form-row label {
    min-width: 0;
  }

  .aut-actions {
    flex-direction: column;
    align-items: stretch;
  }
}
