/* ============================================================
   GLOBAL APP HEADER
   ============================================================ */

.app-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 1px 8px rgba(0,0,0,0.06);
}

.app-header-inner {
    width: 100%;
    max-width: 1680px;
    margin: 0 auto;
    padding: 4px 20px;
    min-height: 72px;
    box-sizing: border-box;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: clamp(8px, 0.8vw, 16px);
}

.app-header-inner > * {
    min-width: 0;
}

/* Logo */
.app-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    flex-shrink: 0;
}

.logo-img {
    height: 96px;
    width: auto;
    object-fit: contain;
}

.logo-separator {
    color: #cbd5e1;
    font-size: 1.6rem;
    font-weight: 200;
    margin-top: -2px;
}

.logo-text {
    font-size: 0.78rem;
    font-weight: 400;
    font-style: italic;
    color: #94a3b8;
    letter-spacing: 0.1px;
    white-space: normal;
    line-height: 1.3;
    max-width: 80px;
}

/* Navigation */
.app-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 0;
    min-width: 0;
    overflow: visible; /* Necesario para que el dropdown no se recorte */
    scrollbar-width: none;
}
.app-nav::-webkit-scrollbar { display: none; }

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px clamp(5px, 0.45vw, 9px);
    border-radius: 7px;
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 500;
    color: #475569;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}

.nav-link svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

.nav-link:hover {
    background: #f1f5f9;
    color: var(--primary);
}

.nav-link.active {
    background: rgba(57, 181, 171, 0.1);
    color: var(--primary);
}

/* Nav Dropdown */
.nav-item-dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.chevron {
    width: 14px;
    height: 14px;
    margin-left: 4px;
    transition: transform 0.2s;
}

.nav-item-dropdown:hover .chevron,
.nav-item-dropdown .dropdown-open ~ * .chevron {
    transform: rotate(0deg);
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    border: 1px solid var(--border);
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 9999;
    padding: 8px 0;
}

/* Clase inyectada por JS al hacer click */
.dropdown-menu.dropdown-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--text-main);
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
    font-weight: 500;
    font-size: 14px;
}

.dropdown-item svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.dropdown-item:hover, .dropdown-item.active {
    background: rgba(57, 181, 171, 0.08);
    color: var(--primary);
}

/* Right side: user/logout arriba, datetime abajo */
.header-right {
    display: flex;
    flex-direction: column-reverse;
    align-items: flex-end;
    gap: 4px;
    min-width: 0;
    max-width: 100%;
    margin-left: auto;
}

/* Fila Sup: Fecha/Hora Pill */
.header-datetime-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #f8fafc;
    padding: 3px 9px;
    border-radius: 20px;
    border: 1px solid var(--border);
    font-size: 0.74rem;
    color: var(--text-muted);
    font-weight: 400;
    max-width: 100%;
    box-sizing: border-box;
    white-space: nowrap;
}

.header-time {
    color: var(--text-muted);
    font-weight: 400;
}

.header-separator {
    color: #cbd5e1;
    font-size: 0.8rem;
}

/* Fila Inf: User Actions Badge */
.header-actions-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #ffffff;
    padding: 3px 3px 3px 10px;
    border-radius: 30px;
    border: 1px solid var(--border);
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.header-user-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    color: #475569;
    font-size: 0.82rem;
    min-width: 0;
    max-width: 170px;
    position: relative;
    cursor: help;
}

.header-user-badge > span {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Tooltip ligero equivalente a v-tooltip, sin cargar Vue/PrimeVue en esta vista PHP. */
.header-user-badge[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    top: calc(100% + 50px);
    right: 0;
    z-index: 10020;
    width: max-content;
    max-width: min(320px, 80vw);
    padding: 7px 10px;
    border-radius: 7px;
    background: #1e293b;
    color: #ffffff;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.2);
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.3;
    white-space: normal;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-3px);
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
}

.header-user-badge:focus-visible {
    outline: 2px solid rgba(57, 181, 171, 0.45);
    outline-offset: 2px;
    border-radius: 5px;
}

.header-user-badge[data-tooltip]:hover::after,
.header-user-badge[data-tooltip]:focus-visible::after {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.header-user-badge svg {
    width: 17px;
    height: 17px;
    stroke: var(--primary);
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Boton de Salir Destacado */
.btn-logout-pill {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fee2e2;
    color: #dc2626;
    padding: 6px 10px;
    border-radius: 20px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.82rem;
    transition: all 0.2s;
    gap: 5px;
    border: none;
}

.btn-logout-pill:hover {
    background: #fca5a5;
    color: #991b1b;
}

.btn-logout-pill svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Compactar antes de separar filas: el zoom no debe crear una cabecera vacía. */
@media (max-width: 1366px) {
    .app-header-inner { padding: 4px 16px; }
    .logo-img { height: 64px; }
}

/* Conservar todas las opciones legibles cuando realmente falta ancho. */
@media (max-width: 1100px) {
    .app-header { position: relative; }
    .app-header-inner {
        grid-template-columns: auto minmax(0, 1fr);
        padding: 4px 16px;
    }

    .app-nav {
        grid-column: 1 / -1;
        grid-row: 2;
        justify-content: center;
        flex-wrap: wrap;
    }

    .header-right {
        grid-column: 2;
        grid-row: 1;
    }
}

/* En móvil cada bloque ocupa su propia fila y nunca amplía el viewport. */
@media (max-width: 680px) {
    .app-header-inner {
        grid-template-columns: minmax(0, 1fr);
        padding: 8px 12px;
    }

    .app-logo,
    .app-nav,
    .header-right {
        grid-column: 1;
    }

    .app-logo {
        grid-row: 1;
        justify-self: center;
    }

    .header-right {
        grid-row: 2;
        width: 100%;
        align-items: stretch;
    }

    .header-actions-pill {
        justify-content: space-between;
    }

    .header-user-badge {
        max-width: calc(100% - 96px);
    }

    .header-user-badge[data-tooltip]::after {
        right: auto;
        left: 0;
        max-width: min(320px, calc(100vw - 24px));
    }

    .header-datetime-pill {
        align-self: flex-end;
    }

    .app-nav {
        grid-row: 3;
    }
}

/* Adjust body top spacing when header is present */
body.has-header .container {
    margin-top: 24px;
}

/* ============================================================
   PAGE SECTION HEADER (logo + H1 + subtitle per page)
   ============================================================ */

.page-section-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e2e8f0;
}

.page-section-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.page-section-icon svg {
    width: 26px;
    height: 26px;
    stroke: white;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.page-section-text h1 {
    margin: 0 0 4px 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
}

.page-section-text p {
    margin: 0;
    font-size: 0.9rem;
    color: #64748b;
    line-height: 1.5;
}

:root {

    --primary: #39b5ab;
    --primary-hover: #2e968d;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #10b981;
    --success-hover: #059669;
    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #434547;
    --text-muted: #6b7280;
    --border: #e2e8f0;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-body);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    line-height: 1.5;
}

h1, h2, h3, h4 {
    margin-top: 0;
    font-weight: 600;
    color: var(--text-main);
}

/* Contenedores Principales */
.container {
    max-width: 1400px;
    box-sizing: border-box;
    width: calc(100% - 48px);
    margin: 40px auto;
    background: var(--bg-card);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
}

.auth-container, .login-container {
    max-width: 440px;
    margin: 8vh auto;
    background: var(--bg-card);
    padding: 45px 40px;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0,0,0,0.05);
    border: 1px solid rgba(226, 232, 240, 0.8);
}

.login-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 35px;
    width: 100%;
}

.login-logo img {
    width: 90%; /* Aumentado considerablemente ocupando el 90% del ancho del login */
    max-height: 220px; /* Incrementado para permitir logos mucho más grandes */
    object-fit: contain;
}

/* Modificamos el H1 genérico por si no hay logo */
.login-container h1 {
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 30px;
    text-align: center;
    color: var(--text-main);
    letter-spacing: -0.5px;
}

.login-container .links {
    margin-top: 25px;
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.login-container .links a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.login-container .links a:hover {
    text-decoration: underline;
}

.login-container .button {
    width: 100%;
    margin-top: 15px;
    padding: 14px 20px;
    font-size: 1rem;
}

/* Arreglo del overflow del texto de aviso rojo en reCAPTCHA localhost */
.recaptcha-wrapper {
    display: flex;
    justify-content: center;
    height: 78px; /* Altura estándar estricta para cortar el texto rojo sobrante */
    overflow: hidden;
    margin: 0 auto 20px auto;
    border-radius: 4px;
}

/* Formularios y Controles */
.form-group {
    margin-bottom: 22px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-main);
    font-size: 0.9rem;
}

.form-control, .search, textarea.form-control {
    width: 100%;
    padding: 8px 12px;
    background-color: #ffffff;
    border: 1px solid var(--border);
    border-radius: 6px;
    box-sizing: border-box;
    font-family: var(--font-family);
    font-size: 0.875rem;
    color: var(--text-main);
    transition: all 0.2s ease;
}

.form-control:hover, .search:hover, textarea.form-control:hover {
    border-color: #cbd5e1;
}

.form-control:focus, .search:focus, textarea.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(57, 181, 171, 0.15);
}

/* Integración Avanzada Floating Labels Premium (Login) */
.form-floating {
    position: relative;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
}

.form-floating .form-control {
    width: 100%;
    height: 64px;
    padding: 24px 18px 8px 52px !important; /* Espacio para icono y label */
    background-color: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-main);
    transition: all 0.3s ease;
}

.form-floating .form-control:hover {
    background-color: #ffffff;
    border-color: #cbd5e1;
}

.form-floating .form-control::placeholder {
    color: transparent;
}

.form-floating .form-control:focus {
    outline: none;
    background-color: #ffffff;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(57, 181, 171, 0.15);
}

.form-floating .icon {
    position: absolute;
    left: 18px;
    width: 22px;
    height: 22px;
    color: var(--text-muted);
    transition: color 0.3s ease;
    z-index: 2;
    pointer-events: none;
}

.form-floating label {
    position: absolute;
    left: 52px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1rem;
    color: var(--text-muted);
    pointer-events: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    margin: 0;
    font-weight: 500;
}

.form-floating .form-control:focus ~ label,
.form-floating .form-control:not(:placeholder-shown) ~ label {
    top: 16px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary);
}

.form-floating .form-control:focus ~ .icon {
    color: var(--primary);
}

/* Botones */
.button {
    padding: 12px 24px;
    background: var(--primary);
    color: white;
    text-decoration: none;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 10px rgba(57, 181, 171, 0.25);
    user-select: none;
    gap: 8px;
}

.button:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(57, 181, 171, 0.35);
}

.button:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 5px rgba(57, 181, 171, 0.2);
}

.button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.button.secondary {
    background: #475569;
}
.button.secondary:hover:not(:disabled) {
    background: #334155;
}

.button.danger {
    background: var(--danger);
}
.button.danger:hover:not(:disabled) {
    background: var(--danger-hover);
}

.button.success {
    background: var(--success);
}
.button.success:hover:not(:disabled) {
    background: var(--success-hover);
}

.button.small {
    padding: 6px 12px;
    font-size: 0.85rem;
    border-radius: 6px;
}

/* Icon Buttons (Grillas) */
.icon-btn {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}
.icon-btn:hover {
    background: #f1f5f9;
    color: var(--text-main);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.icon-btn.primary:hover { color: var(--primary); background: rgba(57, 181, 171, 0.1); border-color: var(--primary); }
.icon-btn.danger { color: var(--danger); border-color: #fee2e2; }
.icon-btn.danger:hover { background: #fee2e2; color: #dc2626; border-color: var(--danger); }
.icon-btn.success { color: #2e968d; border-color: #d1fae5; }
.icon-btn.success:hover { background: #d1fae5; color: #2e968d; border-color: #2e968d; }
.icon-btn.warning { color: #dd6b20; border-color: #fbd38d; }
.icon-btn.warning:hover { background: #fffaf0; color: #c05621; border-color: #dd6b20; }

.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.4;
    border: 1px solid transparent;
    text-align: center;
}
.badge.active { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.badge.danger { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.badge.pending { background: #feebc8; color: #7b341e; border-color: #fbd38d; }

.icon-btn svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
.spinner-small {
    display: inline-block;
}

/* Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: nowrap;
}

/* Override full-width when .search is inside a .toolbar — let it grow/shrink */
.toolbar .search {
    flex: 1 1 180px;
    width: auto;
    min-width: 120px;
}

/* ── Toolbar icon-only action buttons ── */
.toolbar-icon-btn {
    flex-shrink: 0;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.18s;
    font-family: var(--font-family);
    position: relative;
}

.toolbar-icon-btn svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;
}

.toolbar-icon-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.toolbar-icon-btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: none;
}

.toolbar-icon-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* Danger variant */
.toolbar-icon-btn.danger {
    color: var(--danger);
    background: #fff5f5;
    border-color: #fed7d7;
}
.toolbar-icon-btn.danger:hover:not(:disabled) {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}

/* Success variant */
.toolbar-icon-btn.success {
    color: var(--success);
    background: #f0fff4;
    border-color: #c6f6d5;
}
.toolbar-icon-btn.success:hover:not(:disabled) {
    background: var(--success);
    color: #fff;
    border-color: var(--success);
}

/* Primary variant */
.toolbar-icon-btn.primary {
    color: var(--primary);
    background: rgba(57, 181, 171, 0.08);
    border-color: rgba(57, 181, 171, 0.2);
}
.toolbar-icon-btn.primary:hover:not(:disabled) {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* Secondary (neutral) variant */
.toolbar-icon-btn.secondary {
    color: #475569;
    background: #f8fafc;
    border-color: #e2e8f0;
}
.toolbar-icon-btn.secondary:hover:not(:disabled) {
    background: #475569;
    color: #fff;
    border-color: #475569;
}

.grid-container {
    height: 600px;
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
}

/* Filtros de precisión (Pills) */
.score-filter-group {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #f8fafc;
    padding: 4px 8px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}
.score-pill {
    background: transparent;
    border: none;
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #64748b;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-family);
}
.score-pill:hover {
    color: #1e293b;
    background: #f1f5f9;
}
.score-pill.active {
    background: #ffffff;
    color: var(--primary);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* ──────────────────────────────────────────────────────────── 
   Sobrescritura de Variables AG-Grid Alpine al tema Corporativo
   ──────────────────────────────────────────────────────────── */
body .ag-theme-alpine {
    --ag-font-family: var(--font-family);
    --ag-primary-color: #39b5ab;
    --ag-checkbox-checked-color: #39b5ab;
    --ag-selected-row-background-color: rgba(57, 181, 171, 0.12);
    --ag-row-hover-color: rgba(57, 181, 171, 0.05);
    --ag-input-focus-border-color: #39b5ab;
    --ag-input-focus-box-shadow: 0 0 0 4px rgba(57, 181, 171, 0.15);
    --ag-active-color: #39b5ab;
}

/* Toasts */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
.toast {
    background: var(--text-main);
    color: white;
    padding: 14px 20px;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 250px;
    max-width: 350px;
    pointer-events: auto;
    transform: translateX(120%);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.toast.toast-show {
    transform: translateX(0);
    opacity: 1;
}
.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--danger); }
.toast-info { border-left: 4px solid var(--primary); }

/* Loader Spinner */
.spinner {
    animation: rotate 2s linear infinite;
    z-index: 2;
    width: 18px;
    height: 18px;
}
.spinner .path {
    stroke: currentColor;
    stroke-linecap: round;
    animation: dash 1.5s ease-in-out infinite;
}
@keyframes rotate { 100% { transform: rotate(360deg); } }
@keyframes dash {
    0% { stroke-dasharray: 1, 150; stroke-dashoffset: 0; }
    50% { stroke-dasharray: 90, 150; stroke-dashoffset: -35; }
    100% { stroke-dasharray: 90, 150; stroke-dashoffset: -124; }
}
.is-loading {
    color: transparent !important;
    position: relative;
    pointer-events: none;
}
.is-loading::after {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: rotate 0.8s linear infinite;
}

/* Utilidades */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.95rem;
}
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #f87171; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #34d399; }
.text-center { text-align: center; }
.mt-4 { margin-top: 1rem; }

/* Drag & Drop Zones */
.drop-zone {
    width: 100%;
    max-width: 600px;
    height: 180px;
    padding: 25px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 16px;
    font-weight: bold;
    color: var(--text-muted);
    background: var(--bg-body);
    border: 2px dashed var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-sizing: border-box;
}
.drop-zone.dragover {
    background: #ebf8ff;
    border-color: var(--primary);
    color: var(--primary);
}
.drop-zone input[type=file] {
    display: none;
}
.drop-zone-text {
    margin-bottom: 10px;
}
.drop-zone-subtext {
    font-size: 14px;
    font-weight: normal;
}
.selected-file {
    font-size: 14px;
    color: var(--success);
    font-weight: bold;
    margin-top: 15px;
    display: none;
}

/* ──────────────────────────────────────────────────────────── 
   Tarjetas Bento Grid Panel Principal
   ──────────────────────────────────────────────────────────── */
.bento-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 290px), 1fr));
    gap: 24px;
    margin-top: 30px;
}

.dash-card {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    text-align: left;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.dash-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--primary);
    transform: scaleX(0);
    transition: transform 0.3s ease;
    transform-origin: left;
}

.dash-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(57, 181, 171, 0.12), 0 5px 15px rgba(0,0,0,0.05);
    border-color: rgba(57, 181, 171, 0.3);
}

.dash-card:hover::before {
    transform: scaleX(1);
}

.dash-card-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    transition: all 0.3s ease;
}

.dash-card:hover .dash-card-icon {
    background: rgba(57, 181, 171, 0.1);
    transform: scale(1.1);
}

.dash-card-icon svg {
    width: 28px;
    height: 28px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.dash-card-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
}

.dash-card-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.4;
}

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
    animation: modalOverlayIn .18s ease;
}
@keyframes modalOverlayIn { from { opacity:0; } to { opacity:1; } }

/* G.10 — Tarjeta de modal estándar */
.modal-card {
    background: var(--bg-card, #fff);
    border-radius: 20px;
    padding: 36px;
    width: 460px;
    max-width: 100%;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
    animation: dupModalIn .22s ease;
    text-align: center;
}
@keyframes dupModalIn {
    from { opacity:0; transform: scale(.94) translateY(8px); }
    to   { opacity:1; transform: none; }
}
.modal-card h2 {
    margin: 0 0 10px;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main, #1e293b);
    text-align: center;
}
.modal-card p {
    margin: 0 0 28px;
    font-size: 0.92rem;
    color: var(--text-muted, #64748b);
    line-height: 1.65;
    text-align: center;
}

/* Icono circular del modal */
.modal-icon-badge {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}
.modal-icon-badge.warning {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
}
.modal-icon-badge.primary {
    background: linear-gradient(135deg, #d1fae5, #a7f3d0);
}
.modal-icon-badge.danger {
    background: linear-gradient(135deg, #fee2e2, #fca5a5);
}
.modal-icon-badge.pulse {
    animation: badgePulse 1.4s ease-in-out infinite;
}
@keyframes badgePulse {
    0%, 100% { transform: scale(1); }
    50%       { transform: scale(1.08); }
}

/* Botones de acción del modal */
.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 0;
    justify-content: center;
}
.btn-modal-cancel {
    flex: 1;
    padding: 12px 16px;
    border-radius: 10px;
    border: 1.5px solid var(--border, #e2e8f0);
    background: transparent;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-muted, #64748b);
    cursor: pointer;
    transition: background .15s;
}
.btn-modal-cancel:hover { background: #f1f5f9; }

.btn-modal-confirm {
    flex: 1;
    padding: 12px 16px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, var(--primary, #39b5ab), #2e968d);
    font-size: 0.92rem;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(57, 181, 171, 0.35);
    transition: opacity .15s;
}
.btn-modal-confirm:hover { opacity: .88; }

/* Spinner para Modal.showProgress */
.processing-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border, #e2e8f0);
    border-top-color: var(--primary, #39b5ab);
    border-radius: 50%;
    animation: spin .8s linear infinite;
    margin: 16px auto 0;
}


.modal {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 30px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: modalFadeIn 0.3s ease-out forwards;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal h2 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-stat {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
}
.modal-stat:last-child {
    border-bottom: none;
}
.modal-stat span:first-child {
    color: var(--text-muted);
    font-weight: 500;
}
.modal-stat span:last-child {
    font-weight: 600;
    color: var(--text-main);
}

.modal-actions {
    margin-top: 25px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.modal-form-group {
    margin-bottom: 20px;
}
.modal-form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
}
.modal-form-group input, .modal-form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
}

/* ============================================================
   MANUAL MAPPING — Drag & Drop Layout
   ============================================================ */

/* Two-column panel layout */
.layout {
    display: flex;
    gap: 20px;
    height: calc(100vh - 240px);
    min-height: 500px;
}

.panel-left {
    flex: 0 0 320px;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-card);
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

.panel-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-card);
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

.panel-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
    flex-shrink: 0;
}

.panel-header h3 {
    margin: 0 0 10px 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Left panel: JSON field chips */
.panel-left .panel-content {
    flex-direction: row;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 6px;
}

.chip {
    display: inline-flex;
    align-items: center;
    padding: 5px 11px;
    background: rgba(57, 181, 171, 0.08);
    border: 1px solid rgba(57, 181, 171, 0.3);
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 500;
    color: #2e968d;
    cursor: grab;
    user-select: none;
    transition: all 0.15s ease;
    max-width: 100%;
    word-break: break-all;
}

.chip:hover {
    background: rgba(57, 181, 171, 0.18);
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(57, 181, 171, 0.2);
}

.chip:active {
    cursor: grabbing;
    transform: scale(0.97);
}

/* Right panel: Template column rows — 3-column fixed grid */
.col-row {
    display: grid;
    grid-template-columns: 1fr 90px 240px;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid #f1f5f9;
    gap: 10px;
    transition: background 0.15s;
    border-radius: 6px;
    margin-bottom: 1px;
    min-height: 44px;
}

.col-row:last-child {
    border-bottom: none;
}

.col-row:hover {
    background: #f8fafc;
}

.col-row.drag-over {
    background: rgba(57, 181, 171, 0.08);
    border: 1px dashed var(--primary);
    border-radius: 8px;
}

/* Column 1: Name */
.col-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-main);
    min-width: 0;
    word-break: break-word;
}

/* Column 2: Toggle (fixed width, centered) */
.col-toggle {
    display: flex;
    align-items: center;
    gap: 5px;
    justify-content: flex-start;
    white-space: nowrap;
}

.col-toggle .mode-label {
    font-size: 11px;
    color: #718096;
    min-width: 38px;
}

/* Column 3: Badge area (fixed width, always right) */
.col-badge-area {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-width: 0;
}


/* Mapped badge — auto (green) */
.mapped-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: #d1fae5;
    border: 1px solid #6ee7b7;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    color: #065f46;
    max-width: 280px;
    overflow: hidden;
}

.mapped-badge span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Mapped badge — manual override (orange) */
.mapped-badge.manual {
    background: #fff7ed;
    border-color: #fdba74;
    color: #7c2d12;
}

.btn-clear {
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    font-size: 0.85rem;
    padding: 0 2px;
    line-height: 1;
    opacity: 0.6;
    transition: opacity 0.15s;
    flex-shrink: 0;
}

.btn-clear:hover {
    opacity: 1;
}

/* "Sin mapear" label */
.unmapped {
    font-size: 0.78rem;
    color: #94a3b8;
    font-style: italic;
}

/* Toggle Auto / Manual */
.mode-container {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: #cbd5e1;
    border-radius: 20px;
    transition: background 0.2s;
}

.slider:before {
    content: "";
    position: absolute;
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.switch input:checked + .slider {
    background-color: var(--primary);
}

.switch input:checked + .slider:before {
    transform: translateX(16px);
}

/* Scrollbar styling for panels */
.panel-content::-webkit-scrollbar {
    width: 5px;
}
.panel-content::-webkit-scrollbar-track {
    background: transparent;
}
.panel-content::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
.panel-content::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Chip: already-used state (still draggable) */
.chip-used {
    opacity: 0.45;
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #94a3b8;
}

.chip-used:hover {
    opacity: 0.75;
    border-color: #94a3b8;
    box-shadow: none;
}

/* Chip: actively being dragged */
.chip-dragging {
    opacity: 0.35;
    transform: scale(0.95);
}

/* Left panel filter label */
.mm-filter-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #718096;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}

.mm-filter-label input[type=checkbox] {
    cursor: pointer;
    accent-color: var(--primary);
}

/* Empty state for left panel when no upload_id */
.mm-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    text-align: center;
    padding: 30px 16px;
    gap: 12px;
}

.mm-empty-state svg {
    stroke: #cbd5e1;
    opacity: 0.7;
}

.mm-empty-state p {
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.6;
}

/* ============================================================
   BEHAVIOR ICON GROUP — Template Mappings "Bloqueo" column
   ============================================================ */
.behavior-icon-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.behavior-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.18s ease;
    padding: 0;
    flex-shrink: 0;
}

.behavior-icon-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    opacity: 1 !important;
}

.behavior-icon-btn:hover:not(.active) {
    color: #475569;
    border-color: #94a3b8;
    background: #f8fafc;
}

.behavior-icon-btn svg {
    pointer-events: none;
    display: block;
}

.behavior-icon-btn.active {
    font-weight: 600;
}

/* ============================================================
   AUDIT STATS BLOCK
   ============================================================ */

.stats {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.stat {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex: 1;
    min-width: 110px;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    transition: box-shadow 0.2s;
}

.stat:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.stat b {
    display: block;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.1;
}

.stat.ok {
    border-color: #6ee7b7;
    background: #f0fdf4;
}
.stat.ok b { color: #065f46; }

.stat.warn {
    border-color: #fbd38d;
    background: #fffbeb;
}
.stat.warn b { color: #92400e; }

.stat.bad {
    border-color: #fca5a5;
    background: #fff5f5;
}
.stat.bad b { color: #991b1b; }

/* Progress Bar */
.progress-bar-wrap {
    width: 100%;
    height: 10px;
    background: #e2e8f0;
    border-radius: 99px;
    overflow: hidden;
    margin-top: 4px;
}

.progress-bar-inner {
    height: 100%;
    border-radius: 99px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 6px;
    font-size: 10px;
    font-weight: 700;
    color: white;
    transition: width 0.5s ease;
    min-width: 30px;
}

/* Info banner — teal corporativo */
.info-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: rgba(57, 181, 171, 0.08);
    border: 1px solid rgba(57, 181, 171, 0.3);
    border-radius: 8px;
    color: var(--primary);
    font-size: 13px;
    margin-top: 10px;
}

.info-banner svg {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Template selector estándar */
.tpl-select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: var(--font-family);
    font-size: 0.875rem;
    color: var(--text-main);
    background: #ffffff;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    min-width: 280px;
}

.tpl-select:hover { border-color: #cbd5e1; }
.tpl-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(57, 181, 171, 0.15);
}

/* Filter Select in toolbar */
.filter-select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: var(--font-family);
    font-size: 0.875rem;
    color: var(--text-main);
    background: #ffffff;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.filter-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(57, 181, 171, 0.15);
}

/* 026: shared spacing and operational accessibility, without overriding saved branding. */
:root { --space-1:8px; --space-2:16px; --space-3:24px; --space-4:32px; --space-6:48px; }
body.has-header :focus-visible { outline:2px solid #237970; outline-offset:3px; }
.page-section-text { min-width:0; }
.page-section-text h1 { line-height:1.3; overflow-wrap:anywhere; }
.general-upload-grid { display:grid; grid-template-columns:minmax(0,1.25fr) minmax(0,1fr); gap:var(--space-4); align-items:start; max-width:1100px; padding-top:var(--space-3); }
.general-upload-grid .form-group { min-width:0; margin-bottom:0; }
.general-upload-grid .form-control { box-sizing:border-box; width:100%; }
.general-file-empty { display:grid; gap:12px; padding:24px 8px; text-align:center; }
.general-file-empty .pi { font-size:1.7rem; }
.general-file-empty span, .form-hint { font-size:.875rem; color:var(--text-muted); }
.general-file-list { display:grid; gap:8px; }
.general-file-row { display:flex; align-items:center; gap:16px; justify-content:space-between; }
.general-file-row span { overflow-wrap:anywhere; min-width:0; }
.general-upload-grid .p-fileupload-header { flex-wrap:wrap; }
.general-upload-grid .p-button-label { white-space:normal; }
.form-label { display:block; font-size:.875rem; font-weight:600; margin:8px 0 4px; }
body.has-header button:disabled { cursor:not-allowed; }
@media (max-width:700px) {
  body.has-header .container { width:calc(100% - 24px); margin:16px auto; padding:16px; }
  .general-upload-grid { grid-template-columns:minmax(0,1fr); gap:24px; }
  .bento-grid { gap:16px; margin-top:24px; }
  .dash-card { padding:20px; }
  .page-section-header { gap:12px; margin-bottom:24px; flex-wrap:wrap; }
  .page-section-header > .page-section-text { flex:1 1 calc(100% - 64px); }
  .page-section-header > .button { margin-left:0 !important; max-width:100%; }
  .page-section-icon { width:40px; height:40px; }
  .page-section-text h1 { font-size:1.35rem; }
  .app-header { position:relative; }
  .logo-img { height:64px; }
  .dropdown-menu { max-width:calc(100vw - 32px); min-width:220px; }
}

body.has-header .container.file-workspace { width: calc(100% - 32px); max-width: 880px; }
.file-workspace .page-section-header { margin-bottom: 1rem; padding-bottom: .9rem; align-items: center; }
.file-transform-context { overflow-wrap: anywhere; margin-bottom: 1rem; }
.file-transform-context > section { padding: .65rem .8rem; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: .55rem; }
.file-transform-context h2 { margin: 0 0 .35rem; font-size: 1rem; }
.file-transform-context p { margin: .1rem 0; }
.file-transform-destinations { margin-top: .85rem; }
.file-transform-options { display: flex; gap: .4rem; flex-wrap: wrap; }
.file-transform-options a { box-sizing: border-box; display: inline-flex; align-items: center; min-height: 40px; padding: .35rem .7rem; border: 1px solid #cbd5e1; border-radius: .45rem; color: #155b55; font-size: .875rem; font-weight: 600; text-decoration: none; }
.file-transform-options a:hover { background: #e6f5f2; }
.file-transform-options a[aria-current="page"] { background: #0f766e; color: #fff; border-color: #0f766e; }
.file-workspace-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
