/* ===== BethMining — UX moderno ===== */

:root {
    /* Paleta BethMining: negro profundo + carbon + amarillo + blanco */
    --primary: #0F0F0F;
    --primary-light: #2A2929;
    --primary-soft: #FFF8CC;   /* amarillo muy diluido para hovers/highlights suaves */
    --accent: #FFD000;
    --accent-dark: #d4ae00;
    --bg: #FAFAFA;
    --surface: #FFFFFF;
    --border: #E5E5E5;
    --text: #0F0F0F;
    --text-muted: #5B5B5B;
    --success: #16a34a;
    --warning: #FFD000;
    --danger: #dc2626;
    --info: #2563eb;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.14), 0 4px 6px -2px rgba(0, 0, 0, 0.06);
    --radius: 0.5rem;
    --radius-lg: 0.75rem;

    /* Overrides Bootstrap para que bg-primary, text-primary, etc. usen la nueva paleta */
    --bs-primary: #0F0F0F;
    --bs-primary-rgb: 15, 15, 15;
    --bs-warning: #FFD000;
    --bs-warning-rgb: 255, 208, 0;
}

body {
    background: var(--bg);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text);
    font-size: 0.92rem;
    line-height: 1.55;
}

/* ===== Navbar ===== */
.navbar.bg-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%) !important;
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
}
.navbar-brand {
    font-size: 1.05rem;
    letter-spacing: 0.3px;
    padding: 0.3rem 0;
}
.navbar-brand i {
    color: var(--accent);
}
.brand-logo {
    height: 36px;
    width: auto;
    object-fit: contain;
    filter: brightness(0) invert(1);
    transition: filter 0.2s, transform 0.2s;
}
.navbar-brand:hover .brand-logo {
    transform: scale(1.05);
}
.nav-link {
    transition: all 0.2s;
    border-radius: var(--radius);
    margin: 0 2px;
    padding: 0.4rem 0.7rem !important;
}
.nav-link:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: translateY(-1px);
}
.dropdown-menu {
    border: 0;
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius);
    padding: 0.5rem;
    margin-top: 0.5rem !important;
}
.dropdown-item {
    border-radius: 0.35rem;
    padding: 0.5rem 0.75rem;
    transition: all 0.15s;
}
.dropdown-item:hover {
    background: var(--primary-soft);
    transform: translateX(2px);
}
.dropdown-item i {
    width: 18px;
    text-align: center;
    margin-right: 6px;
    color: var(--primary);
}

/* ===== Cards ===== */
.card {
    border: 0;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s, transform 0.2s;
}
.card.shadow-soft, .shadow-soft {
    box-shadow: var(--shadow) !important;
}
.card-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    padding: 0.85rem 1.1rem;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
}
.card-body {
    padding: 1.1rem;
}

/* KPI cards con borde lateral animado */
.kpi-card {
    border-left: 4px solid var(--primary);
    transition: transform 0.18s, box-shadow 0.18s;
    cursor: default;
    overflow: hidden;
    position: relative;
}
.kpi-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 60%, var(--primary-soft) 100%);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}
.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}
.kpi-card:hover::before { opacity: 0.6; }
.kpi-card.success { border-left-color: var(--success); }
.kpi-card.warning { border-left-color: var(--warning); }
.kpi-card.danger  { border-left-color: var(--danger); }
.kpi-card.info    { border-left-color: var(--info); }
.kpi-value {
    font-size: 2.1rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.25rem;
    letter-spacing: -0.5px;
}
.kpi-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.7px;
    font-weight: 600;
}

/* ===== Tables ===== */
.table {
    --bs-table-hover-bg: var(--primary-soft);
}
.table thead { background: var(--surface); }
.table thead th {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom-width: 1px;
    padding: 0.75rem;
}
.table tbody td {
    padding: 0.75rem;
    vertical-align: middle;
    border-color: var(--border);
}
.table-hover tbody tr {
    transition: background 0.1s;
}

/* ===== Buttons ===== */
.btn {
    border-radius: var(--radius);
    transition: all 0.15s;
    font-weight: 500;
}
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}
.btn-primary:hover {
    background: var(--primary-light);
    border-color: var(--primary-light);
}
.btn-lift:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}
.btn-icon {
    padding: 0.3rem 0.55rem;
}
.btn-group-sm > .btn {
    transition: all 0.15s;
}
.btn-group-sm > .btn:hover {
    z-index: 2;
    transform: scale(1.08);
}

/* ===== Badges ===== */
.badge {
    font-weight: 500;
    padding: 0.4em 0.65em;
    letter-spacing: 0.3px;
    border-radius: 0.35rem;
}

/* ===== Avatar circles ===== */
.avatar-circle {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center; justify-content: center;
    color: #fff; font-weight: 600;
    font-size: 0.95rem;
    flex-shrink: 0;
}
.avatar-circle-lg {
    width: 72px; height: 72px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center; justify-content: center;
    color: #fff; font-weight: 700;
    font-size: 2rem;
}

/* ===== Forms ===== */
.form-control, .form-select {
    border-radius: var(--radius);
    border-color: var(--border);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.18rem rgba(255, 208, 0, 0.35);
}
.form-control-lg {
    padding: 0.6rem 0.85rem;
    font-size: 1rem;
}
.form-label {
    font-size: 0.83rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.35rem;
}
.input-group-text {
    background: var(--primary-soft);
    border-color: var(--border);
    color: var(--primary);
}

/* ===== Tabs ===== */
.nav-tabs {
    border-bottom: 2px solid var(--border);
}
.nav-tabs .nav-link {
    border: 0;
    color: var(--text-muted);
    font-weight: 500;
    padding: 0.6rem 1rem;
    position: relative;
    background: transparent !important;
    margin: 0 !important;
}
.nav-tabs .nav-link::after {
    content: '';
    position: absolute;
    bottom: -2px; left: 0;
    width: 0; height: 2px;
    background: var(--primary);
    transition: width 0.2s;
}
.nav-tabs .nav-link:hover { color: var(--primary); }
.nav-tabs .nav-link.active {
    color: var(--primary);
    font-weight: 600;
}
.nav-tabs .nav-link.active::after { width: 100%; }

/* ===== Alerts ===== */
.alert {
    border: 0;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 0.85rem 1rem;
}
.alert-success { background: #d1fae5; color: #065f46; }
.alert-warning { background: #fef3c7; color: #78350f; }
.alert-danger  { background: #fee2e2; color: #7f1d1d; }
.alert-info    { background: #dbeafe; color: #1e3a8a; }

/* ===== Animations ===== */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.fade-in-up { animation: fadeInUp 0.3s ease-out; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}
.pulse { animation: pulse 1.5s infinite; }

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Skeleton loader */
.skeleton {
    background: linear-gradient(90deg, #eee 0%, #f5f5f5 50%, #eee 100%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.4s infinite;
    border-radius: var(--radius);
}
@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ===== Modal ===== */
.modal-content {
    border: 0;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}
.modal-header {
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.25rem;
}
.modal-footer {
    border-top: 1px solid var(--border);
    padding: 0.85rem 1.25rem;
}

/* ===== Progress bars ===== */
.progress {
    border-radius: 1rem;
    background: var(--border);
    overflow: hidden;
}
.progress-bar {
    transition: width 0.5s ease-out;
}

/* ===== Login page ===== */
.login-page-bg {
    background: linear-gradient(135deg, #000000 0%, var(--primary) 50%, var(--primary-light) 100%);
    min-height: 100vh;
    position: relative;
    overflow: hidden;
}
.login-page-bg::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 20% 30%, rgba(255, 208, 0, 0.18) 0, transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(255, 208, 0, 0.10) 0, transparent 40%);
}

/* ===== Notification badge in navbar ===== */
.notification-badge {
    font-size: 0.65rem !important;
    padding: 0.25em 0.45em;
    box-shadow: 0 0 0 2px var(--primary);
    animation: pulse 2s infinite;
}

/* ===== Footer ===== */
footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}

/* ===== Utilities ===== */
.cursor-pointer { cursor: pointer; }
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* DataTables search styling */
.dataTables_filter input {
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 0.3rem 0.6rem;
}
.dataTables_length select {
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.page-link {
    border-radius: var(--radius);
    margin: 0 2px;
    border: 1px solid var(--border);
    color: var(--primary);
}
.page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
}

/* Chart containers */
.chart-container {
    position: relative;
    height: 250px;
}

/* Floating Action Button "Ayuda" */
.fab-help {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1040;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    border: 0;
    border-radius: 50px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: var(--accent);
    font-weight: 600;
    font-size: 0.92rem;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    animation: fabPulse 3s ease-in-out 2;
}
.fab-help:hover {
    transform: translateY(-3px) scale(1.04);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
    color: var(--accent);
}
.fab-help:active {
    transform: translateY(-1px) scale(1.02);
}
.fab-help i {
    font-size: 1.3rem;
    color: var(--accent);
}
@media (max-width: 576px) {
    .fab-help {
        bottom: 18px;
        right: 18px;
        padding: 12px;
        border-radius: 50%;
        width: 52px;
        height: 52px;
        justify-content: center;
    }
    .fab-help-label { display: none; }
    .fab-help i { font-size: 1.4rem; margin: 0; }
}
@keyframes fabPulse {
    0%, 100% { box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35); }
    50% { box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35), 0 0 0 12px rgba(255, 208, 0, 0.28); }
}

/* Stat icon (decoración para KPIs) */
.stat-icon {
    position: absolute;
    top: 1rem; right: 1rem;
    font-size: 2rem;
    opacity: 0.15;
}

/* Fotos de operadores */
.operador-foto-header {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--primary-soft);
    box-shadow: var(--shadow);
    transition: transform 0.2s, border-color 0.2s;
}
.operador-foto-header:hover {
    transform: scale(1.05);
    border-color: var(--primary);
}
.operador-foto-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    font-size: 1.8rem;
}
.operador-foto-grande {
    max-width: 100%;
    height: auto;
    border-radius: 0.5rem;
    box-shadow: var(--shadow);
}
.operador-mini {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
}
.operador-mini-placeholder {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    font-size: 0.8rem;
    border: 2px solid var(--border);
}

/* ===== MEJORAS UX (2026) ===== */

/* Accesibilidad: foco visible al navegar con teclado */
a:focus-visible, button:focus-visible, .btn:focus-visible,
.form-control:focus-visible, .form-select:focus-visible {
    outline: 3px solid rgba(255, 208, 0, 0.55);
    outline-offset: 2px;
}

/* Barra de progreso de navegación (feedback inmediato de clic) */
#page-progress {
    position: fixed; top: 0; left: 0; height: 3px; width: 0;
    background: linear-gradient(90deg, var(--accent), var(--accent-dark));
    z-index: 2000; transition: width 0.2s ease, opacity 0.3s ease;
    box-shadow: 0 0 8px rgba(255, 208, 0, 0.6);
}

/* Encabezado de tabla pegajoso en tablas largas */
.table thead th { position: sticky; top: 0; z-index: 2; }

/* Estado vacío amigable */
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--text-muted); }
.empty-state i { font-size: 2.8rem; opacity: 0.35; display: block; margin-bottom: 0.5rem; }
.empty-state .empty-title { font-weight: 600; color: var(--text); margin-bottom: 0.25rem; }

/* Botón "volver arriba" (sobre el FAB de ayuda) */
.back-to-top {
    position: fixed; bottom: 88px; right: 26px;
    width: 44px; height: 44px; border-radius: 50%;
    background: var(--primary); color: #fff; border: none;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; box-shadow: var(--shadow-lg);
    opacity: 0; visibility: hidden; transform: translateY(10px);
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
    z-index: 1035; cursor: pointer;
}
.back-to-top.show { opacity: 1; visibility: visible; transform: translateY(0); }
.back-to-top:hover { background: var(--primary-light); transform: translateY(-3px); }

/* Respeta a quien prefiere menos animación */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
    html { scroll-behavior: auto; }
}

html { scroll-behavior: smooth; }

/* ===== Menú lateral / layout con sidebar (2026) ===== */
:root { --sb-width: 252px; --sb-rail: 66px; --topbar-h: 56px; }

.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: var(--sb-width);
    background: linear-gradient(180deg, #0F0F0F 0%, #1c1b1b 100%);
    color: #fff; z-index: 1045; display: flex; flex-direction: column;
    transition: width 0.2s ease, transform 0.2s ease;
}
.sb-brand { display: flex; align-items: center; height: var(--topbar-h); padding: 0 16px; border-bottom: 1px solid rgba(255,255,255,0.08); flex-shrink: 0; overflow: hidden; }
.sb-brand-link { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 800; letter-spacing: 0.5px; white-space: nowrap; }
.sb-logo { height: 30px; width: auto; filter: brightness(0) invert(1); flex-shrink: 0; }
.sb-brand-text { font-size: 1.05rem; line-height: 1; }
.sb-brand-text small { display: block; font-size: 0.58rem; letter-spacing: 2.5px; color: var(--accent); font-weight: 700; margin-top: 2px; }

.sb-nav { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; padding: 8px 0 16px; }
.sb-nav::-webkit-scrollbar { width: 6px; }
.sb-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }
.sb-nav ul { list-style: none; margin: 0; padding: 0; }
.sb-link {
    display: flex; align-items: center; gap: 12px; padding: 0.6rem 0.9rem; margin: 2px 10px;
    color: rgba(255,255,255,0.82); text-decoration: none; border-radius: 9px;
    white-space: nowrap; font-size: 0.9rem; cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.sb-link:hover { background: rgba(255,255,255,0.09); color: #fff; }
.sb-link.active { background: var(--accent); color: #0F0F0F; font-weight: 700; }
.sb-ico { font-size: 1.12rem; width: 22px; text-align: center; flex-shrink: 0; }
.sb-caret { margin-left: auto; font-size: 0.72rem; transition: transform 0.2s; }
.sb-item.open > .sb-link .sb-caret { transform: rotate(180deg); }
.sb-sub { list-style: none; margin: 0; padding: 0; max-height: 0; overflow: hidden; transition: max-height 0.25s ease; }
.sb-item.open > .sb-sub { max-height: 640px; }
.sb-sub .sb-link { padding-left: 2.7rem; font-size: 0.84rem; color: rgba(255,255,255,0.7); }
.sb-sub .sb-link .sb-ico { font-size: 0.95rem; }
.sb-sub .sb-link.active { color: #0F0F0F; }
.sb-heading { color: rgba(255,255,255,0.4); font-size: 0.64rem; text-transform: uppercase; letter-spacing: 1.5px; padding: 0.6rem 1.6rem 0.2rem; }

.main-area { margin-left: var(--sb-width); min-width: 0; display: flex; flex-direction: column; min-height: 100vh; transition: margin-left 0.2s ease; }

.topbar {
    height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 10px; padding: 0 16px;
    position: sticky; top: 0; z-index: 1020; box-shadow: var(--shadow-sm);
}
.sb-toggle { background: transparent; border: 0; font-size: 1.45rem; color: var(--primary); line-height: 1; padding: 4px 9px; border-radius: 8px; cursor: pointer; }
.sb-toggle:hover { background: var(--primary-soft); }
.topbar-brand { font-weight: 800; color: var(--primary); text-decoration: none; }
.topbar .nav-link { color: var(--text); padding: 0.35rem 0.6rem !important; }
.topbar .nav-link:hover { background: var(--primary-soft); color: var(--primary); transform: none; }
.topbar .dropdown-menu { z-index: 1030; }

.content { flex: 1 1 auto; padding: 1.3rem 1.5rem; }

.sb-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1040; opacity: 0; visibility: hidden; transition: opacity 0.2s; }
body.sb-open .sb-backdrop { opacity: 1; visibility: visible; }

/* ---- Rail colapsado (solo escritorio) ---- */
@media (min-width: 992px) {
    body.sb-collapsed .sidebar { width: var(--sb-rail); }
    body.sb-collapsed .main-area { margin-left: var(--sb-rail); }
    body.sb-collapsed .sb-label,
    body.sb-collapsed .sb-caret,
    body.sb-collapsed .sb-brand-text,
    body.sb-collapsed .sb-heading { display: none; }
    body.sb-collapsed .sb-link { justify-content: center; margin-left: 8px; margin-right: 8px; padding-left: 0; padding-right: 0; }
    body.sb-collapsed .sb-brand { justify-content: center; padding: 0; }
    body.sb-collapsed .sb-item.has-sub { position: relative; }
    /* Flyout: position:fixed para NO ser recortado por el overflow de .sb-nav (el JS fija el top) */
    body.sb-collapsed .sb-item.has-sub > .sb-sub {
        position: fixed; left: var(--sb-rail); top: 0; min-width: 216px;
        max-height: calc(100vh - 16px); overflow-y: auto; display: none;
        background: #1c1b1b; border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 1050;
    }
    body.sb-collapsed .sb-item.has-sub:hover > .sb-sub,
    body.sb-collapsed .sb-item.has-sub:focus-within > .sb-sub { display: block; }
    body.sb-collapsed .sb-item.has-sub:hover > .sb-sub .sb-label,
    body.sb-collapsed .sb-item.has-sub:focus-within > .sb-sub .sb-label { display: inline; }
    body.sb-collapsed .sb-sub .sb-link { padding-left: 0.9rem; justify-content: flex-start; }
    body.sb-collapsed .sb-link:focus-visible { outline-offset: -2px; }
}

/* ---- Móvil: menú como cajón deslizable ---- */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    body.sb-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0,0,0,0.5); }
    .main-area { margin-left: 0; }
}
