/* ============================================================================
   CUSTOM STYLES - Estilos manuales adicionales a Tailwind
   ============================================================================ */

/* ============================================================================
   LOOKUP FIELD - Componente de busqueda con picker
   ============================================================================ */

/* Overlay del modal del picker */
.lookup-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

/* Contenido del modal del picker */
.lookup-modal-content {
    background-color: white;
    border-radius: 0.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-width: 32rem;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
}

/* Dark mode */
.dark .lookup-modal-content {
    background-color: #1f2937; /* gray-800 */
}

/* Campo seleccionado - display */
.lookup-selected {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background-color: #f9fafb; /* gray-50 */
    border: 1px solid #e5e7eb; /* gray-200 */
    border-radius: 0.375rem;
}

.dark .lookup-selected {
    background-color: #111827; /* gray-900 */
    border-color: #374151; /* gray-700 */
}

/* Boton de limpiar seleccion */
.lookup-clear-btn {
    margin-left: auto;
    color: #9ca3af; /* gray-400 */
    transition: color 0.15s ease-in-out;
}

.lookup-clear-btn:hover {
    color: #ef4444; /* red-500 */
}

/* Indicador de loading */
.lookup-loading {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: #6b7280; /* gray-500 */
}

.lookup-loading::after {
    content: '';
    width: 1rem;
    height: 1rem;
    border: 2px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* Mensaje de error */
.lookup-error {
    font-size: 0.75rem;
    color: #ef4444; /* red-500 */
    margin-top: 0.25rem;
}

/* Dropdown de resultados de búsqueda (usado en creación rápida) */
.lookup-dropdown {
    display: none;
    position: absolute;
    z-index: 40;
    width: 100%;
    margin-top: 0.25rem;
    background-color: white;
    border: 1px solid #e5e7eb; /* gray-200 */
    border-radius: 0.25rem;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    max-height: 16rem;
    overflow-y: auto;
}

.dark .lookup-dropdown {
    background-color: #1f2937; /* gray-800 */
    border-color: #374151; /* gray-700 */
}

.lookup-dropdown:not(:empty) {
    display: block;
}

.lookup-dropdown.hidden {
    display: none !important;
}

.lookup-option {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    transition: background-color 100ms ease;
    font-size: 0.875rem;
}

.lookup-option:hover {
    background-color: #f3f4f6; /* gray-100 */
}

.dark .lookup-option:hover {
    background-color: #374151; /* gray-700 */
}

/* ============================================================================
   ANIMATIONS
   ============================================================================ */

/* Fade in animation */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.animate-fade-in {
    animation: fadeIn 0.2s ease-out;
}

/* Scale in animation */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.animate-scale-in {
    animation: scaleIn 0.2s ease-out;
}

/* ============================================================================
   LEXICAL EDITOR - Editor rich text para plantillas de mensaje
   ============================================================================ */

/* Wrapper del editor */
.lexical-editor-wrapper {
    border: 1px solid #e5e7eb;
    border-radius: 0.375rem;
    overflow: hidden;
    background-color: white;
}

.dark .lexical-editor-wrapper {
    border-color: #374151;
    background-color: #111827;
}

/* Toolbar */
.lexical-toolbar {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.375rem 0.5rem;
    background-color: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

.dark .lexical-toolbar {
    background-color: #1f2937;
    border-bottom-color: #374151;
}

.lexical-toolbar button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    border: none;
    border-radius: 0.25rem;
    background-color: transparent;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.15s ease;
}

.lexical-toolbar button:hover {
    background-color: #e5e7eb;
    color: #374151;
}

.lexical-toolbar button.active {
    background-color: #3b82f6;
    color: white;
}

.dark .lexical-toolbar button {
    color: #9ca3af;
}

.dark .lexical-toolbar button:hover {
    background-color: #374151;
    color: #f3f4f6;
}

.dark .lexical-toolbar button.active {
    background-color: #3b82f6;
    color: white;
}

.lexical-toolbar-divider {
    width: 1px;
    height: 1.25rem;
    margin: 0 0.375rem;
    background-color: #d1d5db;
}

.dark .lexical-toolbar-divider {
    background-color: #4b5563;
}

/* Contenido del editor */
.lexical-editor-content {
    min-height: 12rem;
    max-height: 24rem;
    padding: 0.75rem;
    font-size: 0.875rem;
    line-height: 1.5;
    color: #111827;
    overflow-y: auto;
    outline: none;
}

.lexical-editor-content:focus {
    outline: none;
}

.dark .lexical-editor-content {
    color: #f3f4f6;
}

/* Placeholder - usando pseudo-elemento con CSS */
.lexical-editor-content:empty::before {
    content: attr(data-placeholder);
    color: #9ca3af;
    pointer-events: none;
}

/* Estilos de texto */
.lexical-paragraph {
    margin: 0 0 0.5rem 0;
}

.lexical-paragraph:last-child {
    margin-bottom: 0;
}

.lexical-bold {
    font-weight: 600;
}

.lexical-italic {
    font-style: italic;
}

.lexical-underline {
    text-decoration: underline;
}

/* Variable chips */
.lexical-variable-chip {
    display: inline-flex;
    align-items: center;
    vertical-align: baseline;
    margin: 0 0.125rem;
    user-select: none;
}

.lexical-variable-chip-inner {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    color: #1d4ed8;
    background-color: #dbeafe;
    border: 1px solid #93c5fd;
    border-radius: 9999px;
    white-space: nowrap;
}

.dark .lexical-variable-chip-inner {
    color: #93c5fd;
    background-color: #1e3a5f;
    border-color: #3b82f6;
}

/* Hover effect en chips */
.lexical-variable-chip:hover .lexical-variable-chip-inner {
    background-color: #bfdbfe;
    border-color: #60a5fa;
}

.dark .lexical-variable-chip:hover .lexical-variable-chip-inner {
    background-color: #1e40af;
    border-color: #60a5fa;
}

/* Focus ring cuando el editor tiene focus */
.lexical-editor-wrapper:focus-within {
    border-color: #3b82f6;
    box-shadow: 0 0 0 1px #3b82f6;
}

/* Scrollbar personalizado */
.lexical-editor-content::-webkit-scrollbar {
    width: 6px;
}

.lexical-editor-content::-webkit-scrollbar-track {
    background: transparent;
}

.lexical-editor-content::-webkit-scrollbar-thumb {
    background-color: #d1d5db;
    border-radius: 3px;
}

.dark .lexical-editor-content::-webkit-scrollbar-thumb {
    background-color: #4b5563;
}

/* ============================================================================
   SIDEBAR COLLAPSED STATE
   ============================================================================ */

/* Cuando el sidebar está colapsado, ajustar margen del main y ancho del sidebar */
@media (min-width: 1024px) {
    .sidebar-collapsed main {
        margin-left: 3rem !important; /* w-12 = 48px = 3rem */
    }
    .sidebar-collapsed #sidebar {
        width: 3rem !important; /* Forzar w-12 (Tailwind w-52 en class estático gana sobre w-12 dinámico) */
    }
}
