/* ════════════════════════════════════════════════════════════════════
   MÓDULOS — Tema visual consistente para páginas complementarias
   (maestros, listados, informes)
   ════════════════════════════════════════════════════════════════════ */

/* ─── Contenedor de página ─────────────────────────────────────────── */
.mod-page {
    padding: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
}

/* ─── Tarjeta principal ─────────────────────────────────────────────── */
.mod-card {
    background: #ffffff;
    border-radius: 1rem;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.08), 0 1px 2px -1px rgb(0 0 0 / 0.08);
    overflow: hidden;
}

/* ─── Encabezado de tarjeta ─────────────────────────────────────────── */
.mod-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 1px solid #e2e8f0;
    gap: 1rem;
    flex-wrap: wrap;
}

.mod-header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.mod-header-icon {
    width: 48px;
    height: 48px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.25rem;
    flex-shrink: 0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.15);
}

.mod-header-icon.blue   { background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%); }
.mod-header-icon.green  { background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%); }
.mod-header-icon.amber  { background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); }
.mod-header-icon.indigo { background: linear-gradient(135deg, #6366f1 0%, #4338ca 100%); }
.mod-header-icon.slate  { background: linear-gradient(135deg, #64748b 0%, #475569 100%); }
.mod-header-icon.teal   { background: linear-gradient(135deg, #14b8a6 0%, #0d9488 100%); }
.mod-header-icon.rose   { background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%); }

.mod-header-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
    line-height: 1.2;
}

.mod-header-subtitle {
    font-size: 0.78rem;
    color: #64748b;
    margin: 0.2rem 0 0;
}

/* ─── Alerta ────────────────────────────────────────────────────────── */
.mod-alert {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-bottom: 1px solid transparent;
}

.mod-alert.success {
    background: #f0fdf4;
    border-color: #86efac;
    color: #15803d;
}

.mod-alert.error {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #b91c1c;
}

/* ─── Barra de filtros ──────────────────────────────────────────────── */
.mod-filters {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.875rem 1.5rem;
    border-bottom: 1px solid #f1f5f9;
    background: #fafbfc;
}

.mod-filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 180px;
}

.mod-filter-group label {
    font-size: 0.7rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mod-filter-input {
    height: 34px;
    padding: 0 0.625rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    color: #334155;
    background: #ffffff;
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
    box-sizing: border-box;
}

.mod-filter-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

/* ─── Tabla de datos ────────────────────────────────────────────────── */
.mod-table-wrap {
    overflow-x: auto;
}

.mod-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.875rem;
}

.mod-table thead {
    background: linear-gradient(135deg, #f1f5f9 0%, #e8edf2 100%);
    position: sticky;
    top: 0;
    z-index: 1;
}

.mod-table th {
    padding: 0.75rem 1rem;
    font-weight: 700;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #475569;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
    text-align: left;
}

.mod-table td {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
    vertical-align: middle;
}

.mod-table tbody tr {
    transition: background 0.1s;
}

.mod-table tbody tr:hover {
    background: #f8fafc;
}

.mod-table tbody tr:last-child td {
    border-bottom: none;
}

/* ─── Estado vacío ──────────────────────────────────────────────────── */
.mod-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    text-align: center;
    color: #94a3b8;
}

.mod-empty i {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    opacity: 0.45;
}

.mod-empty p {
    font-size: 0.875rem;
    margin: 0;
}

/* ─── Badges ────────────────────────────────────────────────────────── */
.mod-badge-id {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.5rem;
    background: #f1f5f9;
    color: #64748b;
    border-radius: 0.375rem;
    font-size: 0.72rem;
    font-weight: 700;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, monospace;
}

.mod-badge-rut {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    background: #f0f9ff;
    color: #0369a1;
    border-radius: 0.375rem;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, monospace;
    border: 1px solid #bae6fd;
}

.mod-badge-code {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.5rem;
    background: #f5f3ff;
    color: #6d28d9;
    border-radius: 0.375rem;
    font-size: 0.72rem;
    font-weight: 600;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, monospace;
    border: 1px solid #ddd6fe;
}

.mod-badge-perm {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.5rem;
    background: #dcfce7;
    color: #15803d;
    border-radius: 0.375rem;
    font-size: 0.72rem;
    font-weight: 700;
}

/* ─── Botones de acción en tabla ────────────────────────────────────── */
.mod-btn-edit,
.mod-btn-del {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 0.4rem;
    border: none;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.12s;
}

.mod-btn-edit {
    background: #eff6ff;
    color: #2563eb;
}

.mod-btn-edit:hover {
    background: #dbeafe;
    color: #1d4ed8;
}

.mod-btn-del {
    background: #fef2f2;
    color: #dc2626;
}

.mod-btn-del:hover {
    background: #fee2e2;
    color: #b91c1c;
}

/* ─── Botón primario (encabezado) ───────────────────────────────────── */
.mod-btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border: none;
    border-radius: 0.625rem;
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.28);
    transition: all 0.15s;
    white-space: nowrap;
}

.mod-btn-primary:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.35);
    transform: translateY(-1px);
}

.mod-btn-success {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: white;
    border: none;
    border-radius: 0.625rem;
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(22, 163, 74, 0.28);
    transition: all 0.15s;
    white-space: nowrap;
}

.mod-btn-success:hover:not(:disabled) {
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
    transform: translateY(-1px);
}

.mod-btn-success:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

/* ─── Fila de resumen (informes) ────────────────────────────────────── */
.mod-summary-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    align-items: center;
    background: #fafbfc;
}

.mod-stat {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1rem;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.mod-stat-icon {
    width: 38px;
    height: 38px;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    color: white;
}

.mod-stat-icon.blue  { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.mod-stat-icon.green { background: linear-gradient(135deg, #22c55e, #16a34a); }
.mod-stat-icon.amber { background: linear-gradient(135deg, #f59e0b, #d97706); }

.mod-stat-value {
    font-size: 1.15rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1;
}

.mod-stat-label {
    font-size: 0.7rem;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-top: 0.15rem;
}

/* ─── Badges de tabla (compartidos con PesajePendientes) ────────────── */
.patente-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 0.75rem;
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    color: #1e40af;
    border-radius: 0.5rem;
    font-weight: 700;
    font-size: 0.875rem;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, monospace;
    letter-spacing: 1px;
    border: 1px solid #93c5fd;
}

.id-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    background: #f1f5f9;
    color: #64748b;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, monospace;
}

.product-tag,
.provider-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.625rem;
    background: #f8fafc;
    color: #475569;
    border-radius: 0.5rem;
    font-size: 0.84rem;
    font-weight: 500;
}

.product-tag i,
.provider-tag i {
    color: #94a3b8;
    font-size: 0.72rem;
}

.peso-value {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, monospace;
    font-weight: 700;
    font-size: 0.9rem;
    color: #0f172a;
}

.total-value {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, monospace;
    font-weight: 800;
    font-size: 0.9rem;
    color: #15803d;
}

.fecha-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.625rem;
    background: #f1f5f9;
    color: #64748b;
    border-radius: 0.5rem;
    font-size: 0.78rem;
    font-weight: 500;
}

.tipo-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.375rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.78rem;
    font-weight: 600;
}

.tipo-recepcion {
    background: #dcfce7;
    color: #15803d;
}

.tipo-despacho {
    background: #fee2e2;
    color: #b91c1c;
}

/* ─── Drawer lateral ────────────────────────────────────────────────── */
.mod-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(2px);
    z-index: 2000;
    animation: modFadeIn 0.2s ease;
}

@keyframes modFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.mod-drawer {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 460px;
    max-width: 96vw;
    background: #ffffff;
    z-index: 2001;
    display: flex;
    flex-direction: column;
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.16);
    animation: modSlideIn 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

@keyframes modSlideIn {
    from { transform: translateX(100%); }
    to   { transform: translateX(0); }
}

.mod-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.125rem 1.5rem;
    background: linear-gradient(135deg, #1e3a5f 0%, #1e40af 100%);
    flex-shrink: 0;
    gap: 1rem;
}

.mod-drawer-title {
    font-size: 1rem;
    font-weight: 700;
    color: #ffffff;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.mod-drawer-subtitle {
    font-size: 0.73rem;
    color: rgba(255, 255, 255, 0.6);
    margin: 0.2rem 0 0;
}

.mod-drawer-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.15s;
    flex-shrink: 0;
}

.mod-drawer-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

.mod-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.125rem;
}

.mod-drawer-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
    display: flex;
    gap: 0.75rem;
    flex-shrink: 0;
}

/* ─── Campos de formulario en drawer ────────────────────────────────── */
.mod-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.mod-field label {
    font-size: 0.7rem;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mod-input {
    height: 38px;
    padding: 0 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    color: #0f172a;
    background: #ffffff;
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
    width: 100%;
    box-sizing: border-box;
}

.mod-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.mod-input:disabled {
    background: #f1f5f9;
    color: #94a3b8;
    cursor: not-allowed;
}

.mod-input.invalid {
    border-color: #f87171;
    box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.12);
}

.mod-field-hint {
    font-size: 0.73rem;
    color: #94a3b8;
}

.mod-field-error {
    font-size: 0.73rem;
    color: #dc2626;
    font-weight: 500;
}

/* Sección separadora dentro del drawer */
.mod-drawer-section {
    padding: 0.5rem 0 0.25rem;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.7rem;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 0.25rem;
}

/* ─── Permisos / checkboxes ─────────────────────────────────────────── */
.mod-check-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.mod-check-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.875rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background 0.1s, border-color 0.1s;
    user-select: none;
}

.mod-check-item:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.mod-check-item input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: #3b82f6;
    cursor: pointer;
    flex-shrink: 0;
}

.mod-check-item label {
    font-size: 0.875rem;
    color: #334155;
    font-weight: 500;
    cursor: pointer;
    margin: 0;
    flex: 1;
    text-transform: none;
    letter-spacing: 0;
}

.mod-check-item .mod-check-desc {
    font-size: 0.73rem;
    color: #94a3b8;
    margin-top: 0.1rem;
}

/* ─── Botones del drawer ────────────────────────────────────────────── */
.mod-btn-save {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border: none;
    border-radius: 0.625rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.28);
}

.mod-btn-save:hover:not(:disabled) {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.35);
}

.mod-btn-save:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.mod-btn-cancel {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    background: #ffffff;
    color: #64748b;
    border: 1px solid #e2e8f0;
    border-radius: 0.625rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.mod-btn-cancel:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #334155;
}

/* ─── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .mod-page {
        padding: 0.75rem;
    }

    .mod-card-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .mod-filters {
        flex-direction: column;
    }

    .mod-filter-group {
        min-width: 100%;
    }

    .mod-drawer {
        width: 100vw;
        max-width: 100vw;
    }

    .mod-table {
        font-size: 0.8rem;
    }

    .mod-table th,
    .mod-table td {
        padding: 0.625rem 0.75rem;
    }

    .mod-summary-row {
        flex-direction: column;
    }

    .mod-stat {
        width: 100%;
    }
}

/* ─── Scrollbar ─────────────────────────────────────────────────────── */
.mod-table-wrap::-webkit-scrollbar,
.mod-drawer-body::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

.mod-table-wrap::-webkit-scrollbar-track,
.mod-drawer-body::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.mod-table-wrap::-webkit-scrollbar-thumb,
.mod-drawer-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.mod-table-wrap::-webkit-scrollbar-thumb:hover,
.mod-drawer-body::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}
