/* =====================================================================
   TalentoIA - Hoja de estilos principal
   Paleta: índigo (marca) + verde azulado (IA) | Modo claro/oscuro con
   data-bs-theme en <html>. Sin tablas: listas en tarjetas y grid.
   ===================================================================== */
:root {
  --brand: #4f46e5;
  --brand-rgb: 79, 70, 229;
  --brand-2: #0d9488;
  --brand-soft: rgba(var(--brand-rgb), .10);
  --sidebar-w: 264px;
  --sidebar-w-min: 78px;
  --topbar-h: 64px;
  --radius: 14px;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e6e9f2;
  --text: #0f172a;
  --muted: #64748b;
  --sidebar-bg: #0f172a;
  --sidebar-text: #cbd5e1;
  --sidebar-active: rgba(255,255,255,.08);
  --shadow: 0 1px 2px rgba(15,23,42,.04), 0 4px 16px rgba(15,23,42,.06);
  --shadow-lg: 0 10px 40px rgba(15,23,42,.12);
  --font: "Segoe UI", system-ui, -apple-system, "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
}
[data-bs-theme="dark"] {
  --bg: #0b1120;
  --surface: #111827;
  --surface-2: #0f172a;
  --border: #1f2a3d;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --sidebar-bg: #070b16;
  --brand-soft: rgba(var(--brand-rgb), .22);
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.35);
  --bs-body-bg: var(--bg);
  --bs-tertiary-bg: #0f172a;
}

html, body { height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: .935rem; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
.text-muted, .text-secondary { color: var(--muted) !important; }
.fw-semibold { font-weight: 600 !important; }
.small-2 { font-size: .78rem; }
.btn { border-radius: 10px; font-weight: 500; }
.btn-primary { --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: color-mix(in srgb, var(--brand) 85%, #000); --bs-btn-hover-border-color: color-mix(in srgb, var(--brand) 85%, #000); --bs-btn-active-bg: color-mix(in srgb, var(--brand) 80%, #000); }
.btn-outline-primary { --bs-btn-color: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand); }
.btn-ia { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border: 0; }
.btn-ia:hover { color: #fff; filter: brightness(1.08); }
.btn-icon { width: 38px; height: 38px; display: inline-grid; place-items: center; padding: 0; border-radius: 10px; }
.form-control, .form-select { border-radius: 10px; border-color: var(--border); background-color: var(--surface); }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 .2rem var(--brand-soft); }
.form-label { font-weight: 600; font-size: .82rem; color: var(--muted); margin-bottom: .3rem; }
.text-brand { color: var(--brand) !important; }
.bg-brand { background: var(--brand) !important; color: #fff; }
.bg-brand-soft { background: var(--brand-soft) !important; }

/* ------------------------------ Sidebar ------------------------------ */
.app-sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; z-index: 1040; transition: width .22s ease, transform .22s ease;
}
.sb-brand { height: var(--topbar-h); display: flex; align-items: center; gap: .7rem; padding: 0 1.15rem; color: #fff; border-bottom: 1px solid rgba(255,255,255,.06); white-space: nowrap; overflow: hidden; }
.sb-brand .logo { width: 38px; height: 38px; border-radius: 11px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); display: grid; place-items: center; flex: 0 0 38px; overflow: hidden; }
.sb-brand .logo img { width: 100%; height: 100%; object-fit: cover; }
.sb-brand .name { font-weight: 700; line-height: 1.1; }
.sb-brand .name small { display: block; font-weight: 400; color: #94a3b8; font-size: .72rem; max-width: 170px; overflow: hidden; text-overflow: ellipsis; }
.sb-menu { flex: 1; overflow-y: auto; padding: .75rem .65rem 1rem; scrollbar-width: thin; scrollbar-color: #334155 transparent; }
.sb-group { margin-bottom: .2rem; }
.sb-group-btn {
  width: 100%; display: flex; align-items: center; gap: .75rem; background: none; border: 0; color: #94a3b8; padding: .62rem .8rem;
  border-radius: 10px; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; white-space: nowrap;
}
.sb-group-btn:hover { color: #fff; background: rgba(255,255,255,.04); }
.sb-group-btn .chev { margin-left: auto; transition: transform .2s; font-size: .75rem; }
.sb-group-btn:not(.collapsed) { color: #fff; }
.sb-group-btn:not(.collapsed) .chev { transform: rotate(90deg); }
.sb-group-btn > i:first-child { font-size: 1.05rem; width: 22px; text-align: center; }
.sb-link {
  display: flex; align-items: center; gap: .75rem; color: var(--sidebar-text); padding: .55rem .8rem .55rem 1.1rem; border-radius: 10px;
  margin: 2px 0 2px .4rem; white-space: nowrap; font-size: .9rem; position: relative;
}
.sb-link i { font-size: 1.05rem; width: 22px; text-align: center; opacity: .85; }
.sb-link:hover { background: rgba(255,255,255,.05); color: #fff; }
.sb-link.active { background: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(var(--brand-rgb), .35); }
.sb-foot { padding: .8rem; border-top: 1px solid rgba(255,255,255,.06); font-size: .75rem; color: #64748b; white-space: nowrap; overflow: hidden; }

/* Colapsado (escritorio): solo iconos; al pasar el mouse se expande */
.sidebar-collapsed .app-sidebar { width: var(--sidebar-w-min); }
.sidebar-collapsed .app-sidebar:hover { width: var(--sidebar-w); box-shadow: var(--shadow-lg); }
.sidebar-collapsed .app-sidebar:not(:hover) .sb-brand .name,
.sidebar-collapsed .app-sidebar:not(:hover) .sb-group-btn span,
.sidebar-collapsed .app-sidebar:not(:hover) .sb-group-btn .chev,
.sidebar-collapsed .app-sidebar:not(:hover) .sb-link span,
.sidebar-collapsed .app-sidebar:not(:hover) .sb-foot { display: none; }
.sidebar-collapsed .app-sidebar:not(:hover) .sb-link { margin-left: 0; padding-left: .8rem; justify-content: center; }
.sidebar-collapsed .app-sidebar:not(:hover) .sb-group-btn { justify-content: center; }

/* ------------------------------ Contenido ------------------------------ */
.app-main { margin-left: var(--sidebar-w); min-height: 100vh; transition: margin-left .22s ease; display: flex; flex-direction: column; }
.sidebar-collapsed .app-main { margin-left: var(--sidebar-w-min); }
.app-topbar {
  height: var(--topbar-h); position: sticky; top: 0; z-index: 1030; display: flex; align-items: center; gap: .6rem; padding: 0 1.25rem;
  background: color-mix(in srgb, var(--surface) 85%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.app-topbar .page-title { font-weight: 700; font-size: 1.05rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-content { padding: 1.4rem; flex: 1; }
.sb-backdrop { display: none; }

@media (max-width: 991.98px) {
  .app-sidebar { transform: translateX(-100%); width: var(--sidebar-w) !important; }
  .sidebar-open .app-sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .app-main, .sidebar-collapsed .app-main { margin-left: 0; }
  .sidebar-open .sb-backdrop { display: block; position: fixed; inset: 0; background: rgba(2,6,23,.5); z-index: 1035; }
  .sidebar-collapsed .app-sidebar .sb-link span, .sidebar-collapsed .app-sidebar .sb-group-btn span { display: inline !important; }
  .app-content { padding: 1rem; }
  .app-topbar { padding: 0 .75rem; }
}

/* ------------------------------ Tarjetas ------------------------------ */
.card-x { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-x > .card-x-head { padding: 1rem 1.15rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.card-x > .card-x-head h6, .card-x > .card-x-head .h6 { margin: 0; font-weight: 700; }
.card-x > .card-x-body { padding: 1.15rem; }
.stat { display: flex; gap: .9rem; align-items: center; padding: 1.1rem; }
.stat .ico { width: 48px; height: 48px; border-radius: 13px; display: grid; place-items: center; font-size: 1.35rem; flex: 0 0 48px; }
.stat .val { font-size: 1.55rem; font-weight: 800; line-height: 1; }
.stat .lbl { color: var(--muted); font-size: .8rem; margin-top: .25rem; }

/* Listas responsivas (reemplazo de tablas) */
.list-x { display: flex; flex-direction: column; gap: .6rem; }
.list-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .85rem 1rem;
  display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; transition: border-color .15s, box-shadow .15s, transform .15s;
}
.list-item:hover { border-color: rgba(var(--brand-rgb), .45); box-shadow: var(--shadow); }
.list-item .grow { flex: 1 1 220px; min-width: 0; }
.list-item .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .meta { color: var(--muted); font-size: .8rem; display: flex; gap: .35rem .9rem; flex-wrap: wrap; }
.list-item .acciones { display: flex; gap: .35rem; margin-left: auto; }
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty i { font-size: 2.6rem; display: block; margin-bottom: .6rem; opacity: .6; }

.avatar { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; flex: 0 0 auto; background: var(--brand-soft); color: var(--brand); display: inline-grid; place-items: center; font-weight: 700; font-size: .9rem; overflow: hidden; }
.avatar-lg { width: 96px; height: 96px; font-size: 1.8rem; }
.avatar-sm { width: 32px; height: 32px; font-size: .75rem; }
.badge-soft { background: var(--brand-soft); color: var(--brand); font-weight: 600; border-radius: 8px; padding: .35em .6em; font-size: .74rem; }
.badge-dot { display: inline-flex; align-items: center; gap: .35rem; font-size: .78rem; font-weight: 600; padding: .25rem .6rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.badge-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--brand)); }
.chip { display: inline-flex; align-items: center; gap: .3rem; font-size: .76rem; padding: .22rem .55rem; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); margin: 0 .25rem .3rem 0; }
.chip.ok { background: rgba(22,163,74,.1); border-color: rgba(22,163,74,.3); color: #15803d; }
.chip.warn { background: rgba(234,179,8,.12); border-color: rgba(234,179,8,.35); color: #a16207; }
.chip.bad { background: rgba(220,38,38,.08); border-color: rgba(220,38,38,.3); color: #b91c1c; }
[data-bs-theme="dark"] .chip.ok { color: #4ade80; } [data-bs-theme="dark"] .chip.warn { color: #facc15; } [data-bs-theme="dark"] .chip.bad { color: #f87171; }

/* Anillo de score (Match) */
.score-ring { --v: 0; --c: #16a34a; width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto;
  background: conic-gradient(var(--c) calc(var(--v) * 1%), var(--border) 0); position: relative; }
.score-ring::before { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: var(--surface); }
.score-ring b { position: relative; font-size: .95rem; }
.score-ring.lg { width: 120px; height: 120px; } .score-ring.lg::before { inset: 10px; } .score-ring.lg b { font-size: 1.6rem; }
.score-ring.sm { width: 46px; height: 46px; } .score-ring.sm::before { inset: 5px; } .score-ring.sm b { font-size: .78rem; }
.progress-thin { height: 6px; border-radius: 6px; background: var(--border); overflow: hidden; }
.progress-thin > span { display: block; height: 100%; border-radius: 6px; }

/* Kanban del pipeline (scroll horizontal en móvil) */
.kanban { display: flex; gap: 1rem; overflow-x: auto; padding-bottom: 1rem; scroll-snap-type: x mandatory; }
.kanban-col { flex: 0 0 290px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 230px); scroll-snap-align: start; }
.kanban-col-head { padding: .8rem 1rem; display: flex; align-items: center; gap: .5rem; font-weight: 700; border-bottom: 1px solid var(--border); }
.kanban-col-body { padding: .7rem; overflow-y: auto; flex: 1; min-height: 120px; display: flex; flex-direction: column; gap: .6rem; }
.k-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .75rem; cursor: grab; box-shadow: var(--shadow); }
.k-card:active { cursor: grabbing; }
.k-card.sortable-ghost { opacity: .4; }
@media (max-width: 575.98px) { .kanban-col { flex-basis: 86vw; } }

/* Zona Drag & Drop */
.dropzone { border: 2px dashed rgba(var(--brand-rgb), .45); border-radius: 18px; padding: 2.4rem 1rem; text-align: center; background: var(--brand-soft); transition: all .2s; cursor: pointer; }
.dropzone.drag { background: rgba(var(--brand-rgb), .2); border-color: var(--brand); transform: scale(1.01); }
.dropzone .big { font-size: 3rem; color: var(--brand); }
.up-item { display: flex; gap: .8rem; align-items: center; }
.up-item .ico { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); font-size: 1.3rem; }

/* Imágenes */
.img-cover { width: 100%; aspect-ratio: 16/6; object-fit: cover; border-radius: 12px; background: var(--brand-soft); }
.vac-card { overflow: hidden; display: flex; flex-direction: column; height: 100%; }
.vac-card .banner { height: 110px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); background-size: cover; background-position: center; position: relative; }
.vac-card .banner .estado { position: absolute; top: .7rem; right: .7rem; }
.foto-upload { position: relative; display: inline-block; cursor: pointer; }
.foto-upload .cam { position: absolute; right: 0; bottom: 0; width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; border: 3px solid var(--surface); }

/* Pestañas y secciones */
.nav-pills-x { gap: .35rem; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.nav-pills-x .nav-link { border-radius: 10px; color: var(--muted); font-weight: 600; white-space: nowrap; padding: .5rem .9rem; }
.nav-pills-x .nav-link.active { background: var(--brand); color: #fff; }
.timeline { position: relative; padding-left: 1.4rem; }
.timeline::before { content: ""; position: absolute; left: .45rem; top: .3rem; bottom: .3rem; width: 2px; background: var(--border); }
.tl-item { position: relative; padding-bottom: 1rem; }
.tl-item::before { content: ""; position: absolute; left: -1.2rem; top: .3rem; width: 12px; height: 12px; border-radius: 50%; background: var(--c, var(--brand)); border: 2px solid var(--surface); box-shadow: 0 0 0 2px var(--c, var(--brand)); }

/* Chat IA */
.chat-box { display: flex; flex-direction: column; height: calc(100vh - 210px); min-height: 420px; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .8rem; }
.msg { max-width: 85%; padding: .7rem .95rem; border-radius: 14px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; white-space: normal; }
.msg.assistant p:last-child { margin-bottom: 0; }
.typing span { display: inline-block; width: 7px; height: 7px; margin: 0 2px; background: var(--muted); border-radius: 50%; animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }

/* Utilidades varias */
.section-title { font-size: .76rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; margin: 1.2rem 0 .6rem; }
.loader-bar { position: fixed; top: 0; left: 0; height: 3px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); z-index: 2000; width: 0; transition: width .3s; }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: sk 1.3s infinite; border-radius: 10px; height: 64px; }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.fade-in { animation: fadein .25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.dropdown-menu { border-radius: 12px; border-color: var(--border); box-shadow: var(--shadow-lg); }
.modal-content { border-radius: 16px; border-color: var(--border); background: var(--surface); }
.offcanvas { background: var(--surface); }
.rich-view { line-height: 1.6; } .rich-view p:last-child { margin-bottom: 0; } .rich-view ul { padding-left: 1.2rem; }
.criterio-row { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: .7rem; }
.cursor-pointer { cursor: pointer; }
.stars i { color: #f59e0b; cursor: pointer; }
.ia-badge { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border-radius: 8px; padding: .2rem .5rem; font-size: .72rem; font-weight: 600; }

/* Select2 + tema oscuro */
.select2-container--bootstrap-5 .select2-selection { border-radius: 10px; border-color: var(--border); background-color: var(--surface); min-height: 38px; }
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection,
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-dropdown { background: var(--surface); color: var(--text); border-color: var(--border); }
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered { color: var(--text); }
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-dropdown .select2-results__options .select2-results__option { color: var(--text); }
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-dropdown .select2-search .select2-search__field { background: var(--surface-2); color: var(--text); border-color: var(--border); }
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__rendered .select2-selection__choice { color: var(--text); border-color: var(--border); }
.select2-container { width: 100% !important; }
.swal2-popup { border-radius: 16px !important; font-family: var(--font) !important; }
[data-bs-theme="dark"] .swal2-popup { background: var(--surface) !important; color: var(--text) !important; }
[data-bs-theme="dark"] .swal2-title, [data-bs-theme="dark"] .swal2-html-container { color: var(--text) !important; }
[data-bs-theme="dark"] .swal2-input, [data-bs-theme="dark"] .swal2-textarea, [data-bs-theme="dark"] .swal2-select { background: var(--surface-2) !important; color: var(--text) !important; }
.tox-tinymce { border-radius: 10px !important; border-color: var(--border) !important; }

@media print { .app-sidebar, .app-topbar { display: none !important; } .app-main { margin: 0 !important; } }
[data-bs-theme="dark"] .btn-light { --bs-btn-bg: var(--surface-2); --bs-btn-border-color: var(--border); --bs-btn-color: var(--text); --bs-btn-hover-bg: #1e293b; --bs-btn-hover-border-color: #334155; --bs-btn-hover-color: #fff; --bs-btn-active-bg: #1e293b; --bs-btn-active-color: #fff; }
[data-bs-theme="dark"] .text-bg-light { background: var(--surface-2) !important; color: var(--text) !important; }
[data-bs-theme="dark"] .alert-light { background: var(--surface-2); color: var(--text); border-color: var(--border); }
