/* ============================================
   TASKFLOW — Sistema de diseño centralizado
   Todos los estilos en un solo lugar
   ============================================ */

/* ===== VARIABLES ===== */
:root {
    --tf-primary: #4099ff;
    --tf-primary-dark: #2b7de9;
    --tf-success: #2ed8b6;
    --tf-danger: #ff5370;
    --tf-warning: #ffb64d;
    --tf-purple: #9b59b6;
    --tf-dark: #2b3140;
    --tf-muted: #8b97ad;
    --tf-border: #e8edf2;
    --tf-bg: #f4f7fa;
    --tf-white: #ffffff;
    --tf-sidebar-bg: #1e2533;
    --tf-sidebar-text: #d0d7e3;
    --tf-sidebar-sub: #8b97ad;
    --tf-header-h: 50px;
    --tf-sidebar-w: 235px;
}

/* ===== SIDEBAR ===== */
.pcoded-navbar {
    background: var(--tf-sidebar-bg) !important;
    width: var(--tf-sidebar-w) !important;
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    z-index: 1000 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

.pcoded-navbar:focus {
    outline: none !important;
}

.sidebar-logo {
    background: #161c28 !important;
    height: var(--tf-header-h) !important;
    display: flex !important;
    align-items: center !important;
    padding: 0 14px !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06) !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 10 !important;
    text-decoration: none !important;
}

.sidebar-logo svg {
    flex-shrink: 0;
    width: 24px !important;
    height: 24px !important;
}

.sidebar-logo-text {
    font-size: 15px;
    font-weight: 700;
    color: var(--tf-white);
    letter-spacing: 0.5px;
    margin-left: 8px;
}

.sidebar-logo-text span {
    color: var(--tf-primary);
}

.pcoded-navbar .pcoded-navigation-label {
    color: var(--tf-sidebar-sub) !important;
    font-size: 9px !important;
    padding: 6px 14px 2px !important;
    letter-spacing: 1.5px !important;
    text-transform: uppercase !important;
    font-weight: 600 !important;
}

.pcoded-navbar .pcoded-item li a {
    color: var(--tf-sidebar-text) !important;
    padding: 6px 14px !important;
    display: flex !important;
    align-items: center !important;
    text-decoration: none !important;
    border-left: 3px solid transparent !important;
    transition: all 0.2s ease !important;
    font-size: 12px !important;
}

.pcoded-navbar .pcoded-item li a:hover,
.pcoded-navbar .pcoded-item li.active > a {
    color: var(--tf-white) !important;
    background: rgba(64, 153, 255, 0.12) !important;
    border-left: 3px solid var(--tf-primary) !important;
}

.pcoded-navbar .pcoded-micon {
    margin-right: 8px !important;
    font-size: 13px !important;
    width: 16px !important;
    text-align: center !important;
    opacity: 0.8;
}

.pcoded-navbar .pcoded-item li.active > a .pcoded-micon {
    opacity: 1;
}

.nav-list {
    margin-top: 0 !important;
}

/* ===== HEADER ===== */
.tf-header {
    position: fixed !important;
    top: 0 !important;
    left: var(--tf-sidebar-w) !important;
    right: 0 !important;
    height: var(--tf-header-h) !important;
    background: var(--tf-white) !important;
    border-bottom: 1px solid var(--tf-border) !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06) !important;
    z-index: 999 !important;
    display: flex !important;
    align-items: center !important;
    padding: 0 20px !important;
    justify-content: space-between !important;
}

.tf-header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.tf-header-right {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-left: auto;
}

.tf-header a {
    color: var(--tf-muted);
    font-size: 18px;
    text-decoration: none;
}

.tf-header a:hover {
    color: var(--tf-dark);
}

.pcoded-header.navbar {
    display: none !important;
}

/* ===== LAYOUT PRINCIPAL ===== */
.pcoded-main-container {
    margin-left: var(--tf-sidebar-w) !important;
    padding-top: var(--tf-header-h) !important;
}

.pcoded-content {
    background: var(--tf-bg) !important;
    min-height: calc(100vh - var(--tf-header-h)) !important;
    padding: 25px !important;
}

/* ===== PAGE HEADER ===== */
.page-header {
    background: var(--tf-white) !important;
    border-radius: 8px !important;
    padding: 16px 24px !important;
    margin-bottom: 24px !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06) !important;
}

.page-header .row {
    width: 100% !important;
    margin: 0 !important;
}

.page-header-title {
    display: flex !important;
    align-items: center !important;
}

.page-header-title .d-inline:first-child i {
    padding: 10px 12px !important;
    border-radius: 6px !important;
    color: var(--tf-white) !important;
    margin-right: 12px !important;
    font-size: 18px !important;
}

.page-header-title .d-inline:last-child h5 {
    margin: 0 !important;
    font-size: 18px !important;
    font-weight: 600 !important;
    color: var(--tf-dark) !important;
}

.page-header-title .d-inline:last-child span {
    font-size: 13px !important;
    color: var(--tf-muted) !important;
}

.page-header-breadcrumb {
    display: flex !important;
    justify-content: flex-end !important;
    align-items: center !important;
}

.breadcrumb {
    background: transparent !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* ===== CARDS ===== */
.card {
    border: none !important;
    border-radius: 8px !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08) !important;
    margin-bottom: 24px !important;
    background: var(--tf-white) !important;
}

.card-block {
    padding: 24px !important;
}

/* ===== COLORES SEMÁFORO ===== */
.bg-c-blue {
    background: var(--tf-primary) !important;
}
.bg-c-green {
    background: var(--tf-success) !important;
}
.bg-c-red {
    background: var(--tf-danger) !important;
}
.bg-c-yellow {
    background: var(--tf-warning) !important;
}
.bg-c-purple {
    background: var(--tf-purple) !important;
}

/* ===== COMPONENTES REUTILIZABLES ===== */

/* Badge de estado */
.tf-badge {
    padding: 4px 10px;
    border-radius: 20px;
    color: var(--tf-white);
    font-size: 11px;
    font-weight: 600;
    display: inline-block;
    white-space: nowrap;
}

/* Avatar circular */
.tf-avatar {
    border-radius: 50%;
    background: var(--tf-primary);
    color: var(--tf-white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}

.tf-avatar-sm {
    width: 28px;
    height: 28px;
    font-size: 11px;
}
.tf-avatar-md {
    width: 34px;
    height: 34px;
    font-size: 14px;
}
.tf-avatar-lg {
    width: 48px;
    height: 48px;
    font-size: 18px;
}
.tf-avatar-xl {
    width: 80px;
    height: 80px;
    font-size: 32px;
}

/* Tabla estándar */
.tf-table th {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--tf-muted);
    font-weight: 600;
    border-bottom: 2px solid var(--tf-border);
    padding: 12px;
}

.tf-table td {
    vertical-align: middle;
    font-size: 14px;
    padding: 12px;
    border-bottom: 1px solid var(--tf-bg);
}

.tf-table tr:hover td {
    background: #fafbfc;
}

/* Indicador estadístico */
.tf-stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    color: var(--tf-white);
    font-size: 20px;
}

.tf-stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--tf-dark);
    margin: 8px 0 2px;
}

.tf-stat-label {
    font-size: 12px;
    color: var(--tf-muted);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Indicador circular */
.tf-gauge {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: conic-gradient(
        var(--tf-primary) calc(var(--pct) * 1%),
        var(--tf-border) 0
    );
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.tf-gauge::before {
    content: "";
    position: absolute;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--tf-white);
}

.tf-gauge-value {
    position: relative;
    z-index: 1;
    font-size: 22px;
    font-weight: 700;
    color: var(--tf-dark);
}

/* Barra de progreso */
.tf-progress {
    height: 6px;
    border-radius: 3px;
    background: var(--tf-border);
    overflow: hidden;
}

.tf-progress-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* Selector de color */
.tf-color-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: transform 0.2s;
}

.tf-color-dot.selected,
.tf-color-dot:hover {
    border-color: var(--tf-dark);
    transform: scale(1.2);
}

/* Alertas */
.tf-alert {
    padding: 12px 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    font-size: 14px;
}

.tf-alert-success {
    background: #f0fdf9;
    border-left: 4px solid var(--tf-success);
    color: #1a7a5e;
}
.tf-alert-danger {
    background: #fff5f7;
    border-left: 4px solid var(--tf-danger);
    color: #c0392b;
}
.tf-alert-warning {
    background: #fffbf0;
    border-left: 4px solid var(--tf-warning);
    color: #9a6700;
}

/* Formularios */
.tf-form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--tf-dark);
    margin-bottom: 6px;
    display: block;
}

.tf-section-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--tf-muted);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tf-section-label::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--tf-border);
}

/* Checkbox de permisos */
.tf-perm-card {
    border: 1px solid var(--tf-border);
    border-radius: 6px;
    padding: 10px 12px;
    transition: all 0.2s;
    cursor: pointer;
}

.tf-perm-card:hover {
    border-color: var(--tf-primary);
    background: #f8fbff;
}
.tf-perm-card:has(input:checked) {
    border-color: var(--tf-primary);
    background: #f0f5ff;
}

/* Form check override */
.form-check-input:checked {
    background-color: var(--tf-primary);
    border-color: var(--tf-primary);
}

/* Header avatar */
.tf-header-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--tf-primary);
    color: var(--tf-white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}

/* Dropdown override */
.dropdown-menu {
    border: none !important;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.12) !important;
    border-radius: 8px !important;
    margin-top: 10px !important;
}

.dropdown-item {
    font-size: 13px !important;
    padding: 10px 16px !important;
    color: var(--tf-dark) !important;
}

.dropdown-item:hover {
    background: var(--tf-bg) !important;
}

/* Fix: ícono visible en items activos del sidebar */
.pcoded-navbar .pcoded-item li.active > a .pcoded-micon i,
.pcoded-navbar .pcoded-item li > a .pcoded-micon i {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    color: var(--tf-sidebar-text) !important;
}

.pcoded-navbar .pcoded-item li.active > a .pcoded-micon i {
    color: var(--tf-white) !important;
}

/* ============================================
   TASKFLOW — Responsive / Mobile
   ============================================ */

/* ===== BOTÓN HAMBURGUESA (solo móvil) ===== */
.tf-menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    color: var(--tf-dark);
    font-size: 22px;
    line-height: 1;
}

/* ===== OVERLAY del sidebar en móvil ===== */
.tf-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 999;
}

.tf-sidebar-overlay.active {
    display: block;
}

/* ===== TABLET (≤ 992px) ===== */
@media (max-width: 992px) {
    .pcoded-navbar {
        transform: translateX(-100%) !important;
        transition: transform 0.28s ease !important;
        z-index: 1100 !important;
    }

    .pcoded-navbar.mobile-open {
        transform: translateX(0) !important;
    }

    .tf-header {
        left: 0 !important;
        padding: 0 14px !important;
    }

    .pcoded-main-container {
        margin-left: 0 !important;
    }

    .tf-menu-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
    }

    .page-header .row > [class*="col-lg"] {
        width: 100% !important;
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    .page-header-breadcrumb {
        justify-content: flex-start !important;
        margin-top: 6px !important;
    }
}

/* ===== MÓVIL (≤ 576px) ===== */
@media (max-width: 576px) {
    .pcoded-content {
        padding: 14px !important;
    }

    .card-block {
        padding: 16px !important;
    }

    .row .col-md-3 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    .table-responsive {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .tf-table th,
    .tf-table td {
        font-size: 12px !important;
        padding: 8px !important;
        white-space: nowrap;
    }

    .row .col-md-6,
    .row .col-md-4,
    .row .col-md-3,
    .row .col-md-8 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    .d-flex.gap-2.justify-content-end {
        flex-direction: column !important;
    }

    .d-flex.gap-2.justify-content-end .btn {
        width: 100% !important;
    }

    .page-header {
        padding: 12px 14px !important;
        margin-bottom: 14px !important;
    }

    .page-header-title .d-inline:first-child i {
        padding: 7px 9px !important;
        font-size: 14px !important;
    }

    .page-header-title .d-inline:last-child h5 {
        font-size: 15px !important;
    }

    .page-header-breadcrumb {
        display: none !important;
    }

    .tf-header-right {
        gap: 8px !important;
    }

    .sidebar-logo-text {
        font-size: 16px !important;
    }

    .card-block h3.fw-bold {
        font-size: 1.5rem !important;
    }

    .col-lg-4 {
        margin-top: 0 !important;
    }
}

/* ===== GRÁFICAS — fix overflow móvil ===== */
#chart-estados,
#chart-financiero {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
}

#chart-estados > *,
#chart-financiero > * {
    max-width: 100% !important;
}

#chart-estados > div,
#chart-financiero > div:first-child {
    min-width: 480px;
}
