/* ============================================================
   Directory page template
   Professional directory & org chart styles for public pages
   using the "directory" template. Loaded via content_for(:head).
   ============================================================ */

.dp {
  --dp-primary: #1B396A;
  --dp-primary-dark: #0B231E;
  --dp-accent: #D4AC0D;
  --dp-border: #e2e8f0;
  --dp-muted: #4a5568;
  --dp-connector: #c3cede;
  --dp-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --dp-shadow-hover: 0 20px 25px -5px rgba(27, 57, 106, 0.12), 0 10px 10px -5px rgba(27, 57, 106, 0.08);
  --dp-radius: 16px;
}

/* ---------- Page header ---------- */
.dp-header {
  max-width: 960px;
  margin: 0 auto 2rem;
  padding-top: 1rem;
}

.dp-header-title {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--dp-primary);
  margin: 0 0 0.5rem;
}

.dp-header-lead {
  max-width: 75ch;
  margin: 0;
  color: var(--dp-muted);
  font-size: 1rem;
  line-height: 1.6;
}

.dp-content {
  max-width: 75ch;
  margin: 0 auto 2.5rem;
  color: var(--dp-muted);
  line-height: 1.7;
}

/* ---------- Org chart ---------- */
.dp-chart-scroll {
  overflow-x: auto;
  padding: 1rem 0 0.5rem;
}

.dp-chart {
  display: inline-block;
  min-width: 100%;
}

.dp-chart ul {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  list-style: none;
  margin: 0;
  padding: 2rem 0 0;
  position: relative;
}

.dp-chart > ul {
  padding-top: 0;
}

/* vertical connector from the parent card down to the junction line */
.dp-chart ul ul::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 0;
  height: 2rem;
  border-left: 2px solid var(--dp-connector);
}

.dp-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  padding: 2rem 0.55rem 0;
}

/* junction line: left half + stub down to this node's card */
.dp-node::before {
  content: "";
  position: absolute;
  top: 0;
  right: 50%;
  width: 50%;
  height: 2rem;
  border-top: 2px solid var(--dp-connector);
}

.dp-node::after {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 50%;
  height: 2rem;
  border-top: 2px solid var(--dp-connector);
  border-left: 2px solid var(--dp-connector);
}

.dp-node:first-child::before,
.dp-node:last-child::after {
  border: 0 none;
}

.dp-node:last-child::before {
  border-right: 2px solid var(--dp-connector);
  border-radius: 0 8px 0 0;
}

.dp-node:first-child::after {
  border-radius: 8px 0 0 0;
}

.dp-node:only-child {
  padding-top: 0;
}

.dp-node:only-child::before,
.dp-node:only-child::after {
  display: none;
}

/* ---------- Cards ---------- */
.dp-card {
  width: 258px;
  max-width: 258px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid var(--dp-border);
  border-radius: var(--dp-radius);
  box-shadow: var(--dp-shadow);
  padding: 1.4rem 1.15rem 1.15rem;
  text-align: center;
  position: relative;
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}

.dp-card::after {
  content: "";
  position: absolute;
  top: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 56px;
  height: 4px;
  border-radius: 0 0 6px 6px;
  background: linear-gradient(90deg, var(--dp-primary), var(--dp-accent));
}

.dp-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--dp-shadow-hover);
  border-color: #cbd5e1;
}

.dp-card--root {
  width: 300px;
  max-width: 300px;
  padding-top: 1.6rem;
  border-top: 4px solid var(--dp-primary);
}

.dp-card--root::after {
  display: none;
}

.dp-photo {
  margin: 0 auto 0.9rem;
}

.dp-photo img,
.dp-initials {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  object-fit: cover;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--dp-accent);
}

.dp-card--root .dp-photo img,
.dp-card--root .dp-initials {
  width: 108px;
  height: 108px;
}

.dp-initials {
  background: linear-gradient(135deg, var(--dp-primary) 0%, var(--dp-primary-dark) 100%);
  color: #fff;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.dp-card--root .dp-initials {
  font-size: 1.6rem;
}

.dp-dept {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dp-primary);
  background: #eef3fb;
  border: 1px solid #dbe6f6;
  padding: 0.18rem 0.6rem;
  border-radius: 999px;
  margin-bottom: 0.55rem;
}

.dp-name {
  font-size: 1.04rem;
  font-weight: 700;
  color: var(--dp-primary-dark);
  line-height: 1.3;
  margin: 0 0 0.25rem;
}

.dp-card--root .dp-name {
  font-size: 1.2rem;
}

.dp-role {
  font-size: 0.86rem;
  color: var(--dp-muted);
  line-height: 1.4;
  margin: 0 0 0.7rem;
}

.dp-contact {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  border-top: 1px dashed var(--dp-border);
  padding-top: 0.7rem;
}

.dp-contact a {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  font-size: 0.8rem;
  color: var(--dp-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.dp-contact a:hover {
  color: var(--dp-primary);
}

.dp-contact svg {
  width: 13px;
  height: 13px;
  flex: none;
  color: var(--dp-primary);
}

.dp-contact span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- List mode ---------- */
.dp-list .directory-container {
  max-width: 860px;
  margin: 0 auto;
}

.dp-list .directory-card {
  background: #fff;
  border: 1px solid var(--dp-border);
  border-radius: var(--dp-radius);
  box-shadow: var(--dp-shadow);
  padding: 1.25rem 1.5rem;
  margin-bottom: 0.875rem;
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}

.dp-list .directory-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--dp-shadow-hover);
  border-color: #cbd5e1;
}

.dp-list .directory-card-child {
  border-left: 5px solid var(--dp-primary);
}

.dp-list .directory-card-inner {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.dp-list .directory-photo,
.dp-list .directory-photo-placeholder {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 4px rgba(27, 57, 106, 0.08);
}

.dp-list .directory-photo-placeholder {
  background: linear-gradient(135deg, var(--dp-primary) 0%, var(--dp-primary-dark) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  font-weight: 700;
}

.dp-list .directory-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  min-width: 0;
}

.dp-list .directory-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--dp-primary);
  margin: 0 0 0.3rem;
}

.dp-list .directory-role {
  color: var(--dp-muted);
  margin: 0 0 0.25rem;
}

.dp-list .directory-department {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--dp-primary);
  background: #eef3fb;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.dp-list .directory-actions {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex-shrink: 0;
}

.dp-list .directory-action {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  color: var(--dp-muted);
  text-decoration: none;
}

.dp-list .directory-action:hover {
  color: var(--dp-primary);
}

.dp-list .directory-action span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 260px;
}

.dp-list .directory-children {
  margin-left: 2.25rem;
  padding-left: 1.25rem;
  border-left: 2px solid var(--dp-connector);
}

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
  .dp-chart-scroll {
    overflow-x: visible;
  }

  .dp-chart,
  .dp-chart ul {
    display: block;
  }

  .dp-chart ul {
    padding: 0 0 0 1.4rem;
    margin-left: 0.4rem;
    border-left: 2px solid var(--dp-connector);
  }

  .dp-chart > ul {
    border-left: none;
    padding-left: 0;
    margin-left: 0;
  }

  .dp-node {
    display: block;
    padding: 0.55rem 0 0.55rem 0.9rem;
  }

  .dp-node::before,
  .dp-node::after,
  .dp-chart ul::before {
    display: none;
  }

  .dp-card,
  .dp-card--root {
    width: 100%;
    max-width: 480px;
    margin: 0;
    padding: 1rem 1.1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    text-align: left;
  }

  .dp-photo {
    margin: 0;
    flex-shrink: 0;
  }

  .dp-photo img,
  .dp-initials,
  .dp-card--root .dp-photo img,
  .dp-card--root .dp-initials {
    width: 64px;
    height: 64px;
    font-size: 1.1rem;
  }

  .dp-info {
    flex: 1;
    min-width: 0;
  }

  .dp-list .directory-body {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .dp-list .directory-actions {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.75rem;
  }
}

/* ---------- Vertical mode ---------- */
.dp-v-section {
  max-width: 960px;
  margin: 0 auto 2.75rem;
}

.dp-v-section:last-child {
  margin-bottom: 0;
}

.dp-v-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dp-primary);
  margin: 0 0 1.25rem;
}

.dp-v-title::before {
  content: "";
  width: 30px;
  height: 3px;
  border-radius: 2px;
  background: var(--dp-accent);
}

.dp-v-title--group {
  color: var(--dp-muted);
  font-size: 0.8rem;
}

/* Cards */
.dp-v-card {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  background: #fff;
  border: 1px solid var(--dp-border);
  border-radius: var(--dp-radius);
  box-shadow: var(--dp-shadow);
  padding: 1.1rem 1.4rem;
  margin-bottom: 0.9rem;
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}

.dp-v-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--dp-shadow-hover);
  border-color: #cbd5e1;
}

.dp-v-card .dp-photo {
  margin: 0;
  flex-shrink: 0;
}

.dp-v-card .dp-photo img,
.dp-v-card .dp-initials {
  width: 72px;
  height: 72px;
  font-size: 1.1rem;
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--dp-accent);
}

.dp-v-card .dp-info {
  flex: 1;
  min-width: 0;
}

.dp-v-card--lead {
  padding: 1.4rem 1.6rem;
  border-left: 5px solid var(--dp-primary);
}

.dp-v-card--lead .dp-photo img,
.dp-v-card--lead .dp-initials {
  width: 92px;
  height: 92px;
  font-size: 1.4rem;
}

/* Subdirector grid */
.dp-v-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 0.9rem;
}

.dp-v-grid .dp-v-card {
  margin-bottom: 0;
}

/* Contact column */
.dp-v-contact {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex-shrink: 0;
  min-width: 220px;
  border-left: 1px dashed var(--dp-border);
  padding-left: 1.25rem;
}

.dp-v-contact a {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  font-size: 0.82rem;
  color: var(--dp-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.dp-v-contact a:hover {
  color: var(--dp-primary);
}

.dp-v-contact svg {
  width: 13px;
  height: 13px;
  flex: none;
  color: var(--dp-primary);
}

.dp-v-contact span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Area groups with staff */
.dp-v-group {
  margin-bottom: 1.75rem;
}

.dp-v-group:last-child {
  margin-bottom: 0;
}

.dp-v-group > .dp-v-card {
  margin-bottom: 0;
}

.dp-v-staff {
  list-style: none;
  margin: 0 0 0 2.6rem;
  padding: 0.5rem 0 0.25rem 1.5rem;
  border-left: 2px solid var(--dp-connector);
}

.dp-v-staff-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  background: #fff;
  border: 1px solid var(--dp-border);
  border-radius: 12px;
  padding: 0.55rem 0.9rem;
  margin-bottom: 0.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.dp-v-staff-row:hover {
  border-color: #cbd5e1;
  box-shadow: 0 4px 10px rgba(27, 57, 106, 0.06);
}

.dp-v-staff-row:last-child {
  margin-bottom: 0.25rem;
}

.dp-v-staff-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--dp-primary) 0%, var(--dp-primary-dark) 100%);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
}

.dp-v-staff-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.dp-v-staff-info strong {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--dp-primary-dark);
}

.dp-v-staff-info span {
  font-size: 0.78rem;
  color: var(--dp-muted);
}

.dp-v-staff-actions {
  display: flex;
  gap: 0.4rem;
}

.dp-v-staff-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--dp-border);
  color: var(--dp-primary);
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.dp-v-staff-link:hover {
  background: var(--dp-primary);
  border-color: var(--dp-primary);
  color: #fff;
}

.dp-v-staff-link svg {
  width: 13px;
  height: 13px;
}

/* Vertical mode responsive */
@media (max-width: 991.98px) {
  .dp-v-card {
    flex-wrap: wrap;
    row-gap: 0.75rem;
  }

  .dp-v-card .dp-info {
    flex: 1;
  }

  .dp-v-contact {
    flex: 1 0 100%;
    min-width: 0;
    border-left: none;
    border-top: 1px dashed var(--dp-border);
    padding: 0.65rem 0 0;
  }

  .dp-v-staff {
    margin-left: 1rem;
    padding-left: 1rem;
  }
}

@media (max-width: 575.98px) {
  .dp-v-card--lead {
    padding: 1.1rem 1.2rem;
  }

  .dp-v-card--lead .dp-photo img,
  .dp-v-card--lead .dp-initials {
    width: 72px;
    height: 72px;
    font-size: 1.1rem;
  }
}

/* Ajustes del fallback del plugin: filas de texto (horario/ubicación) e iconos. */
.dp-contact .dp-row,
.dp-v-contact .dp-row {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  font-size: 0.8rem;
  color: var(--dp-muted);
}

.dp-ic {
  width: 13px;
  flex: none;
  color: var(--dp-primary);
  font-size: 11px;
  text-align: center;
}

/* Ajuste del fallback: listas .dp-v-staff anidadas (nietos+ niveles). */
.dp-v-staff .dp-v-staff {
  margin-left: 1.4rem;
  padding-left: 1.1rem;
}

/* Foto real dentro del avatar de fila. */
.dp-v-staff-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* Línea de horario/ubicación en filas de personal (fallback). */
.dp-v-staff-meta {
  font-size: 0.72rem;
  color: var(--dp-muted);
  opacity: 0.9;
}
