/* 
    ESTILOS MAESTROS - LA JOSEFINA
    Centralización de Sidebar, Layout y Tipografía.
*/

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary-color: #004b87;
    --accent-color: #e23822;
    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --sidebar-bg: #004b87;
    --sidebar-text: #b3d4f0;
    --sidebar-width: 280px;
    --transition-speed: 0.3s;
    --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.dark-mode {
    --bg-body: #0f172a;
    --bg-card: #1e293b;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --sidebar-bg: #1e293b;
    --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

body {
    font-family: 'Montserrat', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    display: flex;
    margin: 0;
    min-height: 100vh;
    transition: background-color var(--transition-speed), color var(--transition-speed);
}

.card,
.card-custom,
.panel-blanco,
.input-panel {
    background-color: var(--bg-card);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.card:hover,
.card-custom:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
}

.btn {
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.btn:active {
    transform: scale(0.96);
}

/* SIDEBAR */
.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    height: 100vh;
    padding: 20px 15px;
    color: white;
    position: fixed;
    box-shadow: 5px 0 25px rgba(0, 0, 0, 0.15);
    border-right: 5px solid var(--accent-color);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
    transition: transform var(--transition-speed), width var(--transition-speed);
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

.sidebar h4 {
    font-weight: 900;
    letter-spacing: -1px;
    text-align: center;
    font-size: 1.8rem;
    margin-bottom: 0;
    color: white;
}

.sidebar .slogan {
    color: var(--accent-color);
    font-size: 0.8rem;
    text-align: center;
    font-style: italic;
    margin-bottom: 20px;
    font-weight: 700;
}

.nav-link {
    color: var(--sidebar-text) !important;
    border-radius: 10px;
    margin-bottom: 4px;
    transition: all 0.3s;
    padding: 10px 15px;
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-link:hover,
.nav-link.active {
    background: var(--accent-color);
    color: white !important;
    border-left: 4px solid white;
    box-shadow: 0 4px 12px rgba(226, 56, 34, 0.3);
}

.sidebar-user {
    margin-top: auto;
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
}

.user-avatar-mini {
    width: 40px;
    height: 40px;
    background: var(--accent-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 2px solid white;
    margin-right: 8px;
}

.user-avatar-mini img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.content {
    margin-left: 280px;
    padding: 30px;
    flex: 1;
    min-width: 0;
    min-height: 100vh;
    background-color: var(--bg-body);
    position: relative;
    z-index: 1;
    transition: margin-left var(--transition-speed);
}

/* TABLET OPTIMIZATION */
@media (max-width: 992px) {
    .sidebar {
        width: 80px;
        padding: 15px 5px;
    }

    .sidebar h4,
    .sidebar .slogan,
    .sidebar .nav-link span,
    .sidebar-user div {
        display: none;
    }

    .nav-link {
        justify-content: center;
        padding: 15px 0;
    }

    .content {
        margin-left: 80px;
    }
}

/* MOBILE OPTIMIZATION (Phones) */
@media (max-width: 576px) {
    .sidebar {
        width: 280px;
        left: 0;
        transform: translateX(-100%);
        visibility: hidden;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
        visibility: visible;
    }

    .content {
        margin-left: 0;
        padding: 15px;
        padding-top: 70px;
        /* Espacio para el boton hamburguesa */
    }

    .mobile-nav-toggle {
        display: block !important;
        position: fixed;
        top: 15px;
        right: 15px;
        z-index: 1100;
        background: var(--primary-color);
        color: white;
        border: none;
        padding: 10px 15px;
        border-radius: 10px;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    }

    .header-planta {
        font-size: 1rem;
        padding: 12px !important;
    }

    /* Cards Stack */
    .card-stats-container {
        grid-template-columns: 1fr !important;
    }

    .table-responsive {
        border: none;
        box-shadow: none;
        background: transparent;
    }

    .table thead {
        display: none !important;
    }

    .table,
    .table tbody,
    .table tr,
    .table td {
        display: block;
        width: 100%;
    }

    .table tr {
        background: var(--bg-card);
        margin-bottom: 20px;
        border-radius: 20px;
        box-shadow: var(--card-shadow);
        padding: 15px;
        border: 1px solid var(--border-color);
    }

    .table td {
        text-align: right;
        padding: 10px 0 !important;
        position: relative;
        border-bottom: 1px solid var(--border-color) !important;
        min-height: 45px;
    }

    .table td:last-child {
        border-bottom: none !important;
    }

    .table td::before {
        content: attr(data-label);
        position: absolute;
        left: 0;
        width: 45%;
        text-align: left;
        font-weight: 700;
        color: var(--text-muted);
        text-transform: uppercase;
        font-size: 0.7rem;
    }

    .table td:first-child {
        text-align: left;
        background: var(--primary-color);
        color: white !important;
        margin: -15px -15px 15px -15px;
        padding: 15px !important;
        border-radius: 18px 18px 0 0;
    }

    .table td:first-child div {
        color: white !important;
        font-size: 1.1rem;
    }

    .table td:first-child small {
        color: rgba(255, 255, 255, 0.7) !important;
    }

    .table td:first-child::before {
        display: none;
    }
}

.mobile-nav-toggle {
    display: none;
}

/* Forzar que el cuerpo siempre sea scrollable si es necesario */
html,
body {
    overflow-x: hidden !important;
    overflow-y: auto !important;
    height: auto !important;
    min-height: 100vh;
}

.fw-900 {
    font-weight: 900;
}

.fw-800 {
    font-weight: 800;
}

.fw-700 {
    font-weight: 700;
}

.fw-600 {
    font-weight: 600;
}

.no-print {
    display: block;
}

@media print {

    .sidebar,
    .no-print {
        display: none !important;
    }

    .content {
        margin-left: 0;
        padding: 0;
    }
}

/* ==========================================================================
   GLOBAL TABLE STYLES - REFINAMIENTO DE DATOS
   ========================================================================== */

/* Contenedor responsivo mejorado */
.table-responsive {
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    background: white;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

.table {
    width: 100% !important;
    margin-bottom: 0 !important;
    color: var(--text-main);
    vertical-align: middle;
    border-collapse: separate;
    border-spacing: 0;
}

/* Encabezados más profesionales y compactos */
.table thead th {
    background: var(--primary-color) !important;
    color: white !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    font-size: 0.7rem !important;
    letter-spacing: 0.8px !important;
    padding: 14px 15px !important;
    border: none !important;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
}

/* Celdas con espaciado optimizado para evitar que los datos se vean "dispersos" */
.table tbody td {
    padding: 10px 15px !important;
    border-bottom: 1px solid #f1f5f9 !important;
    color: var(--text-main);
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
}

/* Estilo para ID o códigos pequeños */
.table .id-cell {
    width: 80px;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    color: var(--primary-color);
}

/* Hover y Zebra stripes */
.table tbody tr:hover td {
    background-color: #f8fafc !important;
    color: var(--primary-color) !important;
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: #fafbfc;
}

/* Botones de acción en tablas */
.table .btn-action {
    padding: 4px 8px;
    font-size: 0.75rem;
    border-radius: 6px;
}

/* Ajustes para datos numéricos o alineación central */
.table .text-center {
    text-align: center !important;
}

.table .text-end {
    text-align: right !important;
}

/* Badge ID universal */
.badge-id {
    background-color: #e8f0fe !important;
    color: var(--primary-color) !important;
    border: 1px solid #b6d4fe !important;
    font-weight: 700 !important;
    font-size: 0.7rem !important;
    padding: 3px 8px !important;
    border-radius: 6px !important;
    display: inline-block;
}

/* Badges para el directorio de empleados */
.puesto-tag {
    background: #f8fafc;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    display: inline-flex;
    align-items: center;
}

.custom-wage-input {
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 4px 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    width: 100px;
    text-align: right;
    transition: all 0.2s;
}

.custom-wage-input:focus {
    border-color: #004b87;
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 75, 135, 0.1);
    background-color: #fff;
}

.table-sm-custom thead th {
    padding: 8px 10px !important;
}

.table-sm-custom tbody td {
    padding: 6px 10px !important;
}

/* DARK MODE OVERRIDES */
.dark-mode .card,
.dark-mode .card-custom,
.dark-mode .panel-blanco,
.dark-mode .input-panel,
.dark-mode .table-responsive,
.dark-mode .modal-content {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
    box-shadow: var(--card-shadow) !important;
}

.dark-mode .modal-header,
.dark-mode .modal-footer {
    border-color: var(--border-color) !important;
}

.dark-mode .table,
.dark-mode .table tbody tr,
.dark-mode .table tbody td,
.dark-mode .table th {
    background-color: transparent !important;
    border-bottom-color: var(--border-color) !important;
    color: var(--text-main) !important;
}

.dark-mode .table tbody tr:hover td {
    background-color: rgba(255, 255, 255, 0.05) !important;
}

.dark-mode .text-dark,
.dark-mode .text-body {
    color: #e2e8f0 !important;
}

.dark-mode .bg-light,
.dark-mode .bg-white,
.dark-mode .table .bg-light {
    background-color: #2d3748 !important;
    color: #e2e8f0 !important;
}

.dark-mode .bg-dark,
.dark-mode .table .bg-dark {
    background-color: #1a202c !important;
}

.dark-mode .table-dark {
    background-color: #1a202c !important;
    color: #f1f5f9 !important;
}

.dark-mode .table-dark th {
    background-color: #1a202c !important;
    color: #f1f5f9 !important;
    border-color: #334155 !important;
}

.dark-mode td.bg-light {
    background-color: #2d3748 !important;
}

.dark-mode td.bg-dark-subtle {
    background-color: #1e293b !important;
}

.dark-mode td.bg-danger-subtle,
.dark-mode .row-falta {
    background-color: rgba(226, 56, 34, 0.15) !important;
    color: #fca5a5 !important;
}

.dark-mode .row-falta input,
.dark-mode .row-falta select {
    background-color: rgba(226, 56, 34, 0.25) !important;
    color: #fca5a5 !important;
}

.dark-mode .sticky-save {
    background-color: var(--bg-body) !important;
    box-shadow: 0 -10px 20px rgba(0, 0, 0, 0.5) !important;
}

.dark-mode .text-danger {
    color: #fca5a5 !important;
}

.dark-mode .text-primary {
    color: #93c5fd !important;
}

.dark-mode .text-success {
    color: #86efac !important;
}

.dark-mode .form-control,
.dark-mode .form-select {
    background-color: #2d3748 !important;
    border-color: #4a5568 !important;
    color: white !important;
}

.dark-mode .form-control:focus {
    border-color: var(--accent-color) !important;
}

.dark-mode .text-muted,
.dark-mode .small,
.dark-mode .form-control::placeholder,
.dark-mode .form-switch .form-check-label {
    color: var(--text-muted) !important;
}

.dark-mode .form-label {
    color: var(--text-main) !important;
}

.dark-mode h1,
.dark-mode h2,
.dark-mode h3,
.dark-mode h4,
.dark-mode h5,
.dark-mode h6 {
    color: white !important;
}

.dark-mode .badge-id {
    background-color: rgba(0, 75, 135, 0.3) !important;
    color: #93c5fd !important;
    border-color: #1e3a8a !important;
}

.dark-mode .input-group-text {
    background-color: #2d3748 !important;
    border-color: #4a5568 !important;
    color: #93c5fd !important;
}