/* Interfaz administrativa — Bootstrap 5.3 con acabado tipo Material */
:root {
    --app-primary: #3949ab;
    --app-primary-rgb: 57, 73, 171;
    --app-sidebar-w: 264px;
    --app-sidebar-bg: #1f2547;
    --app-sidebar-fg: #c5cae9;
    --app-radius: 12px;
    --bs-primary: var(--app-primary);
    --bs-primary-rgb: var(--app-primary-rgb);
    --bs-link-color: var(--app-primary);
    --bs-link-color-rgb: var(--app-primary-rgb);
    --bs-body-font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
[data-bs-theme="dark"] {
    --app-primary: #7986cb;
    --app-primary-rgb: 121, 134, 203;
    --app-sidebar-bg: #141830;
    --bs-body-bg: #0f1226;
    --bs-body-bg-rgb: 15, 18, 38;
    --bs-secondary-bg: #1a1e3a;
    --bs-tertiary-bg: #151936;
    --bs-border-color: #2b3059;
}
[data-bs-theme="light"] { --bs-body-bg: #f4f5fb; --bs-body-bg-rgb: 244, 245, 251; }

.btn-primary {
    --bs-btn-bg: var(--app-primary); --bs-btn-border-color: var(--app-primary);
    --bs-btn-hover-bg: #303f9f; --bs-btn-hover-border-color: #303f9f;
    --bs-btn-active-bg: #283593; --bs-btn-active-border-color: #283593;
    --bs-btn-disabled-bg: var(--app-primary); --bs-btn-disabled-border-color: var(--app-primary);
}
.btn-outline-primary {
    --bs-btn-color: var(--app-primary); --bs-btn-border-color: var(--app-primary);
    --bs-btn-hover-bg: var(--app-primary); --bs-btn-hover-border-color: var(--app-primary);
    --bs-btn-active-bg: var(--app-primary); --bs-btn-active-border-color: var(--app-primary);
}
.form-control:focus, .form-select:focus {
    border-color: var(--app-primary);
    box-shadow: 0 0 0 .2rem rgba(var(--app-primary-rgb), .2);
}

/* Estructura */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--app-sidebar-w); z-index: 1040;
    background: var(--app-sidebar-bg); color: var(--app-sidebar-fg);
    overflow-y: auto; transition: transform .2s ease;
}
.sidebar-brand {
    display: flex; align-items: center; gap: .6rem; padding: 1.1rem 1.25rem;
    font-size: 1.15rem; font-weight: 600; color: #fff; letter-spacing: .2px;
}
.sidebar-brand i { font-size: 1.5rem; color: #9fa8da; }
.sidebar-nav { padding: 0 .75rem 1.5rem; }
.sidebar-heading {
    list-style: none; padding: 1.1rem .75rem .35rem; font-size: .7rem;
    text-transform: uppercase; letter-spacing: .08em; color: #7e87c4;
}
.sidebar .nav-link {
    display: flex; align-items: center; gap: .75rem; color: var(--app-sidebar-fg);
    padding: .5rem .75rem; border-radius: 10px; font-size: .92rem;
}
.sidebar .nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.sidebar .nav-link.active { background: rgba(159, 168, 218, .22); color: #fff; font-weight: 500; }
.sidebar .nav-link i { font-size: 1.05rem; width: 1.25rem; text-align: center; }

.main-col { margin-left: var(--app-sidebar-w); flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: .75rem;
    padding: .65rem 1.5rem; background: var(--bs-body-bg); border-bottom: 1px solid var(--bs-border-color);
    backdrop-filter: blur(6px);
}
.topbar-title { font-size: 1.15rem; font-weight: 600; margin: 0; }
.content { padding: 1.5rem; flex: 1; }
.app-footer { padding: .9rem 1.5rem; font-size: .8rem; color: var(--bs-secondary-color); }
.btn-icon { width: 2.4rem; height: 2.4rem; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; border: 0; font-size: 1.2rem; color: var(--bs-body-color); }
.btn-icon:hover { background: rgba(var(--app-primary-rgb), .12); }
.user-chip { display: inline-flex; align-items: center; gap: .5rem; border: 0; border-radius: 2rem; padding: .25rem .75rem .25rem .3rem; }
.user-chip:hover { background: rgba(var(--app-primary-rgb), .12); }
.avatar { width: 2rem; height: 2rem; border-radius: 50%; background: var(--app-primary); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: .9rem; }
.sidebar-backdrop { display: none; }

/* Tarjetas y tablas */
.card { border: 0; border-radius: var(--app-radius); box-shadow: 0 1px 3px rgba(20, 24, 60, .08), 0 4px 14px rgba(20, 24, 60, .04); }
[data-bs-theme="dark"] .card { background: var(--bs-secondary-bg); box-shadow: none; border: 1px solid var(--bs-border-color); }
.table > :not(caption) > * > * { padding: .7rem .9rem; }
.table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--bs-secondary-color); font-weight: 600; white-space: nowrap; }
.table thead th a { color: inherit; text-decoration: none; }
.table thead th a:hover { color: var(--app-primary); }
.table-actions { white-space: nowrap; text-align: right; }
.stat-card { display: flex; align-items: center; gap: 1rem; padding: 1.1rem 1.25rem; }
.stat-icon { width: 3rem; height: 3rem; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; background: rgba(var(--app-primary-rgb), .14); color: var(--app-primary); }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: .8rem; color: var(--bs-secondary-color); }
.badge-estado { font-weight: 500; }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem;
    background: linear-gradient(135deg, #1f2547 0%, #3949ab 100%); }
.login-card { width: 100%; max-width: 410px; padding: 2rem; border-radius: 16px; }
.login-logo { width: 3.6rem; height: 3.6rem; border-radius: 16px; background: rgba(var(--app-primary-rgb), .14); color: var(--app-primary);
    display: flex; align-items: center; justify-content: center; font-size: 1.9rem; margin: 0 auto 1rem; }

/* Responsive */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .4); }
    .main-col { margin-left: 0; }
    .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 1035; }
    .content { padding: 1rem; }
    .topbar { padding: .55rem 1rem; }
}
@media print {
    .sidebar, .topbar, .app-footer, .no-print { display: none !important; }
    .main-col { margin: 0; }
}

/* ---- Inventario (Fase 2) ---- */
.ficha-head { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; }
.ficha-codigo { font-size: 1.5rem; font-weight: 700; letter-spacing: .5px; color: var(--app-primary); }
.ficha-foto { width: 84px; height: 84px; object-fit: cover; border-radius: 14px; background: var(--bs-tertiary-bg); }
.ficha-foto-vacia { width: 84px; height: 84px; border-radius: 14px; background: rgba(var(--app-primary-rgb), .12); color: var(--app-primary); display: flex; align-items: center; justify-content: center; font-size: 2rem; }
.nav-tabs .nav-link { color: var(--bs-secondary-color); }
.nav-tabs .nav-link.active { color: var(--app-primary); font-weight: 600; }
.dl-ficha dt { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--bs-secondary-color); font-weight: 600; }
.dl-ficha dd { margin-bottom: .9rem; }
.galeria { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 1rem; }
.galeria-item { border: 1px solid var(--bs-border-color); border-radius: var(--app-radius); overflow: hidden; background: var(--bs-body-bg); }
.galeria-item button.thumb { display: block; width: 100%; padding: 0; border: 0; background: var(--bs-tertiary-bg); cursor: zoom-in; }
.galeria-item img { width: 100%; height: 140px; object-fit: cover; display: block; }
.foto-prev { width: 84px; height: 84px; object-fit: cover; border-radius: 10px; margin: .5rem .5rem 0 0; border: 1px solid var(--bs-border-color); }
.visor-img { max-width: 100%; max-height: 70vh; display: block; margin: 0 auto; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 1.25rem; border-left: 2px solid var(--bs-border-color); }
.timeline li { position: relative; padding: 0 0 1.1rem 1rem; }
.timeline li::before { content: ""; position: absolute; left: -1.62rem; top: .35rem; width: .7rem; height: .7rem; border-radius: 50%; background: var(--app-primary); border: 2px solid var(--bs-body-bg); }
.activo-form.was-validated .form-control:invalid, .activo-form.was-validated .form-select:invalid { border-color: var(--bs-danger); }

/* ---- Fase 3: movimientos, entregas y actas ---- */
.picker-res { max-height: 280px; overflow-y: auto; }
.acta-frame { width: 100%; height: 75vh; border: 0; }
.logo-config { max-height: 64px; max-width: 160px; border: 1px solid var(--bs-border-color); border-radius: .375rem; padding: .25rem; background: #fff; }
.picker-col-estado { min-width: 150px; }
.picker-col-obs { min-width: 180px; }

/* ---- Fase 4: devoluciones y traslados ---- */
.dev-detalle > td { background: var(--bs-tertiary-bg); border-bottom: 1px solid var(--bs-border-color); }
.dev-detalle[hidden] { display: none; }
#devTabla tr[hidden] { display: none; }
.dest-grupo[hidden] { display: none; }
.chart-box { position: relative; height: 260px; }
.w-640 { max-width: 640px; }
.col-check { width: 2.5rem; }

/* ---- Mesa de ayuda ---- */
.tic-timeline { padding-left: 1.4rem; }
.tic-evento-interno > div:first-child { background: rgba(255, 193, 7, .12); border-radius: .5rem; padding: .15rem .5rem; }
.tic-mensaje { overflow-wrap: anywhere; }
.tic-kpi { text-decoration: none; color: inherit; transition: transform .12s ease; }
.tic-kpi:hover { transform: translateY(-2px); color: inherit; }
.tic-kpi.activo { outline: 2px solid var(--app-primary); }
.tic-trans-grid { display: flex; flex-wrap: wrap; gap: .5rem; }
.tic-pre { white-space: pre-wrap; overflow-wrap: anywhere; }

/* Portal del trabajador (layout independiente) */
.portal-topbar { background: var(--app-sidebar-bg); color: #fff; }
.portal-topbar .portal-brand { display: flex; align-items: center; gap: .6rem; font-weight: 600; font-size: 1.1rem; color: #fff; text-decoration: none; }
.portal-topbar .portal-brand i { font-size: 1.5rem; color: #9fa8da; }
.portal-topbar .btn-icon { color: #fff; }
.portal-main { max-width: 1040px; }
.portal-hero { text-align: center; padding: 3rem 1.25rem; }
.portal-hero .login-logo { width: 4.2rem; height: 4.2rem; font-size: 2.2rem; }
.portal-ticket-card { text-decoration: none; color: inherit; display: block; }
.portal-ticket-card:hover { color: inherit; background: rgba(var(--app-primary-rgb), .06); }
@media (max-width: 575.98px) {
    .portal-hero { padding: 2rem .5rem; }
}
.tic-asunto { max-width: 280px; }
.tic-col-min { min-width: 9rem; }

/* ---- Aceptación electrónica de actas ---- */
.firma-pad { position: relative; border: 2px dashed var(--bs-border-color); border-radius: var(--app-radius); background: #fff; }
.firma-canvas { display: block; width: 100%; height: 220px; touch-action: none; cursor: crosshair; border-radius: calc(var(--app-radius) - 2px); background: #fff; }
.firma-canvas:focus-visible { outline: 3px solid var(--app-primary); outline-offset: 2px; }
.firma-placeholder { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 1rem; color: #7a7f99; pointer-events: none; user-select: none; }
.firma-frame { width: 100%; height: 70vh; border: 1px solid var(--bs-border-color); border-radius: .5rem; background: #fff; }
@media (max-width: 575.98px) { .firma-frame { height: 55vh; } }
.ticket-paste-zone { display:flex; align-items:center; justify-content:center; gap:.75rem; min-height:92px; padding:1rem; text-align:center; border:2px dashed var(--bs-border-color); border-radius:var(--app-radius); cursor:pointer; transition:border-color .15s,background-color .15s; }
.ticket-paste-zone:hover,.ticket-paste-zone:focus-visible,.ticket-paste-zone-activa { border-color:var(--app-primary); background:rgba(var(--bs-primary-rgb),.06); outline:none; }
.ticket-paste-zone-ok { border-color:var(--bs-success); }
.ticket-paste-preview { overflow:hidden; border:1px solid var(--bs-border-color); border-radius:.5rem; background:var(--bs-body-bg); }
.ticket-paste-preview img { display:block; width:100%; height:120px; object-fit:contain; background:#fff; }
