/* Proyecto Finca - Estilos principales (inspirado en El surgir) */
:root {
    --primary: #0d6efd;
    --primary-dark: #0a58ca;
    --bg-start: #1e5fce;
    --bg-end: #0ea5e9;
    --card-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.18);
    --input-border: #e2e8f0;
    --radius: 0.75rem;
}

* {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
    min-height: 100vh;
}

.app-content {
    padding: 1.5rem 1rem;
    min-height: calc(100vh - 56px);
}

main.app-content.smx-soft-nav-loading {
    opacity: 0.55;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

.login-logo-wrap {
    background: #fff;
    border-radius: 50%;
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 30px rgba(13, 110, 253, 0.25), 0 0 0 3px rgba(255,255,255,0.9);
    overflow: hidden;
}

.login-brand-logo {
    border-radius: 50%;
    object-fit: cover;
    width: 100%;
    height: 100%;
}

@media (min-width: 992px) {
    body.nav-rail-collapsed .app-content {
        padding-top: 0.5rem;
    }
}

/* Login / Registro */
body.login-page {
    background: linear-gradient(160deg, #1e5fce 0%, #0ea5e9 50%, #0c8bd4 100%);
    background-attachment: fixed;
    min-height: 100vh;
    padding: 0 !important;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow-x: hidden;
}

body.login-page::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 80% 50% at 50% -20%, rgba(255,255,255,0.15), transparent);
    pointer-events: none;
}

body.login-page .app-content {
    padding: 0;
    min-height: auto;
    width: 100%;
}

.login-wrapper {
    min-height: 100vh;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    position: relative;
    z-index: 1;
    background: transparent;
}

.login-wrapper::before {
    display: none;
}

.login-card {
    background: #fff;
    padding: 2.25rem;
    border-radius: 1.25rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.1) inset;
    width: 100%;
    max-width: 420px;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.login-header {
    text-align: center;
    margin-bottom: 1.75rem;
}

.login-icon-wrap {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    background: linear-gradient(135deg, var(--primary) 0%, #0ea5e9 100%);
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 25px -5px rgba(13, 110, 253, 0.4);
}

.login-icon-wrap i {
    font-size: 1.75rem;
    color: #fff;
}

.login-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 0.35rem;
    letter-spacing: -0.02em;
}

.login-subtitle {
    color: #64748b;
    font-size: 0.95rem;
    margin: 0;
}

.login-input-group .input-group-text {
    background: #f8fafc;
    border: 1px solid var(--input-border);
    border-right: 0;
    color: #64748b;
    border-radius: 0.5rem 0 0 0.5rem;
}

.login-input-group .form-control {
    border-radius: 0 0.5rem 0.5rem 0;
    border-left: 0;
}

.login-input-group .form-control:focus {
    border-color: var(--input-border);
    box-shadow: none;
}

.login-input-group:focus-within .input-group-text {
    border-color: var(--primary);
    color: var(--primary);
}

.login-input-group:focus-within .form-control {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

.btn-login {
    padding: 0.65rem 1rem;
    font-weight: 600;
    font-size: 1rem;
    border-radius: 0.5rem;
    margin-top: 0.25rem;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-login:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px -5px rgba(13, 110, 253, 0.4);
}

.demo-back-link {
    padding: 0.65rem 1rem;
    border-radius: 999px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    color: #475569;
    font-size: 0.88rem;
    font-weight: 600;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.demo-back-link:hover {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: #047857;
}

.login-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid #e2e8f0;
}

.login-link {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: color 0.2s;
}

.login-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* Tarjetas de estadísticas (dashboard) */
.stats-card {
    transition: transform 0.2s;
    border: none;
    border-radius: 15px;
}

.stats-card:hover {
    transform: translateY(-5px);
}

.stats-icon {
    font-size: 2.5rem;
    opacity: 0.8;
}

/* Tablas */
.table-box {
    border: 1px solid rgba(0, 0, 0, .075);
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.table-actions .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

/* Título de página */
.page-title-accent {
    width: 8px;
    height: 42px;
    border-radius: 6px;
    background: linear-gradient(180deg, var(--primary), #20c997);
    box-shadow: 0 4px 14px rgba(13, 110, 253, .25);
}

.page-title-icon {
    color: var(--primary);
    background: rgba(13, 110, 253, .08);
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Modales y formularios */
.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.btn-primary {
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
}

.btn-primary:hover {
    background: linear-gradient(180deg, #0b5ed7 0%, #084298 100%);
}

/* Alertas */
.alert {
    border-radius: var(--radius);
}

/* Navbar - Navegador de módulos */
.navbar {
    min-height: 56px;
    padding: 0.4rem 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.15rem;
    padding: 0.35rem 0;
}

.navbar-brand:hover {
    color: rgba(255, 255, 255, 0.95) !important;
}

.navbar-nav .nav-link {
    padding: 0.5rem 0.75rem;
    margin: 0 0.1rem;
    border-radius: 0.5rem;
    font-weight: 500;
    font-size: 0.95rem;
    transition: background 0.2s, color 0.2s;
}

.navbar-dark .navbar-nav .nav-link {
    color: rgba(255, 255, 255, 0.9);
}

.navbar-dark .navbar-nav .nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
}

.navbar-dark .navbar-nav .nav-link.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 0.5rem;
    border-left: 3px solid #20c997;
    font-weight: 600;
}

.navbar-nav .nav-link i {
    opacity: 0.95;
}

.navbar-nav .nav-link.active i {
    opacity: 1;
}

/* Usuario y dropdown en navbar */
.navbar-nav .dropdown .nav-link {
    display: inline-flex;
    align-items: center;
    padding: 0.4rem 0.75rem;
}

.navbar-nav .dropdown .nav-link .badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.25em 0.5em;
}

.navbar .dropdown-menu {
    border: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    border-radius: 0.5rem;
    padding: 0.35rem 0;
    margin-top: 0.35rem;
    min-width: 200px;
}

.navbar .dropdown-item {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.navbar .dropdown-item i {
    width: 1.25rem;
    text-align: center;
}

.navbar .dropdown-item.active {
    background-color: rgba(13, 110, 253, 0.12);
    color: #0d6efd;
    font-weight: 600;
}

.navbar .dropdown-divider {
    margin: 0.35rem 0;
}

/* Responsive: menú colapsado (móvil/tablet) - mismo criterio que El surgir para despliegue correcto */
@media (max-width: 991.98px) {
    .navbar-collapse {
        margin-top: 0.5rem;
        padding: 0.75rem;
        background: rgba(0, 0, 0, 0.08);
        border-radius: 0.5rem;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        max-height: calc(100vh - 80px);
    }

    .navbar-nav .nav-link {
        padding: 0.85rem 1rem;
        margin-bottom: 0.15rem;
        min-height: 48px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(255, 255, 255, 0.2);
        cursor: pointer;
    }

    .navbar-dark .navbar-nav .nav-link.active {
        border-left-width: 4px;
    }

    .navbar-nav:last-child {
        margin-top: 0.5rem;
        padding-top: 0.5rem;
        border-top: 1px solid rgba(255, 255, 255, 0.15);
    }

    /* Dropdowns en móvil: posición estática (acordeón) para que no se corte y funcione al tocar */
    .nav-item.dropdown {
        width: 100%;
    }

    .navbar-nav .dropdown-toggle {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
    }

    .navbar-nav .dropdown-toggle::after {
        margin-left: auto;
        transition: transform 0.3s ease;
    }

    /* Igual que El surgir: posición estática en móvil; la visibilidad la controla Bootstrap con .dropdown.show */
    .navbar-nav .dropdown-menu {
        position: static !important;
        float: none !important;
        width: 100% !important;
        margin-top: 0.5rem !important;
        margin-bottom: 0.5rem !important;
        margin-left: 0 !important;
        background: rgba(0, 0, 0, 0.2) !important;
        border: 1px solid rgba(255, 255, 255, 0.1) !important;
        box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1) !important;
        border-radius: 0.5rem !important;
        padding: 0.5rem 0 !important;
    }

    .navbar-nav .dropdown.show .dropdown-toggle::after {
        transform: rotate(180deg);
    }

    .navbar-nav .dropdown-item {
        padding: 0.9rem 1.25rem;
        font-size: 0.95rem;
        color: rgba(255, 255, 255, 0.9);
        min-height: 48px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(255, 255, 255, 0.2);
    }

    .navbar-nav .dropdown-item:active,
    .navbar-nav .dropdown-item:focus {
        background: rgba(255, 255, 255, 0.25);
        color: #fff;
    }

    .navbar-nav .dropdown-item:hover {
        background: rgba(255, 255, 255, 0.2);
        color: #fff;
    }

    .navbar-nav .dropdown-item.active {
        background: rgba(255, 255, 255, 0.25);
        color: #fff;
    }

    .navbar-nav .dropdown-divider {
        border-color: rgba(255, 255, 255, 0.2);
    }
}

/* Cards de módulos */
.module-card {
    transition: all 0.2s;
    border-radius: 12px;
    border: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

.module-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

/* Kilos total badge */
.kilos-total {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}

/* Fichas de trabajadores (vista tarjetas) */
.trabajador-ficha {
    border-radius: var(--radius);
    border: none;
    transition: transform 0.2s, box-shadow 0.2s;
}

.trabajador-ficha:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1) !important;
}

.trabajador-ficha .card-header {
    border-radius: var(--radius) var(--radius) 0 0;
    font-size: 0.95rem;
}

.trabajador-ficha .trabajador-total-kilos {
    padding: 0.25rem 0;
}

.trabajador-ficha .card-footer {
    border-top: 1px solid rgba(0, 0, 0, .06);
    border-radius: 0 0 var(--radius) var(--radius);
}

/* Mini tabla dentro de la ficha (fecha, kilos, descripción) */
.trabajador-mini-tabla {
    background: rgba(0, 0, 0, .03);
    border-radius: 6px;
    padding: 0.35rem 0.5rem;
    border: 1px solid rgba(0, 0, 0, .08);
    max-height: 200px;
    overflow-y: auto;
}

.trabajador-mini-tabla .table {
    font-size: 0.75rem;
}

.trabajador-mini-tabla thead th {
    font-weight: 600;
    color: #495057;
    padding: 0.2rem 0.25rem;
    border-bottom: 1px solid rgba(0, 0, 0, .1);
    position: sticky;
    top: 0;
    background: rgba(0, 0, 0, .04);
    z-index: 1;
}

.trabajador-mini-tabla tbody td {
    padding: 0.2rem 0.25rem;
    vertical-align: middle;
}

.trabajador-mini-tabla tbody tr:not(:last-child) td {
    border-bottom: 1px solid rgba(0, 0, 0, .06);
}

/* Celdas de kilos sin fondo (solo texto) en fichas y detalle */
.trabajador-mini-tabla .kilos-cell,
.tabla-kilos-ficha .kilos-cell,
.table .kilos-cell {
    background: transparent !important;
    color: inherit;
    font-weight: 600;
}

/* Responsive transversal para vistas de gestión y reportes */
@media (max-width: 767.98px) {
    .app-content {
        padding: 1rem 0;
    }

    .page-title-accent {
        height: 34px;
        width: 6px;
    }

    .table-responsive table {
        font-size: 0.875rem;
    }

    .table-actions .btn {
        margin-bottom: 0.25rem;
    }

    .btn-group > .btn,
    .btn-group-sm > .btn {
        padding-left: 0.55rem;
        padding-right: 0.55rem;
    }

    .reportes-container .card-header,
    .module-card .card-header {
        font-size: 0.92rem;
    }

    .reportes-container .stats-card h4 {
        font-size: 1.2rem;
    }

    .trabajador-mini-tabla {
        max-height: 160px;
    }
}

/* Modal compartir kilos (trabajadores) */
.compartir-lista-trabajadores {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.55rem 0.65rem 0.55rem 0.85rem !important;
    overflow-x: hidden;
}
.compartir-lista-trabajadores .compartir-trabajador-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0;
    padding: 0.6rem 0.85rem 0.6rem 0.9rem;
    border-radius: 0.5rem;
    border: 1px solid #dee2e6;
    border-left: 3px solid transparent;
    background: #fff;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.compartir-lista-trabajadores .compartir-trabajador-item:hover {
    border-color: rgba(13, 110, 253, 0.35);
    background: rgba(13, 110, 253, 0.04);
}
.compartir-lista-trabajadores .compartir-trabajador-item:has(.compartir-chk-trabajador:checked),
.compartir-lista-trabajadores .compartir-trabajador-item.is-selected {
    background: rgba(13, 110, 253, 0.12);
    border-color: rgba(13, 110, 253, 0.45);
    border-left-color: #0d6efd;
}
.compartir-lista-trabajadores .compartir-trabajador-item:has(.compartir-chk-trabajador:not(:checked)):not(.is-selected) {
    opacity: 0.78;
}
.compartir-lista-trabajadores .compartir-chk-trabajador {
    width: 1.15rem;
    height: 1.15rem;
    min-width: 1.15rem;
    margin: 0;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: #0d6efd;
}
.compartir-lista-trabajadores .compartir-trabajador-label {
    flex: 1;
    min-width: 0;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.85rem;
    cursor: pointer;
    line-height: 1.35;
}
.compartir-lista-trabajadores .compartir-trabajador-nombre {
    font-weight: 600;
    color: #212529;
    flex: 1;
    min-width: 0;
    padding-right: 0.25rem;
}
.compartir-lista-trabajadores .compartir-kilos-badge {
    font-weight: 700;
    font-size: 0.8125rem;
    color: #0d6efd !important;
    background: rgba(13, 110, 253, 0.12);
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    white-space: nowrap;
    flex-shrink: 0;
}
.compartir-lista-trabajadores .compartir-trabajador-item:has(.compartir-chk-trabajador:checked) .compartir-trabajador-nombre,
.compartir-lista-trabajadores .compartir-trabajador-item.is-selected .compartir-trabajador-nombre {
    color: #084298;
}
.compartir-preview-placeholder,
.compartir-preview-texto {
    min-height: 140px;
}
.compartir-preview-texto {
    font-size: 0.85rem;
    line-height: 1.45;
    word-break: break-word;
}
#compartirShareProgreso {
    border-left: 4px solid #25d366;
}
#compartirShareProgreso.compartir-share-progreso--queue,
#compartirShareProgreso.compartir-share-progreso--bulk {
    font-size: 0.92rem;
    line-height: 1.5;
}
#compartirShareProgreso .compartir-share-counter {
    display: inline-block;
    min-width: 3.5rem;
    padding: 0.15rem 0.5rem;
    margin-right: 0.35rem;
    border-radius: 999px;
    background: #25d366;
    color: #fff;
    font-weight: 700;
    text-align: center;
}
#modalCompartirKilos .modal-footer .btn {
    flex: 1 1 auto;
    min-width: 8rem;
}
@media (max-width: 575.98px) {
    #modalCompartirKilos .modal-footer {
        flex-direction: column;
    }
    #modalCompartirKilos .modal-footer .btn {
        width: 100%;
    }
}