/* ============================================================
   JP Digital - Sistema de Gestion TIC
   Estilos propios sobre Bootstrap 5. Paleta petroleo/teal.
   ============================================================ */

:root {
  --tic-accent: #0c8a8d;
  --tic-accent-dark: #0a6e70;
  --tic-accent-soft: #e4f2f2;
  --sidebar-w: 256px;
  --topbar-h: 60px;
}

/* Sobrescribe el primario de Bootstrap con el teal corporativo */
[data-bs-theme="light"] {
  --bs-primary: #0c8a8d;
  --bs-primary-rgb: 12, 138, 141;
  --tic-body-bg: #f4f7f7;
  --tic-sidebar-bg: #0f2a2b;
  --tic-sidebar-ink: #cfe3e3;
  --tic-card-bg: #ffffff;
  --tic-border: #e2e8ea;
}
[data-bs-theme="dark"] {
  --bs-primary: #2bb3b1;
  --bs-primary-rgb: 43, 179, 177;
  --tic-body-bg: #0e1519;
  --tic-sidebar-bg: #0b1417;
  --tic-sidebar-ink: #9bb3b3;
  --tic-card-bg: #161f25;
  --tic-border: #25313a;
}

body {
  background: var(--tic-body-bg);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

.btn-primary {
  --bs-btn-bg: var(--tic-accent);
  --bs-btn-border-color: var(--tic-accent);
  --bs-btn-hover-bg: var(--tic-accent-dark);
  --bs-btn-hover-border-color: var(--tic-accent-dark);
  --bs-btn-active-bg: var(--tic-accent-dark);
}

/* ---- Marca / glifo ---- */
.brand-glyph {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, var(--tic-accent), var(--tic-accent-dark));
  color: #fff; font-weight: 700; font-size: 14px;
}
.brand-glyph.lg { width: 54px; height: 54px; font-size: 22px; border-radius: 14px; }

/* ============================================================
   Layout general (sidebar + main)
   ============================================================ */
.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 1040;
  width: var(--sidebar-w);
  background: var(--tic-sidebar-bg);
  color: var(--tic-sidebar-ink);
  display: flex; flex-direction: column;
  transition: transform .22s ease;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 11px;
  padding: 16px 18px; border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-brand .brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.sidebar-brand b { color: #fff; font-size: 14px; }
.sidebar-brand small { color: var(--tic-sidebar-ink); font-size: 11px; opacity: .8; }

.sidebar-nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 3px; overflow-y: auto; flex: 1; }
.sidebar-nav .nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: 9px;
  color: var(--tic-sidebar-ink); font-size: 13.5px; font-weight: 500;
  text-decoration: none; transition: background .15s, color .15s;
}
.sidebar-nav .nav-link i.bi { font-size: 16px; width: 18px; text-align: center; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav .nav-link.active {
  background: var(--tic-accent); color: #fff;
  box-shadow: 0 4px 12px -4px var(--tic-accent);
}
.sidebar-nav .nav-link.disabled { opacity: .5; cursor: default; }
.sidebar-nav .nav-soon { margin-left: auto; font-size: 10px; opacity: .6; }

.nav-section {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; font-weight: 700;
  color: var(--tic-sidebar-ink); opacity: .55; padding: 14px 12px 6px;
}

.sidebar-footer { padding: 12px 18px; border-top: 1px solid rgba(255,255,255,.07); opacity: .6; }

.app-main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }

/* ---- Topbar ---- */
.app-topbar {
  height: var(--topbar-h); position: sticky; top: 0; z-index: 1020;
  display: flex; align-items: center; gap: 14px; padding: 0 22px;
  background: color-mix(in srgb, var(--tic-body-bg) 85%, transparent);
  backdrop-filter: blur(9px);
  border-bottom: 1px solid var(--tic-border);
}
.topbar-title { font-weight: 650; font-size: 16px; letter-spacing: -.01em; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.topbar-search { position: relative; margin-left: auto; max-width: 340px; flex: 1; }
.topbar-search i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--bs-secondary-color); font-size: 14px; pointer-events: none; }
.topbar-search input { width: 100%; height: 38px; border-radius: 20px; padding: 0 14px 0 34px;
  border: 1px solid var(--tic-border); background: var(--tic-card-bg); color: var(--bs-body-color); font-size: 13px; }
.topbar-search input:focus { outline: none; border-color: var(--tic-accent); }
.topbar-actions { margin-left: 0; }
@media (max-width: 640px) { .topbar-search { display: none; } .topbar-actions { margin-left: auto; } }

/* Selector de equipos (asignacion multiple) */
.equipo-picker { max-height: 280px; overflow-y: auto; border: 1px solid var(--tic-border);
  border-radius: 10px; padding: 6px; }
.equipo-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  cursor: pointer; font-size: 13.5px; }
.equipo-item:hover { background: var(--tic-accent-soft); }
.equipo-item input { width: 16px; height: 16px; }

/* Reportes */
.reporte-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.reporte-card { display: flex; gap: 14px; background: var(--tic-card-bg); border: 1px solid var(--tic-border);
  border-radius: 14px; padding: 18px; box-shadow: 0 1px 2px rgba(20,40,50,.04); }
.reporte-ico { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; flex: none; }
.reporte-body h3 { font-size: 15px; margin: 0 0 3px; }
.reporte-body p { font-size: 12.5px; color: var(--bs-secondary-color); margin: 0 0 10px; }

/* Resultados de busqueda */
.result-row { display: block; padding: 9px 4px; font-size: 13.5px; color: var(--bs-body-color);
  text-decoration: none; border-radius: 6px; }
.result-row + .result-row { border-top: 1px solid var(--tic-border); }
.result-row:hover { background: var(--tic-accent-soft); color: var(--tic-accent-dark); }

.btn-icon {
  width: 40px; height: 40px; border-radius: 10px; padding: 0;
  display: inline-grid; place-items: center; font-size: 18px;
  color: var(--bs-body-color); border: 1px solid transparent;
}
.btn-icon:hover { background: var(--tic-accent-soft); color: var(--tic-accent-dark); }

/* Iconos de tema: mostrar el que corresponde */
.theme-icon-dark { display: none; }
[data-bs-theme="dark"] .theme-icon-light { display: none; }
[data-bs-theme="dark"] .theme-icon-dark { display: inline; }

/* ---- Menu de usuario ---- */
.btn-user {
  display: flex; align-items: center; gap: 9px; padding: 5px 10px 5px 5px;
  border-radius: 30px; border: 1px solid var(--tic-border); background: var(--tic-card-bg);
}
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px;
  background: linear-gradient(135deg, var(--tic-accent), var(--tic-accent-dark));
}
.user-meta { display: flex; flex-direction: column; line-height: 1.1; text-align: left; }
.user-meta b { font-size: 12.5px; }
.user-meta small { font-size: 11px; color: var(--bs-secondary-color); }

.app-content { padding: 24px 22px 40px; max-width: 1320px; width: 100%; }

/* ============================================================
   Dashboard
   ============================================================ */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-title { font-size: 22px; font-weight: 700; letter-spacing: -.02em; margin: 0; }
.page-sub { color: var(--bs-secondary-color); font-size: 13.5px; margin: 4px 0 0; max-width: 60ch; }
.badge-soft {
  background: var(--tic-accent-soft); color: var(--tic-accent-dark);
  padding: 6px 12px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap;
}
[data-bs-theme="dark"] .badge-soft { background: #123033; color: #54c6c3; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.stat-card {
  background: var(--tic-card-bg); border: 1px solid var(--tic-border); border-radius: 14px;
  padding: 16px; display: flex; align-items: center; gap: 14px;
  box-shadow: 0 1px 2px rgba(20,40,50,.04);
}
.stat-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; flex: none; }
.stat-value { font-size: 24px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 12.5px; color: var(--bs-secondary-color); margin-top: 3px; }

.tone-primary   { background: var(--tic-accent-soft); color: var(--tic-accent-dark); }
.tone-success   { background: #e4f4ea; color: #2f7d4f; }
.tone-warning   { background: #fbeed7; color: #a5731a; }
.tone-info      { background: #e0eef7; color: #2f6ca6; }
.tone-danger    { background: #f8e3ec; color: #a53562; }
.tone-secondary { background: #e9edef; color: #5c6d77; }
[data-bs-theme="dark"] .tone-primary   { background: #123033; color: #54c6c3; }
[data-bs-theme="dark"] .tone-success   { background: #16301f; color: #6bd390; }
[data-bs-theme="dark"] .tone-warning   { background: #332a15; color: #e3b45a; }
[data-bs-theme="dark"] .tone-info      { background: #16283a; color: #7fa9da; }
[data-bs-theme="dark"] .tone-danger    { background: #331823; color: #db86ad; }
[data-bs-theme="dark"] .tone-secondary { background: #212a30; color: #9bacb6; }

.panel { background: var(--tic-card-bg); border: 1px solid var(--tic-border); border-radius: 14px; padding: 18px; }
.panel-head { margin-bottom: 12px; }
.panel-title { font-size: 15px; font-weight: 650; margin: 0; }

.alert-list { list-style: none; margin: 0; padding: 0; }
.alert-list li { display: flex; align-items: center; gap: 12px; padding: 11px 4px; }
.alert-list li + li { border-top: 1px solid var(--tic-border); }
.alert-ico { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  background: var(--tic-accent-soft); color: var(--tic-accent-dark); flex: none; }
[data-bs-theme="dark"] .alert-ico { background: #123033; color: #54c6c3; }
.alert-text { font-size: 13.5px; }
.alert-count { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }

.empty-state { text-align: center; padding: 34px 10px; color: var(--bs-secondary-color); }
.empty-state i { font-size: 34px; opacity: .4; }
.empty-state p { margin: 10px 0 2px; font-weight: 600; }
.empty-state small { font-size: 12px; }

/* ============================================================
   Login
   ============================================================ */
.login-wrap {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; position: relative;
  background:
    radial-gradient(1100px 500px at 50% -10%, var(--tic-accent-soft), transparent 60%),
    var(--tic-body-bg);
}
[data-bs-theme="dark"] .login-wrap {
  background: radial-gradient(1100px 500px at 50% -10%, #10292b, transparent 60%), var(--tic-body-bg);
}
.login-card {
  width: 100%; max-width: 400px; background: var(--tic-card-bg);
  border: 1px solid var(--tic-border); border-radius: 18px; padding: 34px 30px;
  box-shadow: 0 20px 50px -20px rgba(12,42,43,.35);
}
.login-brand { text-align: center; margin-bottom: 22px; }
.login-brand h1 { font-size: 20px; font-weight: 700; margin: 12px 0 2px; }
.login-brand p { color: var(--bs-secondary-color); font-size: 13px; margin: 0; }

.input-with-icon { position: relative; }
.input-with-icon > i.bi:first-child {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  color: var(--bs-secondary-color); font-size: 15px; pointer-events: none;
}
.input-with-icon .form-control { padding-left: 38px; height: 46px; }
.toggle-pass {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; color: var(--bs-secondary-color);
  width: 34px; height: 34px; border-radius: 8px; cursor: pointer;
}
.toggle-pass:hover { background: var(--tic-accent-soft); color: var(--tic-accent-dark); }

.link-muted { color: var(--bs-secondary-color); text-decoration: none; }
.link-muted:hover { color: var(--tic-accent); }
.login-foot { margin-top: 20px; color: var(--bs-secondary-color); font-size: 12px; }
.login-theme { position: absolute; top: 18px; right: 18px; }

/* ============================================================
   Formularios y fichas (modulo core)
   ============================================================ */
.form-wrap { max-width: 640px; }
.form-wrap-wide { max-width: 960px; }

.section-title {
  font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--tic-accent-dark); margin: 0 0 14px;
}
[data-bs-theme="dark"] .section-title { color: #54c6c3; }

.detail-list { display: grid; grid-template-columns: 40% 60%; margin: 0; }
.detail-list dt { padding: 8px 0; font-weight: 500; color: var(--bs-secondary-color); font-size: 13px; }
.detail-list dd { padding: 8px 0; margin: 0; font-size: 13.5px; border-bottom: 1px solid var(--tic-border); }
.detail-list dt { border-bottom: 1px solid var(--tic-border); }

.detail-photo { width: 64px; height: 64px; border-radius: 14px; object-fit: cover; }
.detail-avatar { width: 64px; height: 64px; font-size: 22px; border-radius: 14px; }

/* Tablas mas compactas dentro del panel */
.panel .table { margin-bottom: 0; }
.panel .table > :not(caption) > * > * { background: transparent; }

/* Boveda de contrasenas */
.cred-ico {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  display: grid; place-items: center; font-size: 15px;
  background: #f7ecd9; color: #b4720c;
}
[data-bs-theme="dark"] .cred-ico { background: #3a2e17; color: #e3a24e; }
.pwd-box {
  font-size: 15px; letter-spacing: .08em; background: var(--tic-card-bg);
  border: 1px dashed var(--tic-border); padding: 5px 12px; border-radius: 8px;
  color: var(--tic-accent-dark);
}
[data-bs-theme="dark"] .pwd-box { color: #54c6c3; }
.acceso-list { list-style: none; margin: 0; padding: 0; }
.acceso-list li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 2px; }
.acceso-list li + li { border-top: 1px solid var(--tic-border); }

/* Actas y firma */
.hash-box { display: block; font-size: 11px; word-break: break-all; background: var(--tic-card-bg);
  border: 1px dashed var(--tic-border); padding: 8px 10px; border-radius: 8px; }
.firma-canvas-wrap { border: 2px dashed var(--tic-border); border-radius: 12px; background: #fff;
  height: 200px; overflow: hidden; }
.firma-canvas { width: 100%; height: 200px; touch-action: none; cursor: crosshair; }
.firma-registro { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.firma-registro + .firma-registro { border-top: 1px solid var(--tic-border); }
.firma-thumb { height: 44px; max-width: 120px; background: #fff; border: 1px solid var(--tic-border);
  border-radius: 6px; padding: 2px; }

/* Asientos de licencias */
.seat-summary { display: flex; gap: 10px; text-align: center; }
.seat-summary > div { flex: 1; padding: 12px 6px; border: 1px solid var(--tic-border); border-radius: 12px; }
.seat-summary .seat-num { display: block; font-size: 26px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.seat-summary small { color: var(--bs-secondary-color); font-size: 11.5px; }

/* MFA */
.mfa-qr {
  width: 176px; height: 176px; border-radius: 12px;
  border: 1px solid var(--tic-border); background: #fff; padding: 8px;
}
.mfa-secret {
  display: inline-block; font-size: 15px; letter-spacing: .12em; font-weight: 600;
  background: var(--surface-2, var(--tic-card-bg)); border: 1px dashed var(--tic-border);
  padding: 8px 14px; border-radius: 8px; user-select: all; color: var(--tic-accent-dark);
}
[data-bs-theme="dark"] .mfa-secret { color: #54c6c3; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 991.98px) {
  .app-sidebar { transform: translateX(-100%); }
  .app-sidebar.open { transform: translateX(0); }
  .app-main { margin-left: 0; }
  .sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1035; }
  .sidebar-backdrop.show { display: block; }
}
