/*
 * ContAudita GG & Asociados — estilos base del portal.
 * Paleta derivada del logotipo: azul institucional, dorado y gris plata.
 */

:root {
  --color-primary: #1e56a0;
  --color-primary-dark: #163f78;
  --color-primary-soft: #e5edf9;
  --color-accent: #c9971c;
  --color-accent-dark: #a87c12;
  --color-accent-soft: #fbf3dc;
  --color-bg: #f7f9fc;
  --color-surface: #ffffff;
  --color-border: #dfe6f0;
  --color-text: #1a2333;
  --color-muted: #64748b;
  --color-danger: #dc2626;
  --color-danger-soft: #fee2e2;
  --color-success: #16a34a;
  --color-success-soft: #dcfce7;
  --color-warning: #b45309;
  --color-warning-soft: #fef3c7;
  --shadow-sm: 0 1px 2px rgba(22, 63, 120, 0.06);
  --shadow-md: 0 4px 12px rgba(22, 63, 120, 0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --ring: 0 0 0 3px rgba(30, 86, 160, 0.2);
  --topbar-h: 52px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--color-primary-dark); }

h1, h2, h3 { letter-spacing: -0.01em; }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 3rem;
}

/* Barra superior */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 2px solid var(--color-accent);
}

.topbar__inner {
  padding: 0.65rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.topbar__brand {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.topbar__brand img {
  height: 40px;
  width: auto;
  display: block;
}

.topbar__nav {
  display: flex;
  gap: 0.25rem;
  flex: 1;
}

.topbar__nav a {
  color: var(--color-muted);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  transition: color 0.15s ease, background 0.15s ease;
}

.topbar__nav a:hover {
  color: var(--color-primary-dark);
  background: var(--color-primary-soft);
}

.topbar__user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.88rem;
  color: var(--color-muted);
}

/* Mensajes flash */
.flash {
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.25rem;
  border: 1px solid transparent;
  font-size: 0.95rem;
}

.flash--notice {
  background: var(--color-success-soft);
  color: #166534;
  border-color: rgba(22, 163, 74, 0.25);
}

.flash--alert {
  background: var(--color-danger-soft);
  color: #991b1b;
  border-color: rgba(220, 38, 38, 0.25);
}

/* Encabezados de página */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.page-header h1 { margin: 0; font-size: 1.55rem; font-weight: 700; }

.page-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.page-header h1 .badge { vertical-align: middle; margin-left: 0.35rem; }

.page-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  margin: 0.35rem 0 0;
  color: var(--color-muted);
  font-size: 0.9rem;
}

.page-meta > span:not(:last-child)::after {
  content: "·";
  margin-left: 0.75rem;
  color: var(--color-border);
}

.breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--color-muted);
  margin-bottom: 0.5rem;
}

.breadcrumbs a {
  color: var(--color-muted);
  text-decoration: none;
}

.breadcrumbs a:hover { color: var(--color-text); text-decoration: underline; }

.breadcrumbs__current { color: var(--color-text); font-weight: 500; }

/* Tarjetas y secciones */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.card h2 {
  margin: 0 0 0.85rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
}

.card--empty { color: var(--color-muted); }

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.card__header h2 { margin: 0; }

.grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr));
}

.grid > .card {
  min-width: 0;
  overflow-x: auto;
  margin-bottom: 0;
}

@media (max-width: 480px) {
  .grid { grid-template-columns: 1fr; }
}

.grid + .card { margin-top: 1.25rem; }

/* Indicadores del dashboard */
.stats {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  margin-bottom: 1.5rem;
}

.stat {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  text-decoration: none;
  color: inherit;
  display: block;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}

a.stat:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--color-primary);
}

.stat__value {
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--color-primary-dark);
}

.stat__label {
  color: var(--color-muted);
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Tablas */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  font-size: 0.92rem;
}

th, td {
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}

th {
  background: transparent;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-muted);
}

tr:last-child td { border-bottom: none; }

tr:hover td { background: #f8fafc; }

td.actions, th.actions { text-align: right; white-space: nowrap; }

.money { white-space: nowrap; }

/* Etiquetas de estado */
.badge {
  display: inline-block;
  white-space: nowrap;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  background: #f1f5f9;
  color: var(--color-muted);
}

.badge--paid, .badge--active, .badge--completed, .badge--charged { background: var(--color-success-soft); color: #15803d; }
.badge--pending, .badge--worked, .badge--requested, .badge--in-progress, .badge--uncharged { background: var(--color-warning-soft); color: var(--color-warning); }
.badge--overdue, .badge--inactive, .badge--cancelled { background: var(--color-danger-soft); color: var(--color-danger); }

/* Formularios */
.form { max-width: 620px; }

.form .field { margin-bottom: 1rem; }

.form label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.3rem;
  font-size: 0.88rem;
}

.form input[type="text"],
.form input[type="email"],
.form input[type="password"],
.form input[type="date"],
.form input[type="month"],
.form input[type="number"],
.form input[type="file"],
.form select,
.form textarea {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font: inherit;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form input:focus,
.form select:focus,
.form textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: var(--ring);
}

.form textarea { min-height: 100px; }

.form .checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.form .checkbox label { margin: 0; }

.form-errors {
  background: var(--color-danger-soft);
  color: #991b1b;
  border: 1px solid rgba(220, 38, 38, 0.25);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.92rem;
}

.form-errors ul { margin: 0.3rem 0 0; padding-left: 1.2rem; }

/* Botones */
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-primary);
  background: var(--color-primary);
  color: #fff;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.btn--secondary {
  background: #fff;
  border-color: var(--color-border);
  color: var(--color-text);
}

.btn--secondary:hover {
  background: #f1f5f9;
  border-color: var(--color-border);
}

.btn--danger {
  background: #fff;
  border-color: rgba(220, 38, 38, 0.4);
  color: var(--color-danger);
}

.btn--danger:hover {
  background: var(--color-danger-soft);
  border-color: var(--color-danger);
}

.btn--sm { padding: 0.25rem 0.6rem; font-size: 0.8rem; }

.btn--link {
  background: none;
  border: none;
  color: var(--color-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 0;
  cursor: pointer;
}

.btn--link:hover {
  background: none;
  color: var(--color-danger);
}

/* Filtros */
.filters {
  display: flex;
  gap: 0.6rem;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.filters label {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--color-muted);
  margin-bottom: 0.2rem;
}

.filters input, .filters select {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.9rem;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.filters input:focus, .filters select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: var(--ring);
}

.sort-link {
  color: inherit;
  text-decoration: none;
}

.sort-link:hover {
  text-decoration: underline;
}

.sort-link--active {
  color: var(--color-primary);
}

/* Autenticación */
.auth {
  max-width: 380px;
  margin: 8vh auto 0;
}

.auth__logo {
  display: block;
  width: 210px;
  max-width: 80%;
  height: auto;
  margin: 0.5rem auto 1.5rem;
}

/* Listas de definición (perfil) */
.details {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 1.5rem;
  margin: 0;
}

.details dt { font-weight: 600; color: var(--color-muted); font-size: 0.9rem; }
.details dd { margin: 0; }

.muted { color: var(--color-muted); }

/* Vista de cliente: menú lateral + pestañas */
.main--full {
  max-width: none;
  margin: 0;
  padding: 0;
}

.main--full .flash {
  margin: 1rem 1.25rem;
}

.client-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 0;
  align-items: start;
  min-height: calc(100vh - var(--topbar-h));
}

.side-menu {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  padding: 1.5rem 1.25rem;
}

.side-menu__header h1 {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.side-menu__header { margin-bottom: 1rem; }

.side-menu__title { color: inherit; text-decoration: none; }

.side-menu__title:hover { color: var(--color-primary-dark); }

.side-menu__nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-bottom: 1rem;
  border-top: 1px solid var(--color-border);
  padding-top: 0.85rem;
}

.side-menu__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.7rem;
  border-radius: var(--radius-sm);
  color: var(--color-muted);
  font-size: 0.92rem;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.15s ease, background 0.15s ease;
}

.side-menu__link:hover {
  color: var(--color-primary-dark);
  background: var(--color-primary-soft);
}

.side-menu__link--active {
  color: var(--color-primary-dark);
  background: var(--color-primary-soft);
  font-weight: 600;
}

.side-menu__count {
  background: var(--color-accent-soft);
  color: var(--color-accent-dark);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.05rem 0.5rem;
}

.side-menu__actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  border-top: 1px solid var(--color-border);
  padding-top: 0.85rem;
}

.side-menu__actions .btn { text-align: center; }

.client-content {
  min-width: 0;
  max-width: 1100px;
  padding: 1.75rem 1.5rem 3rem;
}

.client-content > .card:last-child { margin-bottom: 0; }

/* Barra móvil y panel deslizable del cliente */
.client-mobile-bar { display: none; }

.drawer-backdrop { display: none; }

@media (max-width: 760px) {
  .client-layout { grid-template-columns: 1fr; }

  .client-mobile-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
  }

  .client-mobile-bar__toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: #fff;
    cursor: pointer;
  }

  .client-mobile-bar__toggle span {
    display: block;
    height: 2px;
    border-radius: 2px;
    background: var(--color-primary-dark);
  }

  .client-mobile-bar__toggle:focus-visible {
    outline: none;
    box-shadow: var(--ring);
  }

  .client-mobile-bar__title {
    font-weight: 700;
    font-size: 0.95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .drawer-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgba(26, 35, 51, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  .drawer-backdrop--visible {
    opacity: 1;
    pointer-events: auto;
  }

  .side-menu {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(300px, 85vw);
    height: auto;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-md);
  }

  .side-menu--open { transform: translateX(0); }
}

/* Checklist de documentos requeridos */
.checklist__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 0.75rem;
}

.checklist__item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  min-height: 8.5rem;
  padding: 0.85rem;
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-sm);
  text-align: center;
  text-decoration: none;
  color: var(--color-muted);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.checklist__mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  font-size: 1.25rem;
  font-weight: 700;
  background: #f1f5f9;
}

.checklist__name {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--color-text);
}

.checklist__meta { font-size: 0.76rem; }

.checklist__item--upload:hover,
.checklist__item--upload:focus-within {
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
}

.checklist__item--upload:hover .checklist__mark,
.checklist__item--upload:focus-within .checklist__mark {
  background: var(--color-primary);
  color: #fff;
}

.checklist__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.checklist__item--done {
  border-style: solid;
  border-color: var(--color-success);
  background: var(--color-success-soft);
}

.checklist__preview {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 5.5rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}

.checklist__preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.checklist__preview:hover { box-shadow: var(--shadow-sm); }

.checklist__ext {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--color-muted);
}

.checklist__meta a { color: inherit; }

.checklist__thumbs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
}

.checklist__thumb {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
}

.checklist__thumb-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.checklist__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.checklist__thumb:hover { box-shadow: var(--shadow-sm); }

.checklist__thumb-delete {
  position: absolute;
  top: -0.4rem;
  right: -0.4rem;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.checklist__thumb:hover .checklist__thumb-delete,
.checklist__thumb:focus-within .checklist__thumb-delete { opacity: 1; }

.checklist__item-delete {
  top: 0.35rem;
  right: 0.35rem;
  z-index: 1;
}

.checklist__item:hover .checklist__item-delete,
.checklist__item:focus-within .checklist__item-delete { opacity: 1; }

.checklist__thumb-delete button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.15rem;
  height: 1.15rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--color-danger);
  color: #fff;
  font-size: 0.8rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.checklist__thumb .checklist__ext { font-size: 0.6rem; }

.checklist__thumb--add {
  position: relative;
  border-style: dashed;
  border-width: 2px;
  background: transparent;
  cursor: pointer;
}

.checklist__thumb--add:hover,
.checklist__thumb--add:focus-within {
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
}

.checklist__mark--sm {
  width: 1.4rem;
  height: 1.4rem;
  font-size: 1rem;
  background: transparent;
  color: var(--color-muted);
}

@media (min-width: 480px) {
  .checklist__item--wide { grid-column: span 2; }
}

.checklist__item--done .checklist__meta {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.checklist__item--locked { background: var(--color-bg); }

/* Configuración de documentos requeridos en el formulario de cliente */
.checklist-config {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
}

.checklist-config legend {
  font-weight: 600;
  font-size: 0.88rem;
  padding: 0 0.35rem;
}

.checklist-config .muted { margin: 0 0 0.6rem; font-size: 0.85rem; }

.checklist-config__option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 400;
  margin-bottom: 0.25rem;
}

/* Pestañas */
.tabs__nav {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 1rem;
}

.tabs__tab {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.55rem 0.9rem;
  margin-bottom: -1px;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--color-muted);
  cursor: pointer;
}

.tabs__tab:hover { color: var(--color-primary-dark); }

.tabs__tab--active {
  color: var(--color-primary-dark);
  border-bottom-color: var(--color-primary);
}

/* Diseño adaptable */
@media (max-width: 760px) {
  .container { padding: 1.25rem 1rem 2.5rem; }

  .topbar__inner {
    padding: 0.5rem 1rem;
    gap: 0.5rem 1rem;
  }

  .topbar__nav {
    order: 3;
    flex: 1 0 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.15rem;
  }

  .topbar__nav a { white-space: nowrap; }

  .topbar__user {
    min-width: 0;
    gap: 0.5rem;
    font-size: 0.82rem;
  }

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

  .card {
    padding: 1rem 1.1rem;
    overflow-x: auto;
  }

  .client-content { padding: 1.25rem 1rem 2.5rem; }

  .filters > div { flex: 1 1 160px; min-width: 0; }

  .filters input, .filters select { width: 100%; }

  .details { grid-template-columns: 1fr; gap: 0.1rem; }

  .details dd { margin-bottom: 0.6rem; }

  .page-meta {
    font-size: 0.7rem;
    gap: 0.1rem 0.5rem;
    margin-top: 0.15rem;
  }

  .page-meta > span:not(:last-child)::after { margin-left: 0.5rem; }

  .page-header h1 { font-size: 1.15rem; }

  .page-header h1 .badge {
    font-size: 0.62rem;
    padding: 0.08rem 0.45rem;
  }
}

@media (max-width: 480px) {
  .page-header h1 { font-size: 1.15rem; }

  .topbar__brand img { height: 34px; }

  .stats { gap: 0.6rem; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }

  .stat { padding: 0.75rem 0.85rem; }

  .stat__value { font-size: 1.55rem; }

  th, td { padding: 0.55rem 0.6rem; }
}
