/* =========================================================================
   Cumplimiento IMVESA - hoja de estilos compartida
   ========================================================================= */
@font-face {
  font-family: 'MazdaType';
  src: url('/frontend/fonts/MazdaTypeRegular.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'MazdaType';
  src: url('/frontend/fonts/MazdaTypeBold.ttf') format('truetype');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'MazdaType';
  src: url('/frontend/fonts/MazdaTypeItalic.ttf') format('truetype');
  font-style: italic;
  font-display: swap;
}

:root {
  --brand: #1f2023;
  --brand-2: #34363b;
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f8f9fa;
  --border: #e3e5e8;
  --text: #1f2023;
  --muted: #6b7280;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --success: #15803d;
  --success-soft: #f0fdf4;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);

  --bs-body-font-family: 'MazdaType', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  --bs-body-color: var(--text);
  --bs-body-bg: var(--bg);
  --bs-border-color: var(--border);
  --bs-border-radius: var(--radius-sm);
}

html, body { min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---------- Navbar ---------- */
.app-navbar {
  background: var(--brand);
  padding: .6rem 0;
  position: sticky;
  top: 0;
  z-index: 1030;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .15);
}
/* El PNG del logo trae mucho margen transparente: se agranda y se compensa con margen negativo */
.app-navbar .navbar-brand { padding: 0; margin-right: .5rem; }
.app-navbar .navbar-brand img { height: 72px; width: auto; margin: -18px -22px -18px -12px; }
.app-navbar .nav-link {
  color: rgba(255, 255, 255, .72);
  border-radius: 8px;
  padding: .5rem .85rem !important;
  display: flex;
  align-items: center;
  gap: .45rem;
  transition: background-color .15s, color .15s;
}
.app-navbar .nav-link:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.app-navbar .nav-link.active { color: #fff; background: rgba(255, 255, 255, .14); }
.app-navbar .navbar-toggler { border-color: rgba(255, 255, 255, .25); }
.app-navbar .navbar-toggler:focus { box-shadow: none; }
.app-navbar .navbar-toggler-icon { filter: invert(1); }
.app-navbar .user-chip {
  color: rgba(255, 255, 255, .85);
  font-size: .9rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.app-navbar .user-chip .avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .15);
  display: grid; place-items: center;
  font-weight: 700; font-size: .8rem; color: #fff;
}
@media (max-width: 991.98px) {
  .app-navbar .navbar-collapse { padding-top: .75rem; }
  .app-navbar .user-chip { padding: .75rem .85rem 0; border-top: 1px solid rgba(255, 255, 255, .1); margin-top: .5rem; }
}

/* ---------- Layout ---------- */
.app-main { flex: 1; padding: 1.75rem 0 2.5rem; }
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.page-header h1 { font-size: 1.6rem; font-weight: 700; margin: 0; }
.page-header p { color: var(--muted); margin: .25rem 0 0; }
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; }

.card-app {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-app .card-app-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex; flex-wrap: wrap;
  align-items: center; justify-content: space-between;
  gap: .75rem;
}
.card-app .card-app-header h2 { font-size: 1.05rem; font-weight: 700; margin: 0; }
.card-app .card-app-body { padding: 1.25rem; }
@media (max-width: 575.98px) {
  .card-app .card-app-body { padding: 1rem; }
  .page-header h1 { font-size: 1.35rem; }
}

/* ---------- Stat tiles ---------- */
.stat {
  display: flex; align-items: center; gap: 1rem;
  padding: 1.1rem 1.25rem;
  height: 100%;
}
.stat .stat-icon {
  width: 46px; height: 46px; flex: none;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: grid; place-items: center;
  font-size: 1.3rem; color: var(--brand);
}
.stat .stat-label { color: var(--muted); font-size: .85rem; }
.stat .stat-value { font-size: 1.45rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat .stat-value.small-value { font-size: 1.05rem; }

/* ---------- Botones y formularios ---------- */
.btn { border-radius: var(--radius-sm); font-weight: 500; }
.btn-brand { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-brand:hover, .btn-brand:focus { background: var(--brand-2); color: #fff; border-color: var(--brand-2); }
.btn-brand:disabled { background: var(--brand); color: #fff; opacity: .45; }
.btn-icon { width: 34px; height: 34px; padding: 0; display: inline-grid; place-items: center; }
.form-control, .form-select { border-radius: var(--radius-sm); border-color: var(--border); padding: .6rem .85rem; background-color: var(--surface); }
.card-app-header .search-box, .card-app-header .seg-tabs { flex: 1 1 280px; max-width: 420px; }
.form-control:focus, .form-select:focus { background-color: var(--surface); border-color: #9ca3af; box-shadow: 0 0 0 .2rem rgba(31, 32, 35, .1); }
.form-label { font-weight: 600; font-size: .9rem; margin-bottom: .35rem; }

.search-box { position: relative; }
.search-box .bi { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-box .form-control { padding-left: 2.4rem; }

/* ---------- Pestañas segmentadas ---------- */
.seg-tabs {
  display: flex; gap: .25rem;
  padding: .3rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow-x: auto;
  scrollbar-width: none;
}
.seg-tabs::-webkit-scrollbar { display: none; }
.seg-tabs .tab {
  flex: 1 0 auto;
  text-align: center;
  padding: .55rem 1rem;
  border-radius: 9px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: .92rem;
  white-space: nowrap;
  transition: background-color .15s, color .15s;
}
.seg-tabs .tab:hover { color: var(--text); }
.seg-tabs .tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }
@media (max-width: 575.98px) {
  .seg-tabs { flex-wrap: wrap; }
  .seg-tabs .tab { flex: 1 1 40%; padding: .5rem .6rem; }
}

/* ---------- Resultado de búsqueda ---------- */
.result-alert {
  display: none;
  border-radius: var(--radius-sm);
  padding: 1rem 1.1rem;
  margin-top: 1.25rem;
  border: 1px solid transparent;
}
.result-alert .d-flex { gap: .85rem; }
.result-alert .bi { font-size: 1.4rem; line-height: 1; }
.result-alert .result-title { font-weight: 700; margin: 0 0 .15rem; }
.result-alert p { margin: 0; }
.error-alert.result-alert { background: var(--danger-soft); border-color: #fecaca; color: var(--danger); }
.success.result-alert { background: var(--success-soft); border-color: #bbf7d0; color: var(--success); }

.hint {
  display: flex; gap: .65rem;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: .75rem 1rem;
  color: var(--muted);
  font-size: .9rem;
}

/* ---------- Dropzone (carga masiva) ---------- */
.dropzone {
  border: 2px dashed #cbd0d6;
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 2rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background-color .15s;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--brand); background: #eef0f2; }
.dropzone .bi { font-size: 2.2rem; color: var(--muted); }
.dropzone .file-name { font-weight: 600; margin-top: .5rem; word-break: break-all; }
.step-num {
  width: 26px; height: 26px; flex: none;
  border-radius: 50%;
  background: var(--brand); color: #fff;
  display: inline-grid; place-items: center;
  font-size: .8rem; font-weight: 700;
}
.step-title { display: flex; align-items: center; gap: .6rem; font-weight: 700; margin-bottom: .75rem; }

.user-avatar {
  width: 32px; height: 32px; flex: none;
  border-radius: 50%;
  background: var(--brand); color: #fff;
  display: inline-grid; place-items: center;
  font-size: .8rem; font-weight: 700;
}

/* ---------- Badges ---------- */
.badge-soft { display: inline-block; padding: .35em .65em; border-radius: 999px; font-weight: 600; font-size: .78rem; }
.badge-soft.danger { background: var(--danger-soft); color: var(--danger); }
.badge-soft.success { background: var(--success-soft); color: var(--success); }
.badge-soft.neutral { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }

/* ---------- Tablas / DataTables ---------- */
table.dataTable { width: 100% !important; margin: 0 !important; }
.table { --bs-table-bg: transparent; font-size: .9rem; }
.table > thead th {
  background: var(--surface-2) !important;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  white-space: nowrap;
  border-bottom: 1px solid var(--border) !important;
  vertical-align: middle;
}
.table > tbody td { vertical-align: middle; border-color: var(--border); }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: #f6f7f9; }
.table .actions { white-space: nowrap; }
.table .actions .btn + .btn { margin-left: .25rem; }
tr.row-invalid > td { background: #fff7ed !important; }

div.dataTables_wrapper div.dataTables_length select { width: auto; display: inline-block; }
div.dataTables_wrapper div.dataTables_filter input { margin-left: .5rem; }
div.dataTables_wrapper div.dataTables_info { color: var(--muted); font-size: .85rem; padding-top: .85rem !important; }
div.dataTables_wrapper div.dataTables_paginate { padding-top: .5rem; }
.page-link { color: var(--brand); border-radius: 8px !important; margin: 0 2px; border-color: var(--border); }
.active > .page-link, .page-link.active { background: var(--brand); border-color: var(--brand); }
div.dataTables_processing.card {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); padding: .75rem !important;
  z-index: 5;
}
table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control { white-space: nowrap; }
table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control > .d-flex { display: inline-flex !important; vertical-align: middle; }
table.dataTable > tbody > tr.child ul.dtr-details { width: 100%; }
table.dataTable > tbody > tr.child span.dtr-title { color: var(--muted); font-size: .8rem; min-width: 140px; }
@media (max-width: 767.98px) {
  div.dataTables_wrapper div.dataTables_length,
  div.dataTables_wrapper div.dataTables_filter,
  div.dataTables_wrapper div.dataTables_info,
  div.dataTables_wrapper div.dataTables_paginate { text-align: left !important; }
  div.dataTables_wrapper div.dataTables_paginate ul.pagination { justify-content: flex-start !important; flex-wrap: wrap; }
  div.dataTables_wrapper div.dataTables_filter { margin-top: .5rem; }
  div.dataTables_wrapper div.dataTables_filter label { width: 100%; }
  div.dataTables_wrapper div.dataTables_filter input { width: 100%; margin-left: 0; display: block; }
}

/* ---------- Modales ---------- */
.modal-content { border: 0; border-radius: var(--radius); box-shadow: 0 20px 50px rgba(0, 0, 0, .2); }
.modal-header { border-bottom-color: var(--border); padding: 1rem 1.25rem; gap: .75rem; }
.modal-footer { border-top-color: var(--border); }
.modal-title { font-weight: 700; font-size: 1.1rem; }
.modal-fullscreen .modal-content { border-radius: 0; }
.modal-actions { display: flex; flex-wrap: wrap; gap: .5rem; order: 2; }
.modal-actions + .btn-close { order: 3; margin: 0; }
@media (max-width: 575.98px) {
  .modal-actions { order: 4; width: 100%; }
  .modal-actions .btn { flex: 1; }
}
.form-section-title {
  font-size: .75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted);
  margin: 1.25rem 0 .75rem;
}
.form-section-title:first-child { margin-top: 0; }

/* ---------- Footer ---------- */
.app-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 1.1rem 0;
  color: var(--muted);
  font-size: .82rem;
}
.app-footer .privacy { display: flex; gap: .75rem; align-items: flex-start; }
.app-footer .privacy .bi { color: #d97706; font-size: 1.2rem; line-height: 1.2; }
.app-footer .privacy strong { color: var(--text); display: block; margin-bottom: .15rem; letter-spacing: .02em; }
.app-footer p { margin: 0; }

/* ---------- Login ---------- */
.auth-wrap {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
  background:
    radial-gradient(1200px 500px at 10% -10%, #3a3d43 0%, transparent 60%),
    linear-gradient(160deg, #1f2023 0%, #2b2d31 100%);
}
.auth-card { width: 100%; max-width: 410px; padding: 2rem; }
.auth-card .auth-logo { background: var(--brand); border-radius: 12px; padding: .5rem; text-align: center; margin-bottom: 1.5rem; overflow: hidden; }
.auth-card .auth-logo img { height: 110px; max-width: 100%; object-fit: contain; margin: -22px 0; }
.auth-card h1 { font-size: 1.35rem; font-weight: 700; margin-bottom: .25rem; }
@media (max-width: 575.98px) { .auth-card { padding: 1.4rem; } }

.text-muted-app { color: var(--muted) !important; }
.font-mono { font-variant-numeric: tabular-nums; }
