/* 
 * MAIN CUSTOM CSS - NIEOK CRM
 * Este archivo centraliza todos los estilos personalizados del proyecto.
 */

:root {
    --sidebar-width: 240px;
    --sidebar-r-width: 320px;
    --header-height: 40px;
    --footer-height: 30px;
    --primary-bg: #3a4651;
    --text-muted: rgba(255, 255, 255, 0.7);
    --border-color: #e9ecef;
}

/* --- Base & Reset --- */
body { 
    font-family: 'Inter', sans-serif !important; 
    margin: 0;
    overflow: hidden !important; 
    height: 100vh; 
    background-color: #f8fafc;
}

body.landing-page {
    overflow: auto !important;
    height: auto !important;
}

html { height: 100%; }

.main-wrapper, .app { 
    height: 100vh; 
    overflow: hidden !important; 
    display: flex;
    flex-direction: column;
}

/* --- Layout: Header --- */
.header { 
    position: fixed !important; 
    top: 0; 
    left: var(--sidebar-width); 
    right: 0; 
    z-index: 1040; 
    height: var(--header-height) !important; 
    transition: all 0.3s ease; 
    background: var(--primary-bg) !important;
    border-bottom: none !important;
    display: flex;
    align-items: center;
}

.header .fas, .header .fa, .header .name { color: #ffffff !important; }
.header-block-nav { margin-left: auto; display: flex; align-items: center; }
.header-block-collapse { display: none; }

/* --- Layout: Left Sidebar --- */
.sidebar { 
    position: fixed !important; 
    top: 0; 
    left: 0; 
    bottom: 0; 
    width: var(--sidebar-width);
    height: 100vh; 
    overflow-y: auto; 
    z-index: 1050; 
    transition: left 0.3s ease;
    background-color: var(--primary-bg) !important;
}

.sidebar-header .brand { 
    color: #fff !important; 
    font-weight: 700; 
    display: flex; 
    align-items: center; 
    padding-left: 15px; 
}

.sidebar .sidebar-menu > li > a { color: rgba(255,255,255,0.8) !important; }
.sidebar .sidebar-menu > li.active > a,
.sidebar .sidebar-menu > li > a:hover { 
    color: #fff !important; 
    background-color: rgba(0,0,0,0.15) !important; 
}

.sidebar-menu .fas, .sidebar-menu .fa { color: rgba(255,255,255,0.8) !important; }

/* --- Layout: Right Sidebar (sidebar_sz) --- */
#sidebar_sz {
    position: fixed;
    top: var(--header-height);
    right: 0;
    width: var(--sidebar-r-width);
    height: calc(101vh - var(--header-height) -2 * var(--footer-height));
    background: var(--primary-bg);
    transition: all 300ms linear;
    z-index: 1050;
    box-shadow: -3px 0 15px rgba(0,0,0,0.2);
}

#sidebar_sz.active { right: calc(-1 * var(--sidebar-r-width)); }

#sidebar_sz .toggle-btn {
    position: absolute;
    right: calc(var(--sidebar-r-width) + 12px);
    top: 30px; /* Subido para alinearse mejor con el header */
    width: 34px;
    height: 34px;
    background: #ffffff; /* Fondo blanco para contraste */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1060;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    animation: bounce-attention 4s infinite;
}

#sidebar_sz .toggle-btn i {
    color: var(--primary-bg);
    font-size: 15px;
    transition: transform 0.3s ease;
}

#sidebar_sz .toggle-btn:hover {
    transform: scale(1.1);
    background: #f8fafc;
}

#sidebar_sz:not(.active) .toggle-btn {
    animation: none; /* Detener animación cuando está abierto */
    right: calc(var(--sidebar-r-width) - 45px); /* Se mueve adentro un poco para no estorbar */
    background: rgba(255,255,255,0.2);
    color: #fff;
}

#sidebar_sz:not(.active) .toggle-btn i {
    color: #fff;
}

@keyframes bounce-attention {
    0%, 20%, 50%, 80%, 100% {transform: translateY(0);}
    40% {transform: translateY(-6px);}
    60% {transform: translateY(-3px);}
}

#sidebar_sz .nav-tabs {
    border-bottom: 1px solid rgba(255,255,255,0.1);
    background: rgba(0,0,0,0.05);
}

#sidebar_sz .nav-tabs .nav-link {
    color: var(--text-muted);
    border: none;
    border-bottom: 2px solid transparent;
    padding: 12px 20px;
}

#sidebar_sz .nav-tabs .nav-link.active {
    background: transparent;
    color: #fff;
    border-bottom: 2px solid #fff;
}

#sidebar_sz .tab-content { padding: 10px 20px 0; color: white; }

/* --- Layout: Footer --- */
.footer { 
    position: fixed !important; 
    bottom: 0; 
    left: var(--sidebar-width); 
    right: 0; 
    z-index: 1040; 
    height: var(--footer-height) !important; 
    padding: 0 !important; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    transition: all 0.3s ease; 
    background: #fff;
    border-top: 1px solid var(--border-color);
}

.footer p { color: #64748b; margin-bottom: 0; font-size: 11px; }
.footer a { color: #0d6efd; text-decoration: none; font-weight: 700; }

/* --- Layout: Main Content Area --- */
.app .content { 
    position: relative !important;
    margin-top: var(--header-height) !important; 
    margin-bottom: var(--footer-height) !important; 
    height: calc(100vh - var(--header-height) - var(--footer-height)) !important;
    overflow-y: auto !important; 
    min-height: 0 !important;
    transition: all 0.3s ease;
    padding: 20px;
}

/* --- UI Components: Cards & Tables --- */
.card { border: none; box-shadow: 0 4px 15px rgba(0,0,0,0.05); border-radius: 8px; }
.white_shd { background: #fff; padding: 20px; border-radius: 8px; box-shadow: 0 4px 15px rgba(0,0,0,0.02); }

.table thead th { 
    border-bottom: 2px solid #edf2f7; 
    color: #4a5568; 
    font-weight: 600; 
    text-transform: uppercase; 
    font-size: 11px; 
    letter-spacing: 0.5px; 
}

/* --- DataTables Customization --- */
.dataTables_wrapper .dataTables_paginate .paginate_button { padding: 0; margin-left: 0; border: none; }
.dataTables_wrapper .dataTables_filter input { border: 1px solid #e2e8f0; border-radius: 6px; padding: 4px 8px; }

table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control,
table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control {
    padding-left: 30px !important;
    position: relative;
}

table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control:before,
table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control:before {
    top: 50%; left: 5px; height: 16px; width: 16px; margin-top: -9px;
    display: block; position: absolute; color: white; border: 2px solid white;
    border-radius: 16px; text-align: center; line-height: 14px;
    box-shadow: 0 0 3px #444; box-sizing: content-box; content: '+';
    background-color: #31b131;
}

table.dataTable.dtr-inline.collapsed > tbody > tr.parent > td.dtr-control:before,
table.dataTable.dtr-inline.collapsed > tbody > tr.parent > th.dtr-control:before {
    content: '-'; background-color: #d33333;
}

/* --- Module: Wallet (Right Sidebar) --- */
.wallet-transactions-list::-webkit-scrollbar { width: 4px; }
.wallet-transactions-list::-webkit-scrollbar-thumb { 
    background: rgba(255,255,255,0.2); 
    border-radius: 4px; 
}

.sidebar-r .accordion-button::after { 
    filter: invert(1) brightness(200%); 
    transform: scale(0.7); 
}

.sidebar-r .accordion-button:not(.collapsed) { 
    background: rgba(255,255,255,0.2) !important; 
    box-shadow: none !important; 
}

/* --- Responsive Layout (Mobile) --- */
@media (max-width: 991.98px) {
    .header, .footer { left: 0 !important; }
    .header-block-collapse { display: block !important; }
    .sidebar { left: -240px !important; }
    .sidebar-open .sidebar { left: 0 !important; }
    
    .sidebar-open .sidebar-overlay {
        display: block; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
        background-color: rgba(0, 0, 0, 0.5); z-index: 1045;
    }

    .stats-grid { grid-template-columns: 1fr !important; }
    .shortcuts-grid { grid-template-columns: 1fr 1fr !important; }
    .main-card { padding: 15px !important; }
    .welcome-section h1 { font-size: 20px !important; }
}

/* --- Landing Page (index.php) --- */
:root {
    --primary-blue: #1a237e;
    --accent-gold: #ffc107;
    --soft-gray: #f8f9fa;
    --text-dark: #2c3e50;
}

.navbar { background: white; box-shadow: 0 2px 15px rgba(0,0,0,0.05); }
.navbar-brand { color: var(--primary-blue) !important; }

.hero-section {
    position: relative;
    background: url('../img/hero_legal.png') no-repeat center center/cover;
    padding: 100px 0;
    color: white;
}
.hero-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(135deg, rgba(26, 35, 126, 0.95) 0%, rgba(26, 35, 126, 0.7) 100%);
    z-index: 1;
}
.hero-content { position: relative; z-index: 2; }

.accordion-button:not(.collapsed) {
    background-color: #e8eaf6;
    color: var(--primary-blue);
    font-weight: 700;
}

.accordion-item {
  color: white;
}

.legal-box {
    border-left: 4px solid var(--primary-blue);
    padding: 20px;
    background: var(--soft-gray);
    border-radius: 0 12px 12px 0;
}

.btn-cta {
    background: var(--accent-gold);
    color: var(--primary-blue);
    font-weight: 800;
    padding: 16px 40px;
    border-radius: 14px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    border: none;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 10px 20px rgba(255, 193, 7, 0.2);
}
.btn-cta:hover {
    background-color: #e5ad06;
    transform: scale(1.05) translateY(-2px);
    color: var(--primary-blue);
    box-shadow: 0 15px 30px rgba(255, 193, 7, 0.3);
}

.external-link {
    text-decoration: none;
    color: var(--primary-blue);
    font-weight: 700;
    display: flex;
    align-items: center;
    padding: 15px 20px;
    border-radius: 12px;
    background: white;
    border: 1px solid rgba(26, 35, 126, 0.1);
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
    height: 100%;
}
.external-link:hover {
    background: white;
    border-color: var(--primary-blue);
    transform: translateY(-3px);
    box-shadow: 0 8px 15px rgba(26, 35, 126, 0.08);
    color: var(--primary-blue);
}
.external-link span {
    font-size: 22px;
    margin-right: 12px;
}

.transition-hover {
    transition: all 0.3s ease;
    background: #fdfdfd;
}
.transition-hover:hover {
    transform: translateY(-5px);
    border-color: var(--primary-blue) !important;
    background: white;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
}

.landing-footer { background: #10151a; color: #94a3b8; }

/* --- Welcome Section (Standard PRO Header) --- */
.welcome-section {
    background: linear-gradient(135deg, #3a4651 0%, #2b343c 100%);
    border-radius: 16px;
    padding: 1.5rem 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

.welcome-section h1, 
.welcome-section .display-6, 
.welcome-section .display-5 {
    font-size: 24px !important;
    font-weight: 700 !important;
    color: #d3d7df !important;
    margin-bottom: 0.5rem;
}

.welcome-section p, 
.welcome-section .lead {
    color: #f2f6fd !important;
    font-size: 15px !important;
    opacity: 1 !important;
    margin-bottom: 0;
}

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; margin-bottom: 40px; }
.stat-card { background: #fff; padding: 24px; border-radius: 12px; border: 1px solid #f1f5f9; box-shadow: 0 4px 15px rgba(0,0,0,0.03); }
.stat-card .icon-box { width: 48px; height: 48px; border-radius: 10px; display: flex; align-items: center; justify-content: center; margin-bottom: 16px; }
.stat-card h3 { font-size: 14px; color: #64748b; font-weight: 600; margin-bottom: 8px; }
.stat-card .value { font-size: 28px; font-weight: 700; color: #1e293b; }

.blue { background: #f1f5f9; color: #3a4651; }
.green { background: #f0fdf4; color: #22c55e; }
.amber { background: #fffbeb; color: #f59e0b; }

.shortcuts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; }
.shortcut-btn { 
    background: #fff; border: 1px solid #f1f5f9; padding: 20px; border-radius: 12px; 
    text-align: center; text-decoration: none; color: #1e293b; font-weight: 600; font-size: 14px;
    transition: all 0.2s; display: flex; flex-direction: column; align-items: center; gap: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.02);
}
.shortcut-btn:hover { background: #f8fafc; transform: translateY(-2px); box-shadow: 0 8px 25px rgba(0,0,0,0.06); }
.shortcut-btn i { font-size: 24px; color: #3a4651; }

.alert-wallet { background: #fff1f2; border: 1px solid #fecdd3; border-radius: 12px; padding: 20px; margin-bottom: 30px; display: flex; gap: 15px; align-items: flex-start; }
.alert-wallet i { color: #e11d48; font-size: 24px; }
.alert-wallet .txt { font-size: 14px; color: #9f1239; }
.alert-wallet .txt strong { display: block; margin-bottom: 4px; }

/* --- Global Modal System Overrides --- */
.modal-content { border-radius: 12px !important; overflow: hidden; }
.btn-close-custom { transition: all 0.2s; }
.btn-close-custom:hover { transform: scale(1.1); opacity: 1 !important; }

/* Custom Nav Pills (Slate Blue) */
.nav-pills .nav-link {
    color: #475569;
    font-weight: 600;
    transition: all 0.2s;
}

.nav-pills .nav-link.active, 
.nav-pills .show > .nav-link {
    background-color: #3a4651 !important;
    color: #ffffff !important;
    box-shadow: 0 4px 12px rgba(58, 70, 81, 0.25);
}

.nav-pills .nav-link:hover:not(.active) {
    background-color: #f1f5f9;
    color: #1e293b;
}

/* --- SISTEMA DE TABLAS PREMIUM RESPONSIVE --- */
.table-premium {
    border-collapse: separate !important;
    border-spacing: 0 8px !important;
    width: 100% !important;
}

.table-premium thead th {
    background-color: #f1f5f9 !important;
    color: #475569 !important;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 15px !important;
    border: none !important;
}

.table-premium tbody tr {
    background: white !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.table-premium tbody tr:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.table-premium td {
    padding: 15px !important;
    border-top: 1px solid #f1f5f9 !important;
    border-bottom: 1px solid #f1f5f9 !important;
    vertical-align: middle !important;
}

/* Soporte para modo Stack/Accordion en móviles */
@media (max-width: 991px) {
    .table-responsive-stack thead {
        display: none; /* Ocultar cabeceras en móvil */
    }

    .table-responsive-stack tr {
        display: block;
        margin-bottom: 15px;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        background: white;
        overflow: hidden;
    }

    .table-responsive-stack td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: right;
        border: none !important;
        padding: 10px 15px !important;
        border-bottom: 1px solid #f1f5f9 !important;
    }

    .table-responsive-stack td:last-child {
        border-bottom: none !important;
        background: #f8fafc;
    }

    .table-responsive-stack td::before {
        content: attr(data-label);
        font-weight: bold;
        text-transform: uppercase;
        font-size: 0.7rem;
        color: #64748b;
        text-align: left;
        margin-right: 10px;
        flex-shrink: 0;
    }

    .hide-on-mobile {
        display: none !important;
    }
}
