/* ==========================================================================
   IT Traviser — sistema de diseño
   Paleta derivada del logotipo corporativo Traviser S.A. (verde #006830).
   ========================================================================== */

:root {
  /* Marca */
  --brand-900: #04301A;
  --brand-800: #00512A;
  --brand-700: #006830;
  --brand-600: #0A7D3E;
  --brand-500: #12924C;
  --brand-100: #D9EFE1;
  --brand-50:  #EFF8F2;

  /* Neutros */
  --ink-900: #0D1B14;
  --ink-800: #16241C;
  --ink-700: #2B3A31;
  --ink-500: #5A6B61;
  --ink-400: #7C8B82;
  --ink-300: #AFBAB3;
  --ink-200: #DCE3DE;
  --ink-100: #EDF1EE;
  --surface: #FFFFFF;
  --canvas:  #F4F7F5;

  /* Semánticos */
  --ok:    #12924C;
  --warn:  #B7791F;
  --dangr: #C0392B;
  --info:  #2A6F97;

  /* Formas */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(13, 27, 20, .06), 0 1px 3px rgba(13, 27, 20, .04);
  --shadow-md: 0 2px 8px rgba(13, 27, 20, .07), 0 1px 3px rgba(13, 27, 20, .05);
  --shadow-lg: 0 12px 32px rgba(13, 27, 20, .12);

  --sidebar-w: 254px;
  --topbar-h: 62px;

  --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* --------------------------------------------------------------- base --- */
body {
  background: var(--canvas);
  color: var(--ink-800);
  font-family: var(--bs-body-font-family);
  font-size: .9375rem;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 { color: var(--ink-900); font-weight: 600; letter-spacing: -.01em; }

a { color: var(--brand-700); text-decoration: none; }
a:hover { color: var(--brand-800); }

code { color: var(--brand-800); background: var(--brand-50); padding: .1rem .35rem; border-radius: 4px; font-size: .85em; }

::selection { background: var(--brand-100); }

:focus-visible { outline: 2px solid var(--brand-600); outline-offset: 2px; }

/* ------------------------------------------------------------ sidebar --- */
.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--ink-900);
  display: flex;
  flex-direction: column;
  z-index: 1040;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
  min-height: var(--topbar-h);
}
.app-brand img { height: 30px; width: auto; }
.app-brand__text { line-height: 1.15; }
.app-brand__name { color: #fff; font-weight: 650; font-size: .95rem; letter-spacing: -.01em; }
.app-brand__sub { color: var(--ink-400); font-size: .68rem; text-transform: uppercase; letter-spacing: .09em; }

.nav-section {
  color: var(--ink-400);
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  padding: 1.15rem 1.15rem .4rem;
}

.nav-link-app {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .58rem 1.15rem;
  color: rgba(255, 255, 255, .72);
  font-size: .885rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.nav-link-app i { width: 1.05rem; text-align: center; font-size: .92rem; opacity: .85; }
.nav-link-app:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.nav-link-app.active {
  background: rgba(18, 146, 76, .16);
  color: #fff;
  border-left-color: var(--brand-500);
}
.nav-link-app.active i { opacity: 1; color: var(--brand-500); }

.sidebar-footer {
  margin-top: auto;
  padding: 1rem 1.15rem;
  border-top: 1px solid rgba(255, 255, 255, .07);
  color: var(--ink-400);
  font-size: .72rem;
}

/* ------------------------------------------------------------- topbar --- */
.app-main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }

.app-topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--ink-200);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 1030;
}
.app-topbar__title { font-size: .95rem; font-weight: 600; color: var(--ink-900); margin: 0; }

.user-chip {
  display: flex;
  align-items: center;
  gap: .55rem;
  background: none;
  border: 0;
  padding: .3rem .4rem;
  border-radius: var(--r-md);
}
.user-chip:hover { background: var(--ink-100); }
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--brand-700);
  color: #fff;
  display: grid; place-items: center;
  font-size: .78rem; font-weight: 650;
  flex: 0 0 auto;
}
.user-chip__name { font-size: .85rem; font-weight: 600; color: var(--ink-800); line-height: 1.1; }
.user-chip__role { font-size: .7rem; color: var(--ink-500); line-height: 1.1; }

.app-content { padding: 1.6rem 1.5rem 2.5rem; flex: 1; }

/* -------------------------------------------------------- page header --- */
.page-header {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.35rem;
}
.page-header h1 { font-size: 1.4rem; font-weight: 650; margin: 0; }
.page-header .lead-sub { color: var(--ink-500); font-size: .875rem; margin: .2rem 0 0; }

/* --------------------------------------------------------------- card --- */
.card {
  border: 1px solid var(--ink-200);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  background: var(--surface);
}
.card-header {
  background: var(--surface);
  border-bottom: 1px solid var(--ink-200);
  padding: .9rem 1.15rem;
  font-weight: 600;
  font-size: .9rem;
  border-radius: var(--r-lg) var(--r-lg) 0 0 !important;
}
.card-body { padding: 1.15rem; }

/* Tarjetas de indicador del dashboard */
.stat-card { position: relative; overflow: hidden; }
.stat-card .card-body { display: flex; align-items: center; gap: 1rem; padding: 1.15rem 1.25rem; }
.stat-icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: grid; place-items: center;
  font-size: 1.05rem;
  background: var(--brand-50);
  color: var(--brand-700);
  flex: 0 0 auto;
}
.stat-icon.is-info   { background: #E7F0F7; color: var(--info); }
.stat-icon.is-warn   { background: #FBF3E2; color: var(--warn); }
.stat-icon.is-danger { background: #FBEAE8; color: var(--dangr); }
.stat-value { font-size: 1.7rem; font-weight: 680; line-height: 1.05; color: var(--ink-900); }
.stat-label { color: var(--ink-500); font-size: .8rem; margin-top: .1rem; }

/* -------------------------------------------------------------- table --- */
.table-card { padding: 0; overflow: hidden; }
.table-card .dataTables_wrapper { padding: 1rem 1.15rem; }

.table { --bs-table-bg: transparent; margin-bottom: 0; color: var(--ink-800); }
.table > thead > tr > th {
  background: var(--ink-100);
  color: var(--ink-700);
  font-size: .72rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--ink-200);
  padding: .7rem .85rem;
  white-space: nowrap;
}
.table > tbody > tr > td {
  padding: .68rem .85rem;
  border-bottom: 1px solid var(--ink-100);
  vertical-align: middle;
}
.table > tbody > tr:last-child > td { border-bottom: 0; }
.table-hover > tbody > tr:hover > * { background: var(--brand-50); }
.table .mono { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink-900); }

.empty-state { padding: 3rem 1rem; text-align: center; color: var(--ink-500); }
.empty-state i { font-size: 2rem; color: var(--ink-300); margin-bottom: .75rem; display: block; }

/* ------------------------------------------------------------- badges --- */
.badge { font-weight: 600; font-size: .72rem; padding: .32em .6em; border-radius: 999px; letter-spacing: .01em; }
.badge-soft { background: var(--ink-100); color: var(--ink-700); }
.badge-soft-ok    { background: var(--brand-50);  color: var(--brand-800); }
.badge-soft-info  { background: #E7F0F7; color: #1B4F72; }
.badge-soft-warn  { background: #FBF3E2; color: #8A5B12; }
.badge-soft-danger{ background: #FBEAE8; color: #922A1E; }
.badge-soft-muted { background: var(--ink-100); color: var(--ink-500); }

/* ------------------------------------------------------------ botones --- */
.btn { font-weight: 550; font-size: .865rem; border-radius: var(--r-sm); padding: .44rem .85rem; }
.btn-sm { font-size: .8rem; padding: .3rem .6rem; }
.btn i { font-size: .85em; }

.btn-primary {
  background: var(--brand-700); border-color: var(--brand-700);
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--brand-800); border-color: var(--brand-800);
}
.btn-success { background: var(--brand-700); border-color: var(--brand-700); }
.btn-success:hover, .btn-success:focus { background: var(--brand-800); border-color: var(--brand-800); }
.btn-outline-primary { color: var(--brand-700); border-color: var(--ink-200); }
.btn-outline-primary:hover { background: var(--brand-700); border-color: var(--brand-700); }
.btn-outline-secondary, .btn-outline-dark { color: var(--ink-700); border-color: var(--ink-200); }
.btn-outline-secondary:hover, .btn-outline-dark:hover { background: var(--ink-800); border-color: var(--ink-800); color: #fff; }
.btn-outline-success { color: var(--brand-700); border-color: var(--ink-200); }
.btn-outline-success:hover { background: var(--brand-700); border-color: var(--brand-700); }
.btn-outline-danger { color: var(--dangr); border-color: var(--ink-200); }
.btn-outline-danger:hover { background: var(--dangr); border-color: var(--dangr); }
.btn-outline-warning { color: var(--warn); border-color: var(--ink-200); }
.btn-outline-warning:hover { background: var(--warn); border-color: var(--warn); color: #fff; }

/* Grupo de acciones en tablas */
.action-group { display: inline-flex; gap: .25rem; }
.action-group .btn { padding: .28rem .5rem; line-height: 1.1; }

/* ---------------------------------------------------------- formularios -- */
.form-label { font-weight: 600; font-size: .8rem; color: var(--ink-700); margin-bottom: .3rem; }
.form-control, .form-select {
  border: 1px solid var(--ink-200);
  border-radius: var(--r-sm);
  padding: .48rem .7rem;
  font-size: .885rem;
  color: var(--ink-900);
  background-color: var(--surface);
}
.form-control:focus, .form-select:focus {
  border-color: var(--brand-600);
  box-shadow: 0 0 0 3px rgba(18, 146, 76, .13);
}
.form-control::placeholder { color: var(--ink-300); }
.form-text { color: var(--ink-500); font-size: .78rem; }
.form-check-input:checked { background-color: var(--brand-700); border-color: var(--brand-700); }
.form-check-input:focus { border-color: var(--brand-600); box-shadow: 0 0 0 3px rgba(18, 146, 76, .13); }

.form-section {
  font-size: .72rem; font-weight: 650; text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-500);
  padding-bottom: .5rem; margin-bottom: .25rem;
  border-bottom: 1px solid var(--ink-200);
}

.form-actions {
  display: flex; gap: .5rem; align-items: center;
  margin-top: 1.5rem; padding-top: 1.15rem;
  border-top: 1px solid var(--ink-200);
}

/* Barra de filtros */
.filter-bar {
  background: var(--surface);
  border: 1px solid var(--ink-200);
  border-radius: var(--r-lg);
  padding: .85rem 1rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.1rem;
}

/* ------------------------------------------------------------- alertas -- */
.alert { border: 1px solid transparent; border-radius: var(--r-md); font-size: .875rem; padding: .8rem 1rem; }
.alert-success { background: var(--brand-50); border-color: var(--brand-100); color: var(--brand-800); }
.alert-info    { background: #EAF2F8; border-color: #D3E3EE; color: #1B4F72; }
.alert-warning { background: #FDF6E7; border-color: #F5E4BF; color: #7D5A11; }
.alert-danger, .alert-error { background: #FBEAE8; border-color: #F3D2CE; color: #8C271B; }

/* --------------------------------------------------------------- login -- */
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; }

.auth-aside {
  background:
    radial-gradient(1100px 520px at 12% 8%, rgba(18, 146, 76, .30), transparent 62%),
    linear-gradient(155deg, #0D1B14 0%, #04301A 58%, #00512A 100%);
  color: #fff;
  padding: 3.5rem 3.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.auth-aside::after {
  content: "";
  position: absolute;
  right: -140px; bottom: -160px;
  width: 460px; height: 460px;
  border-radius: 50%;
  background: rgba(18, 146, 76, .10);
}
.auth-aside > * { position: relative; z-index: 1; }
/* align-self evita que el contenedor flex estire la imagen a lo ancho */
.auth-aside__logo { height: 44px; width: auto; align-self: flex-start; flex: 0 0 auto; }
.auth-aside h2 { color: #fff; font-size: 2rem; font-weight: 650; line-height: 1.2; letter-spacing: -.02em; }
.auth-aside p { color: rgba(255, 255, 255, .68); font-size: .95rem; max-width: 34ch; }
.auth-feature { display: flex; gap: .8rem; align-items: flex-start; color: rgba(255, 255, 255, .84); font-size: .875rem; }
.auth-feature i { color: var(--brand-500); margin-top: .18rem; }
.auth-aside__foot { color: rgba(255, 255, 255, .4); font-size: .75rem; }

.auth-panel { display: grid; place-items: center; padding: 2rem 1.5rem; background: var(--surface); }
.auth-form { width: 100%; max-width: 370px; }
.auth-form__mark { height: 34px; width: auto; max-width: 100%; margin-bottom: 1.5rem; }
.auth-form h1 { font-size: 1.45rem; font-weight: 650; margin-bottom: .3rem; }
.auth-form .sub { color: var(--ink-500); font-size: .885rem; margin-bottom: 1.6rem; }
.auth-form .form-control { padding: .6rem .8rem; }

.input-icon { position: relative; }
.input-icon i {
  position: absolute; left: .8rem; top: 50%; transform: translateY(-50%);
  color: var(--ink-300); font-size: .85rem; pointer-events: none;
}
.input-icon .form-control { padding-left: 2.25rem; }

@media (max-width: 991.98px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
}

/* --------------------------------------------------- DataTables / select2 */
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
  border: 1px solid var(--ink-200);
  border-radius: var(--r-sm);
  padding: .32rem .6rem;
  font-size: .85rem;
}
.dataTables_wrapper .dataTables_filter input:focus,
.dataTables_wrapper .dataTables_length select:focus {
  outline: none; border-color: var(--brand-600);
  box-shadow: 0 0 0 3px rgba(18, 146, 76, .13);
}
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter { font-size: .82rem; color: var(--ink-500); }
.page-link { color: var(--brand-700); border-color: var(--ink-200); font-size: .85rem; }
.page-item.active .page-link { background: var(--brand-700); border-color: var(--brand-700); }

.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple {
  border: 1px solid var(--ink-200) !important;
  border-radius: var(--r-sm) !important;
  min-height: 38px;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 36px; color: var(--ink-900); font-size: .885rem; padding-left: .7rem;
}
.select2-container--default .select2-selection--single .select2-selection__arrow { height: 36px; }
.select2-container--default.select2-container--focus .select2-selection,
.select2-container--default.select2-container--open .select2-selection {
  border-color: var(--brand-600) !important;
  box-shadow: 0 0 0 3px rgba(18, 146, 76, .13);
}
.select2-container--default .select2-results__option--highlighted[aria-selected] { background: var(--brand-700); }
.select2-container--default .select2-selection--multiple .select2-selection__choice {
  background: var(--brand-50); border: 1px solid var(--brand-100); color: var(--brand-800);
  border-radius: var(--r-sm); font-size: .8rem;
}
.select2-dropdown { border-color: var(--ink-200); border-radius: var(--r-sm); box-shadow: var(--shadow-md); }

/* --------------------------------------------------------- responsive --- */
.sidebar-toggle { display: none; background: none; border: 0; color: var(--ink-700); font-size: 1.1rem; padding: .25rem .5rem; }
.sidebar-backdrop {
  position: fixed; inset: 0; background: rgba(13, 27, 20, .5); z-index: 1035; display: none;
}
.sidebar-backdrop.show { display: block; }

@media (max-width: 991.98px) {
  .app-sidebar { transform: translateX(-100%); transition: transform .22s ease; }
  .app-sidebar.show { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .app-main { margin-left: 0; }
  .sidebar-toggle { display: inline-block; }
  .app-content { padding: 1.15rem 1rem 2rem; }
}

@media print {
  .app-sidebar, .app-topbar, .btn, .filter-bar { display: none !important; }
  .app-main { margin-left: 0; }
  .card { border: 0; box-shadow: none; }
}
