/**
 * Luuk Feedback CSS
 * Estilos para feedback visual, validación y estados de carga
 *
 * Guías de diseño:
 * - Fondos grises neutros: #f9fafb, #f3f4f6, #e5e7eb
 * - Color de acento: var(--color) solo para estados activos
 * - Border-radius: 4-6px (compacto)
 * - Sin emojis
 */

/* ========================================
   ESTADOS DE VALIDACIÓN INLINE
   ======================================== */

.input-validating {
    border-color: #6b7280 !important;
    background-color: #f9fafb !important;
}

.input-valid {
    border-color: #10b981 !important;
    background-color: #ffffff !important;
}

.input-valid:focus {
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2) !important;
}

.input-invalid {
    border-color: #ef4444 !important;
    background-color: #fef2f2 !important;
}

.input-invalid:focus {
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2) !important;
}

/* Mensajes de validación */
.validation-message {
    font-size: 12px;
    margin-top: 4px;
    display: block;
}

.validation-message.error {
    color: #ef4444;
}

.validation-message.success {
    color: #10b981;
}

.validation-message.info {
    color: #6b7280;
}

/* ========================================
   LOADING OVERLAY MEJORADO
   ======================================== */

.luuk-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    z-index: 9999;
    transition: opacity 0.2s ease;
}

.luuk-loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.luuk-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e5e7eb;
    border-top-color: var(--color, #29c178);
    border-radius: 50%;
    animation: luuk-spin 0.8s linear infinite;
}

.luuk-loading-text {
    margin-top: 16px;
    color: #374151;
    font-size: 14px;
}

@keyframes luuk-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ========================================
   BOTONES CON ESTADO DE CARGA
   ======================================== */

.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.btn-loading .btn-text {
    visibility: hidden;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: luuk-spin 0.8s linear infinite;
}

/* Botón con spinner inline */
.btn-with-spinner {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-spinner {
    display: none;
    width: 14px;
    height: 14px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: luuk-spin 0.8s linear infinite;
}

.btn-loading .btn-spinner {
    display: inline-block;
}

/* ========================================
   TABLAS RESPONSIVE
   ======================================== */

.table-responsive-luuk {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 16px;
}

@media (max-width: 992px) {
    .table-responsive-luuk table {
        min-width: 700px;
    }
}

@media (max-width: 768px) {
    .table-responsive-luuk table {
        min-width: 600px;
    }

    /* Botones más compactos en móvil */
    .table-responsive-luuk .btnUser,
    .table-responsive-luuk .btn-sm {
        padding: 4px 8px;
        font-size: 11px;
        margin: 2px;
    }

    /* Celdas más compactas */
    .table-responsive-luuk td,
    .table-responsive-luuk th {
        padding: 8px 6px;
        font-size: 13px;
    }
}

/* ========================================
   FEEDBACK VISUAL EN FILAS
   ======================================== */

.row-saving {
    background-color: #fef3c7 !important;
    opacity: 0.8;
    pointer-events: none;
}

.row-saved {
    animation: luuk-flash-success 0.5s ease;
}

.row-error {
    animation: luuk-flash-error 0.5s ease;
    background-color: #fef2f2 !important;
}

@keyframes luuk-flash-success {
    0% {
        background-color: #d1fae5;
    }
    100% {
        background-color: transparent;
    }
}

@keyframes luuk-flash-error {
    0%, 100% {
        background-color: #fef2f2;
    }
    50% {
        background-color: #fee2e2;
    }
}

/* ========================================
   ESTADOS DE FORMULARIO
   ======================================== */

/* Grupo de campo con error */
.form-group.has-error .form-control {
    border-color: #ef4444;
}

.form-group.has-error .control-label,
.form-group.has-error .floating-label {
    color: #ef4444;
}

/* Grupo de campo válido */
.form-group.has-success .form-control {
    border-color: #10b981;
}

/* Indicador de campo requerido */
.form-control.required::after {
    content: '*';
    color: #ef4444;
    margin-left: 4px;
}

/* ========================================
   MEJORAS VISUALES GENERALES
   ======================================== */

/* Transiciones suaves */
.form-control,
.btn,
input,
select,
textarea {
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

/* Focus mejorado */
.form-control:focus {
    border-color: var(--color, #29c178);
    box-shadow: 0 0 0 2px rgba(41, 193, 120, 0.15);
    outline: none;
}

/* Hover en inputs */
.form-control:hover:not(:focus):not(:disabled) {
    border-color: #9ca3af;
}

/* Disabled state */
.form-control:disabled,
.form-control[readonly] {
    background-color: #f3f4f6;
    cursor: not-allowed;
    opacity: 0.7;
}

/* ========================================
   CARDS Y PANELES MEJORADOS
   ======================================== */

.luuk-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 14px;
    margin-bottom: 16px;
}

.luuk-card-header {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e5e7eb;
}

/* ========================================
   BADGES Y TAGS
   ======================================== */

.luuk-badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 500;
    color: #374151;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-left: 3px solid var(--color, #29c178);
    border-radius: 4px;
}

.luuk-badge.success {
    border-left-color: #10b981;
}

.luuk-badge.warning {
    border-left-color: #f59e0b;
}

.luuk-badge.error {
    border-left-color: #ef4444;
}

.luuk-badge.info {
    border-left-color: #3b82f6;
}

/* ========================================
   TOOLTIPS SIMPLES
   ======================================== */

[data-luuk-tooltip] {
    position: relative;
}

[data-luuk-tooltip]::after {
    content: attr(data-luuk-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 8px;
    background: #1f2937;
    color: #ffffff;
    font-size: 12px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    pointer-events: none;
    z-index: 1000;
    margin-bottom: 4px;
}

[data-luuk-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
}

/* ========================================
   SKELETON LOADING
   ======================================== */

.luuk-skeleton {
    background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
    background-size: 200% 100%;
    animation: luuk-skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

.luuk-skeleton-text {
    height: 16px;
    margin-bottom: 8px;
}

.luuk-skeleton-text:last-child {
    width: 60%;
}

@keyframes luuk-skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ========================================
   EMPTY STATE
   ======================================== */

.luuk-empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #6b7280;
}

.luuk-empty-state-icon {
    font-size: 48px;
    color: #d1d5db;
    margin-bottom: 16px;
}

.luuk-empty-state-title {
    font-size: 16px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
}

.luuk-empty-state-text {
    font-size: 14px;
    color: #6b7280;
}

/* ========================================
   ACCIONES DE TABLA MEJORADAS
   ======================================== */

.luuk-actions {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.luuk-actions .btn {
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 4px;
}

/* Hover mejorado en botones de acción */
.luuk-actions .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* ========================================
   PROGRESS BAR SUTIL
   ======================================== */

.luuk-progress {
    height: 4px;
    background: #e5e7eb;
    border-radius: 2px;
    overflow: hidden;
}

.luuk-progress-bar {
    height: 100%;
    background: var(--color, #29c178);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.luuk-progress-bar.warning {
    background: #f59e0b;
}

.luuk-progress-bar.error {
    background: #ef4444;
}

/* ========================================
   TOAST NOTIFICATIONS
   ======================================== */

.luuk-toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 360px;
}

.luuk-toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: luuk-toast-in 0.3s ease;
    min-width: 280px;
}

.luuk-toast.hiding {
    animation: luuk-toast-out 0.2s ease forwards;
}

.luuk-toast-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.luuk-toast.success .luuk-toast-icon {
    background: #d1fae5;
    color: #059669;
}

.luuk-toast.error .luuk-toast-icon {
    background: #fee2e2;
    color: #dc2626;
}

.luuk-toast.warning .luuk-toast-icon {
    background: #fef3c7;
    color: #d97706;
}

.luuk-toast.info .luuk-toast-icon {
    background: #dbeafe;
    color: #2563eb;
}

.luuk-toast-content {
    flex: 1;
}

.luuk-toast-title {
    font-size: 13px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 2px;
}

.luuk-toast-message {
    font-size: 12px;
    color: #6b7280;
}

.luuk-toast-close {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.15s ease;
}

.luuk-toast-close:hover {
    background: #f3f4f6;
    color: #4b5563;
}

@keyframes luuk-toast-in {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes luuk-toast-out {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* ========================================
   SAVE STATUS INDICATOR
   ======================================== */

.luuk-save-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 4px;
    transition: all 0.2s ease;
    opacity: 0;
    visibility: hidden;
}

.luuk-save-status.visible {
    opacity: 1;
    visibility: visible;
}

.luuk-save-status.saving {
    background: #fef3c7;
    color: #92400e;
}

.luuk-save-status.saved {
    background: #d1fae5;
    color: #065f46;
}

.luuk-save-status.error {
    background: #fee2e2;
    color: #991b1b;
}

.luuk-save-status-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid #d97706;
    border-top-color: transparent;
    border-radius: 50%;
    animation: luuk-spin 0.8s linear infinite;
}

.luuk-save-status-icon {
    font-size: 14px;
}

/* ========================================
   INLINE PROGRESS BAR (Top of page)
   ======================================== */

.luuk-top-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: transparent;
    z-index: 99999;
    pointer-events: none;
}

.luuk-top-progress-bar {
    height: 100%;
    background: var(--color, #29c178);
    width: 0;
    transition: width 0.3s ease;
}

.luuk-top-progress.active .luuk-top-progress-bar {
    animation: luuk-progress-indeterminate 1.5s infinite ease-in-out;
}

@keyframes luuk-progress-indeterminate {
    0% {
        width: 0;
        margin-left: 0;
    }
    50% {
        width: 50%;
        margin-left: 25%;
    }
    100% {
        width: 0;
        margin-left: 100%;
    }
}

/* ========================================
   SWEETALERT PROGRESS BAR
   ======================================== */

.luuk-swal-progress {
    width: 100%;
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
    margin: 8px 0;
}

.luuk-swal-progress-bar {
    height: 100%;
    background: var(--color2, #092825);
    border-radius: 3px;
    transition: width 0.25s ease;
}

/* SweetAlert custom styles */
.swal2-popup.luuk-swal-saving {
    padding: 24px 32px;
}

.swal2-popup.luuk-swal-saving .swal2-title {
    font-size: 18px;
    color: #1f2937;
    margin-bottom: 8px;
}

.swal2-popup.luuk-swal-saving .swal2-html-container {
    margin: 0;
}

/* Success state */
.luuk-swal-success-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 12px;
    background: color-mix(in srgb, var(--color, #29c178) 15%, white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: luuk-swal-pop 0.3s ease;
}

.luuk-swal-success-icon svg {
    width: 28px;
    height: 28px;
    color: var(--color, #29c178);
}

@keyframes luuk-swal-pop {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ========================================
   LUUK ISOTIPO LOADING
   Loading animado con el isotipo de Luuk
   ======================================== */

.luuk-isotipo-loading {
    position: relative;
    width: 64px;
    height: 64px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    animation: luuk-isotipo-pulse 1.2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.luuk-isotipo-loading img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0;
}

/* Pseudo-elemento para colorear el isotipo con --colort */
.luuk-isotipo-loading::before {
    content: '';
    position: absolute;
    inset: 0;
    background-color: var(--colort, #ffffff);
    -webkit-mask-image: url('ia/images/luuk-isotipo-sin-ojos.png');
    -webkit-mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-image: url('ia/images/luuk-isotipo-sin-ojos.png');
    mask-size: contain;
    mask-repeat: no-repeat;
    mask-position: center;
}

/* Animación robótica - pulso mecánico preciso */
@keyframes luuk-isotipo-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(0.92);
        opacity: 0.85;
    }
}

.luuk-isotipo-eyes {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.luuk-isotipo-eye {
    position: absolute;
    width: 9px;
    height: 9px;
    background: var(--colort, #ffffff);
    border-radius: 50%;
    transition: all 0.15s ease-out;
}

.luuk-isotipo-eye.left {
    left: calc(34% - 4.5px);
    top: calc(50% - 4.5px);
}

.luuk-isotipo-eye.right {
    left: calc(66% - 4.5px);
    top: calc(50% - 4.5px);
}

/* Animación de parpadeo */
.luuk-isotipo-loading .luuk-isotipo-eye {
    animation: luuk-eye-blink 2s ease-in-out infinite;
}

.luuk-isotipo-loading .luuk-isotipo-eye.right {
    animation-delay: 0.05s;
}

@keyframes luuk-eye-blink {
    0%, 85%, 100% {
        transform: scaleY(1);
        opacity: 1;
    }
    90% {
        transform: scaleY(0.1);
        opacity: 0.3;
    }
}

/* Movimiento de ojos constante como loading */
.luuk-isotipo-loading .luuk-isotipo-eyes {
    animation: luuk-eyes-loading 1.2s ease-in-out infinite;
}

@keyframes luuk-eyes-loading {
    0% {
        transform: translateX(0) translateY(0);
    }
    20% {
        transform: translateX(3px) translateY(-1px);
    }
    40% {
        transform: translateX(2px) translateY(1px);
    }
    60% {
        transform: translateX(-3px) translateY(-1px);
    }
    80% {
        transform: translateX(-2px) translateY(1px);
    }
    100% {
        transform: translateX(0) translateY(0);
    }
}

/* Override del loading actual - usa el isotipo */
.LoadingGeneral .luuk-isotipo-loading {
    width: 80px;
    height: 80px;
}

/* ========================================
   SEARCH WRAPPER - Componente de búsqueda moderno
   ======================================== */

.luuk-search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 0 12px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.luuk-search-wrapper:focus-within {
    border-color: var(--color, #29c178);
    box-shadow: 0 0 0 2px rgba(41, 193, 120, 0.15);
}

.luuk-search-wrapper:hover:not(:focus-within) {
    border-color: #d1d5db;
}

.luuk-search-icon {
    color: #9ca3af;
    font-size: 16px;
    flex-shrink: 0;
    margin-right: 8px;
}

.luuk-search-wrapper:focus-within .luuk-search-icon {
    color: var(--color, #29c178);
}

.luuk-search-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px 0;
    font-size: 14px;
    color: #374151;
    outline: none;
}

.luuk-search-input::placeholder {
    color: #9ca3af;
}

.luuk-search-clear {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0;
    background: #f3f4f6;
    border: none;
    border-radius: 50%;
    color: #6b7280;
    cursor: pointer;
    flex-shrink: 0;
    margin-left: 8px;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.luuk-search-clear:hover {
    background: #e5e7eb;
    color: #374151;
}

.luuk-search-clear .icon {
    font-size: 10px;
}

/* Filter results indicator - Override MyCss.css styles */
/* Oculto por defecto, JS controla visibilidad */
.luuk-filter-results,
#AvisoResultados0,
#AvisoResultados0.luuk-filter-results {
    display: none;
    align-items: center;
    gap: 10px;
    width: auto !important;
    height: auto !important;
    padding: 8px 14px;
    margin-top: 12px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 13px;
    color: #374151;
}

/* Mostrar cuando tiene clase activa */
#AvisoResultados0.filter-active {
    display: inline-flex !important;
}

.luuk-filter-results span,
#AvisoResultados0 span,
#AvisoResultados {
    color: #374151 !important;
    white-space: nowrap !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    float: none !important;
    width: auto !important;
}

.luuk-filter-clear-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    font-size: 12px;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.15s ease;
}

.luuk-filter-clear-btn:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
    color: #374151;
}

.luuk-filter-clear-btn .icon {
    font-size: 10px;
}

/* Tamaño pequeño para loading inline */
.luuk-isotipo-loading.small {
    width: 40px;
    height: 40px;
}

.luuk-isotipo-loading.small .luuk-isotipo-eye {
    width: 5px;
    height: 5px;
}

.luuk-isotipo-loading.small .luuk-isotipo-eye.left {
    left: calc(34% - 2.5px);
    top: calc(50% - 2.5px);
}

.luuk-isotipo-loading.small .luuk-isotipo-eye.right {
    left: calc(66% - 2.5px);
    top: calc(50% - 2.5px);
}

/* Tamaño grande para loading de página */
.luuk-isotipo-loading.large {
    width: 100px;
    height: 100px;
}

.luuk-isotipo-loading.large .luuk-isotipo-eye {
    width: 14px;
    height: 14px;
}

.luuk-isotipo-loading.large .luuk-isotipo-eye.left {
    left: calc(34% - 7px);
    top: calc(50% - 7px);
}

.luuk-isotipo-loading.large .luuk-isotipo-eye.right {
    left: calc(66% - 7px);
    top: calc(50% - 7px);
}

/* Ocultar el spinner viejo cuando hay isotipo */
.LoadingGeneral:has(.luuk-isotipo-loading) .lds-ring {
    display: none;
}
