/* ============================================================
   Intranet CPI México — Hoja de estilos principal
   Paleta: Negro #1A1A1A | Rojo #C41230 | Blanco #FFFFFF
   ============================================================ */

:root {
    --cpi-black:     #1A1A1A;
    --cpi-red:       #C41230;
    --cpi-red-dark:  #9E0E27;
    --cpi-red-light: #F8E8EB;
    --cpi-white:     #FFFFFF;
    --cpi-gray-100:  #F4F4F4;
    --cpi-gray-200:  #E9ECEF;
    --cpi-gray-500:  #6C757D;
    --cpi-gray-800:  #343A40;

    --sidebar-width: 240px;
    --navbar-height: 58px;
}

/* ── Reset & base ──────────────────────────────────────────── */
* { box-sizing: border-box; }
body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; }

/* ── Colores de marca ──────────────────────────────────────── */
.text-cpi-red  { color: var(--cpi-red) !important; }
.bg-cpi-red    { background-color: var(--cpi-red) !important; }

/* ── Botón principal ───────────────────────────────────────── */
.btn-cpi {
    background-color: var(--cpi-red);
    border-color: var(--cpi-red);
    color: #fff;
    font-weight: 500;
}
.btn-cpi:hover, .btn-cpi:focus {
    background-color: var(--cpi-red-dark);
    border-color: var(--cpi-red-dark);
    color: #fff;
}
.btn-cpi:disabled { opacity: .65; }

/* ════════════════════════════════════════════════════════════
   LAYOUT DE AUTENTICACIÓN
   ════════════════════════════════════════════════════════════ */
.auth-body {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--cpi-black) 0%, #2d2d2d 50%, #1a1a1a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}

.auth-wrapper {
    width: 100%;
    max-width: 440px;
}

.auth-card {
    background: #fff;
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0,0,0,.35);
}

.auth-logo {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 2px solid var(--cpi-gray-200);
}
.auth-logo-img  { height: 52px; object-fit: contain; }
.auth-logo-text { display: flex; flex-direction: column; }
.auth-logo-title { font-size: 1.1rem; font-weight: 700; color: var(--cpi-black); line-height: 1.1; }
.auth-logo-sub   { font-size: .78rem; color: var(--cpi-red); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }

.auth-form-title { font-size: 1.4rem; font-weight: 700; color: var(--cpi-black); margin-bottom: 4px; }
.auth-icon-badge { width: 64px; height: 64px; background: var(--cpi-red-light); border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto; }

.auth-footer {
    text-align: center;
    color: rgba(255,255,255,.4);
    font-size: .78rem;
    margin-top: 20px;
}

/* ════════════════════════════════════════════════════════════
   LAYOUT PRINCIPAL (APP)
   ════════════════════════════════════════════════════════════ */
.app-body {
    background: var(--cpi-gray-100);
    min-height: 100vh;
}

/* Navbar */
.app-navbar {
    background: var(--cpi-black);
    height: var(--navbar-height);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    box-shadow: 0 2px 10px rgba(0,0,0,.3);
}
.navbar-brand-label {
    color: var(--cpi-red);
    font-weight: 700;
    font-size: .85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.navbar-toggler { border: none; padding: 4px 8px; }
.navbar-toggler:focus { box-shadow: none; }

/* Contenedor app */
.app-container {
    display: flex;
    min-height: calc(100vh - var(--navbar-height));
    margin-top: var(--navbar-height);
}

/* Sidebar */
.app-sidebar {
    width: var(--sidebar-width);
    background: var(--cpi-black);
    flex-shrink: 0;
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.15) transparent;
}

/* Offcanvas móvil */
.app-offcanvas { background: var(--cpi-black); border-right: none; }

/* Navegación sidebar */
.sidebar-nav { padding: 12px 0; }
.sidebar-nav .nav-link {
    color: rgba(255,255,255,.65);
    padding: 9px 20px;
    font-size: .875rem;
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 0;
    transition: all .15s;
    border-left: 3px solid transparent;
}
.sidebar-nav .nav-link:hover {
    color: #fff;
    background: rgba(255,255,255,.07);
}
.sidebar-nav .nav-link.active {
    color: #fff;
    background: rgba(196,18,48,.15);
    border-left-color: var(--cpi-red);
    font-weight: 600;
}
.sidebar-nav .nav-link i { font-size: 1rem; width: 18px; text-align: center; }
.sidebar-section-label {
    color: rgba(255,255,255,.3);
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 16px 20px 6px;
}

/* Contenido principal */
.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 28px 28px 40px;
    min-width: 0;
}
@media (max-width: 991px) {
    .app-main { margin-left: 0; padding: 20px 16px; }
}

/* ── Page header ──────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.page-title { font-size: 1.6rem; font-weight: 700; color: var(--cpi-black); margin: 0; }
.page-sub   { margin: 2px 0 0; font-size: .875rem; }

/* ── Tarjetas de estadística ──────────────────────────────── */
.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,.06);
    height: 100%;
}
.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    color: #fff;
    font-size: 1.4rem;
}
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--cpi-black); line-height: 1; }
.stat-label { font-size: .78rem; color: var(--cpi-gray-500); margin-top: 4px; }

/* ── Avatar de usuario ──────────────────────────────────────── */
.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--cpi-red);
    color: #fff;
    font-weight: 700;
    font-size: .85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.user-avatar.sm   { width: 30px; height: 30px; font-size: .75rem; }
.user-avatar.xl   { width: 72px; height: 72px; font-size: 1.5rem; }

/* ── Grupo chip ─────────────────────────────────────────────── */
.group-chip {
    border: 1.5px solid;
    border-radius: 20px;
    padding: 3px 10px;
    font-size: .75rem;
    font-weight: 600;
    color: var(--cpi-black);
}
.group-color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ── Iconos de tipo de documento ──────────────────────────── */
.doc-type-icon {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .6rem;
    font-weight: 800;
    letter-spacing: .5px;
    flex-shrink: 0;
}
.file-pdf  { background: #FDECEA; color: #C41230; border: 1px solid #F5C6CB; }
.file-pptx { background: #FFF3E0; color: #E65100; border: 1px solid #FFCC80; }
.file-docx { background: #E3F2FD; color: #1565C0; border: 1px solid #90CAF9; }
.file-xlsx { background: #E8F5E9; color: #2E7D32; border: 1px solid #A5D6A7; }

/* ── Zona de upload ─────────────────────────────────────────── */
.upload-zone {
    border: 2px dashed var(--cpi-gray-200);
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all .2s;
    position: relative;
    background: var(--cpi-gray-100);
}
.upload-zone:hover, .upload-zone.drag-over {
    border-color: var(--cpi-red);
    background: var(--cpi-red-light);
}
.upload-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

/* ── Badges de roles ─────────────────────────────────────────── */
.badge-superadmin  { background: #1a1a1a !important; color: #fff !important; }
.badge-titular     { background: var(--cpi-red-light) !important; color: var(--cpi-red) !important; border: 1px solid #F5C6CB; }
.badge-adjunto     { background: #FFF3E0 !important; color: #E65100 !important; border: 1px solid #FFCC80; }
.badge-especialista{ background: #E3F2FD !important; color: #1565C0 !important; border: 1px solid #90CAF9; }

/* ── Cards ───────────────────────────────────────────────────── */
.card { border-radius: 12px; }
.card-header {
    background: #fff;
    border-bottom: 1px solid var(--cpi-gray-200);
    padding: 14px 20px;
    border-radius: 12px 12px 0 0 !important;
}
.card-title { font-size: 1rem; font-weight: 600; color: var(--cpi-black); }

/* ── Tabla ───────────────────────────────────────────────────── */
.table thead th {
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    padding: 12px 16px;
    border: none;
}
.table tbody td { padding: 12px 16px; vertical-align: middle; }
.table-hover tbody tr:hover { background: var(--cpi-gray-100); }

/* ── Form controls ───────────────────────────────────────────── */
.form-control:focus, .form-select:focus {
    border-color: var(--cpi-red);
    box-shadow: 0 0 0 .2rem rgba(196,18,48,.15);
}
.form-check-input:checked {
    background-color: var(--cpi-red);
    border-color: var(--cpi-red);
}
.input-group-text {
    background: var(--cpi-gray-100);
    color: var(--cpi-gray-500);
}

/* ── Alerts ──────────────────────────────────────────────────── */
.alert { border-radius: 10px; }

/* ── Pagination ──────────────────────────────────────────────── */
.page-link { color: var(--cpi-black); }
.page-item.active .page-link {
    background-color: var(--cpi-red);
    border-color: var(--cpi-red);
}
.page-link:hover { color: var(--cpi-red); }

/* ── Dropdown ────────────────────────────────────────────────── */
.dropdown-menu { border-radius: 10px; border: 1px solid var(--cpi-gray-200); }
.dropdown-item:hover { background: var(--cpi-gray-100); }
.dropdown-item.text-danger:hover { background: #FFF0F0; }

/* ── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,.2); border-radius: 3px; }

/* ── Utilidades ──────────────────────────────────────────────── */
.min-w-0 { min-width: 0; }
.text-purple { color: #5C3D8F !important; }
.bg-purple-subtle { background-color: #F3EEF9 !important; }
