/* ── Design Tokens ─────────────────────────────────────────────────── */
:root {
    --ep-bg: #FAFAFA;
    --ep-card: #FFFFFF;
    --ep-text-primary: #111827;
    --ep-text-secondary: #6B7280;
    --ep-primary: #0071E3;
    --ep-primary-hover: #005BB5;
    --ep-border: #E5E7EB;
    --ep-success: #059669;
    --ep-warning: #D97706;
    --ep-cta: #10B981;
    --ep-cta-hover: #059669;
    --ep-sidebar-w: 256px;
    --ep-header-h: 56px;
}
.dark {
    --ep-bg: #121212;
    --ep-card: #1A1A1A;
    --ep-text-primary: #E5E7EB;
    --ep-text-secondary: #9CA3AF;
    --ep-border: #374151;
    --ep-cta: #10B981;
    --ep-cta-hover: #059669;
}

/* ── Reduced motion ────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ── Sidebar ───────────────────────────────────────────────────────── */
.sidebar-open { overflow: hidden; }
@media (max-width: 767px) {
    #sidebar.open { transform: translateX(0); }
}
.sidebar-history-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    font-size: 13px;
    color: var(--ep-text-secondary);
}
.sidebar-history-item:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--ep-text-primary);
}
.dark .sidebar-history-item:hover {
    background: rgba(255, 255, 255, 0.06);
}
.sidebar-history-item.active {
    background: rgba(0, 113, 227, 0.08);
    color: #0071E3;
}
.dark .sidebar-history-item.active {
    background: rgba(0, 113, 227, 0.15);
    color: #60A5FA;
}

/* ── Source Tabs ────────────────────────────────────────────────────── */
.source-tab {
    color: var(--ep-text-secondary);
    background: transparent;
}
.source-tab:hover:not(.active) {
    background: rgba(0, 0, 0, 0.04);
}
.dark .source-tab:hover:not(.active) {
    background: rgba(255, 255, 255, 0.06);
}
.source-tab.active {
    background: #fff;
    color: var(--ep-text-primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.dark .source-tab.active {
    background: #374151;
    color: #E5E7EB;
}

/* Custom Animations */
@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(200%);
    }
}

.loading-shimmer {
    animation: shimmer 1.5s infinite linear;
    transform-origin: left;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* Hide scrollbar for cleaner look */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background-color: #D1D5DB;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background-color: #9CA3AF;
}

/* Utilities not in compiled Tailwind build */
.overflow-x-auto  { overflow-x: auto; }
.overflow-y-auto  { overflow-y: auto; }
.tabular-nums     { font-variant-numeric: tabular-nums; }
.text-10          { font-size: 10px; }
.leading-none     { line-height: 1; }

/* Dividers for toolbar groups */
.toolbar-group {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 20px;
    border-right: 1px solid #F3F4F6;
}
.dark .toolbar-group { border-right-color: #1F2937; }
.toolbar-group:last-child { border-right: none; }

/* Preview button — bg tint not in compiled CSS */
#preview-toggle-btn {
    background-color: rgba(0, 113, 227, 0.05);
    border-color: rgba(0, 113, 227, 0.3);
}
#preview-toggle-btn:hover {
    background-color: rgba(0, 113, 227, 0.1);
    border-color: rgba(0, 113, 227, 0.55);
}
.dark #preview-toggle-btn {
    background-color: rgba(0, 113, 227, 0.08);
    border-color: rgba(0, 113, 227, 0.22);
}
.dark #preview-toggle-btn:hover {
    background-color: rgba(0, 113, 227, 0.15);
    border-color: rgba(0, 113, 227, 0.5);
}

/* sm:hidden / sm:flex for mobile print button */
@media (min-width: 640px) {
    .sm-hidden { display: none !important; }
    .sm-flex   { display: flex !important; }
}

/* Segmented control pills for compact toolbars (preview modal) */
.seg-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 14px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid #E5E7EB;
    background: #fff;
    color: #374151;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    white-space: nowrap;
    line-height: 1.6;
}
.seg-btn:first-child { border-radius: 8px 0 0 8px; }
.seg-btn:last-child  { border-radius: 0 8px 8px 0; border-left: none; }
.seg-btn:only-child  { border-radius: 8px; }
.seg-btn + .seg-btn  { border-left: none; }
.seg-btn:hover:not(.active) { background: #F9FAFB; border-color: rgba(0,113,227,0.4); }
.seg-btn.active {
    background: #0071E3;
    border-color: #0071E3;
    color: #fff;
    z-index: 1;
    position: relative;
}

.dark .seg-btn {
    background: #374151;
    border-color: #4B5563;
    color: #D1D5DB;
}
.dark .seg-btn:hover:not(.active) { background: #4B5563; border-color: rgba(96,165,250,0.5); }
.dark .seg-btn.active { background: #0071E3; border-color: #0071E3; color: #fff; }

/* Preview document shadow for the scaled iframe wrapper */
#pdf-preview-modal-scaler iframe {
    box-shadow: 0 4px 24px rgba(0,0,0,0.18), 0 1px 4px rgba(0,0,0,0.1);
}

/* Pareados: glow when a new field is added */
@keyframes fieldGlow {
    0%   { box-shadow: 0 0 0 3px rgba(139,92,246,0.5); }
    100% { box-shadow: 0 0 0 3px transparent; }
}
.field-highlight {
    animation: fieldGlow 1.2s ease-out forwards;
}

/* ── Drag & Drop de preguntas ───────────────────────────────────────── */
.draggable-card { position: relative; }
.drag-handle {
    position: absolute;
    left: 4px;
    top: 20px;
    width: 22px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    background: transparent;
    border: none;
    padding: 0;
    cursor: grab;
    opacity: 0;
    border-radius: 4px;
    transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
    touch-action: none;
    user-select: none;
    z-index: 5;
}
.draggable-card:hover .drag-handle { opacity: 1; }
.drag-handle:hover { color: #e8614d; background: rgba(232, 97, 77, 0.1); }
.drag-handle:active { cursor: grabbing; }
.dark .drag-handle { color: #6b7280; }
.dark .drag-handle:hover { color: #f87171; background: rgba(232, 97, 77, 0.15); }
@media (max-width: 640px) {
    .drag-handle { opacity: 1; }
}
.draggable-card.dragging {
    opacity: 0.85;
    border: 2px dashed #e8614d !important;
    padding-top: 0.75rem !important;
    padding-bottom: 0.75rem !important;
}
/* Colapsar contenido de la card mientras se arrastra: mostrar solo el header
   (enunciado + badge). Aplica a la card activa (.dragging) y a las peers de
   la misma sección (.drag-peer-collapsed). Transiciones con max-height para
   que colapso/expansión sean fluidos. */
.draggable-card {
    transition: transform 0.22s cubic-bezier(.2,.7,.3,1),
                padding 0.22s ease;
}
.draggable-card > *:not(.drag-handle):not(:first-child) {
    overflow: hidden;
    transition: max-height 0.25s ease, opacity 0.2s ease,
                margin 0.25s ease, padding 0.25s ease;
    max-height: 1500px;
    opacity: 1;
}
.draggable-card.dragging > *:not(.drag-handle):not(:first-child),
.draggable-card.drag-peer-collapsed > *:not(.drag-handle):not(:first-child) {
    max-height: 0 !important;
    opacity: 0 !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}
.draggable-card.dragging > :first-child,
.draggable-card.drag-peer-collapsed > :first-child {
    margin-bottom: 0 !important;
}
.draggable-card.dragging .q-text,
.draggable-card.drag-peer-collapsed .q-text {
    min-height: 0 !important;
    pointer-events: none;
}
.draggable-card.dragging,
.draggable-card.drag-peer-collapsed {
    padding-top: 0.75rem !important;
    padding-bottom: 0.75rem !important;
}
.draggable-card.drag-peer-collapsed { opacity: 0.9; }
.draggable-card.drop-indicator-top { box-shadow: 0 -3px 0 0 #e8614d; }
.draggable-card.drop-indicator-bottom { box-shadow: 0 3px 0 0 #e8614d; }

/* Onboarding highlight ring on target element */
.onboarding-highlight {
    outline: 2px solid #0071E3 !important;
    outline-offset: 4px;
    border-radius: 12px;
    z-index: 10;
    box-shadow: 0 0 0 4000px rgba(0,0,0,0.08);
}

/* Onboarding tooltip mobile */
@media (max-width: 640px) {
    #onboarding-tooltip {
        left: 1rem !important;
        right: 1rem !important;
        max-width: none !important;
        bottom: 1rem !important;
        top: auto !important;
    }
}

/* Tooltip tap-toggle for touch devices */
.tooltip-content.tap-visible {
    opacity: 1 !important;
    visibility: visible !important;
    transform: scale(1) !important;
    pointer-events: auto !important;
}