/* ═══════════════════════════════════════════════════════════════
   NELLY – Animations
   ═══════════════════════════════════════════════════════════════ */

/* ── Shared Keyframes ────────────────────────────────────────── */
@keyframes enrich-signal-pulse {
    0% { box-shadow: 0 0 12px 2px rgba(79, 140, 255, 0.12); }
    50% { box-shadow: 0 0 20px 6px rgba(79, 140, 255, 0.25); }
    100% { box-shadow: 0 0 12px 2px rgba(79, 140, 255, 0.12); }
}
.enrich-btn:not(.loading) {
    animation: enrich-signal-pulse 3s ease-in-out infinite;
}
@keyframes float {
    0% { transform: translate(0, 0) scale(1) rotate(0deg); }
    20% { transform: translate(60px, -50px) scale(1.1) rotate(5deg); }
    40% { transform: translate(-40px, 40px) scale(0.95) rotate(-3deg); }
    60% { transform: translate(50px, 60px) scale(1.05) rotate(4deg); }
    80% { transform: translate(-30px, -30px) scale(1.08) rotate(-5deg); }
    100% { transform: translate(0, 0) scale(1) rotate(0deg); }
}

@keyframes pulse-tag {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ── Button Animations ───────────────────────────────────────── */
button, .btn, .save-btn, .action-btn, .submit-btn, .icon-btn, 
.bulk-action-btn, .file-btn, .enrich-btn, .dedup-rescan-btn {
    transition: box-shadow 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

button:hover, .btn:hover, .save-btn:hover, .action-btn:hover, 
.submit-btn:hover, .icon-btn:hover, .bulk-action-btn:hover, 
.file-btn:hover, .enrich-btn:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

button:active, .btn:active, .save-btn:active, .action-btn:active,
.submit-btn:active, .icon-btn:active, .bulk-action-btn:active,
.enrich-btn:active {
    transform: scale(0.98);
}

/* ── Primary Button Glow ─────────────────────────────────────── */
.submit-btn, .swal2-confirm, .enrich-btn, .dedup-rescan-btn {
    box-shadow: 0 2px 8px rgba(79, 140, 255, 0.3);
}

.submit-btn:hover, .swal2-confirm:hover, .enrich-btn:hover,
.dedup-rescan-btn:hover {
    box-shadow: 0 4px 16px rgba(79, 140, 255, 0.35);
}

/* ── Toggle Option ───────────────────────────────────────────── */
.toggle-option {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle-option:hover:not(.active) {
    background: rgba(79, 140, 255, 0.08);
}

.toggle-option.active {
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Dropdown Animations ─────────────────────────────────────── */
.dropdown-body {
    visibility: hidden;
    opacity: 0;
    transform: translateY(-4px) scaleY(0.97);
    pointer-events: none;
    transition: visibility 0.2s, opacity 0.2s, transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: top center;
}

.dropdown-body.show {
    visibility: visible;
    opacity: 1;
    transform: translateY(0) scaleY(1);
    pointer-events: auto;
}

.profile-menu {
    animation: dropdownSlide 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: top center;
}

@keyframes dropdownSlide {
    from {
        opacity: 0;
        transform: translateY(-8px) scaleY(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scaleY(1);
    }
}

.dropdown-header {
    transition: all 0.2s ease;
}

.dropdown-header:hover {
    border-color: var(--primary);
    background: var(--bg-color);
}

.dropdown-list li {
    transition: background 0.15s ease;
}

.dropdown-list li:hover {
    background: var(--bg-color);
}

/* ── Profile Menu ───────────────────────────────────────────── */
.profile-menu-btn {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.profile-menu-btn:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.profile-menu a, .profile-menu button {
    transition: background 0.2s ease;
}

.profile-menu a:hover, .profile-menu button:hover {
    background: rgba(79, 140, 255, 0.12);
}

/* ── Input Focus Animation ──────────────────────────────────── */
input, select, textarea, .form-input, .searchbar {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus, select:focus, textarea:focus,
.form-input:focus, .searchbar:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,140,255, 0.15);
}

/* ── Autocomplete ───────────────────────────────────────────── */
.autocomplete-list {
    animation: autocompleteSlide 0.2s ease;
    transform-origin: top;
}

@keyframes autocompleteSlide {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.autocomplete-item {
    transition: background 0.15s ease;
}

.autocomplete-item:hover, .autocomplete-item.focused {
    background: var(--bg-color);
}

/* ── Tab Transitions ───────────────────────────────────────── */
.tab, .settings-panel {
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab.active {
    opacity: 1;
    transform: translateY(0);
}

.tab:not(.active) {
    opacity: 0.5;
}

.settings-panel {
    opacity: 1;
    transform: translateX(0);
}

.settings-panel.hidden {
    display: none;
}

/* ── Modal Animations ───────────────────────────────────────── */
.dedup-modal, .merge-modal {
    animation: modalBackdrop 0.25s ease;
}

.dedup-modal-box, .merge-modal-box {
    animation: modalScaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

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

.swal2-popup.swal2-show {
    animation: swal2ScaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.swal2-popup.swal2-hide {
    animation: swal2ScaleOut 0.2s ease forwards;
}

@keyframes swal2ScaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.swal2-popup.swal2-show .swal2-icon {
    animation: modalIconIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalIconIn {
    0% {
        opacity: 0;
        transform: scale(0) rotate(-45deg);
    }
    70% {
        transform: scale(1.2) rotate(5deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

@keyframes swal2ScaleOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.95);
    }
}

/* ── Close Button ───────────────────────────────────────────── */
.dedup-modal-close, .merge-modal-close, .clear-history-btn {
    transition: all 0.2s ease;
}

.dedup-modal-close:hover, .merge-modal-close:hover,
.clear-history-btn:hover {
    background: var(--border);
    transform: rotate(90deg);
}

/* ── Business Card Animations ───────────────────────────────── */
.business-card {
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.business-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    border-color: var(--primary);
}

.business-card.selected {
    box-shadow: 0 0 0 2px var(--primary), 0 4px 16px rgba(79, 140, 255, 0.2);
}

/* Business Card Fade In - only apply when JS adds animation */
.business-item.fade-in {
    opacity: 0;
    animation: cardFadeIn 0.4s ease forwards;
}

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

/* ── Status Badge Pulse ─────────────────────────────────────── */
.status-badge, .enrich-status-tag, .status-badge.running, 
.status-badge.verifying, .enrich-badge.running, .enrich-badge.verifying,
.enrich-job-badge.running, .enrich-job-badge.verifying {
    animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.65; }
}

/* ── Scroll Spinner ─────────────────────────────────────────── */
.scroll-spinner {
    animation: spin 0.8s linear infinite;
}

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

/* ── Loading Skeletons ──────────────────────────────────────── */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--accent2) 25%,
        var(--border) 50%,
        var(--accent2) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 6px;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── Branch Card ────────────────────────────────────────────── */
.branch-card {
    transition: all 0.2s ease;
}

.branch-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: var(--primary);
}

/* ── Contact Card ───────────────────────────────────────────── */
.contact-card {
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.contact-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: var(--primary);
}

/* ── Enrich Category Accordion ─────────────────────────────── */
.enrich-category-header {
    transition: background 0.2s ease;
}

.enrich-category-header:hover {
    background: rgba(79, 140, 255, 0.05);
}

.enrich-category-header .arrow {
    transition: transform 0.25s ease;
}

.enrich-category.collapsed .enrich-category-header .arrow {
    transform: rotate(-90deg);
}

.enrich-category-body {
    animation: accordionOpen 0.3s ease;
}

@keyframes accordionOpen {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Standorte Card ─────────────────────────────────────────── */
.standorte-toggle {
    transition: background 0.15s ease;
}

.standorte-toggle:hover {
    background: rgba(79, 140, 255, 0.05);
}

.standorte-toggle .arrow {
    transition: transform 0.25s ease;
}

.standorte-card.open .standorte-toggle .arrow {
    transform: rotate(180deg);
}

.standorte-body {
    transition: max-height 0.3s ease;
}

/* ── User Row ───────────────────────────────────────────────── */
.user-row {
    transition: background 0.2s ease;
}

.user-row:hover {
    background: rgba(79, 140, 255, 0.08);
}

/* ── Panel Fade In ─────────────────────────────────────────── */
.settings-panel, .admin-grid, .activity-log-list {
    animation: panelFadeIn 0.35s ease;
}

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

/* ── Toast Notifications ────────────────────────────────────── */
.toast {
    animation: toastFadeIn 0.3s ease;
}

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

/* ── Dedup / Merge Candidate Card ───────────────────────────── */
.dedup-candidate-card, .merge-candidate-card {
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.dedup-candidate-card:hover, .merge-candidate-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: var(--primary);
}

/* ── Back Button ───────────────────────────────────────────── */
.back-btn {
    transition: all 0.2s ease;
}

.back-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* ── Links ──────────────────────────────────────────────────── */
a, .activity-link {
    transition: all 0.15s ease;
}

a:hover, .activity-link:hover {
    color: var(--primary);
}

/* ── Progress Bar ───────────────────────────────────────────── */
.progress-bar-fill, .enrich-progress-fill {
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Checkbox Animation ─────────────────────────────────────── */
.b-select-checkbox {
    transition: all 0.15s ease;
}

.b-select-checkbox:hover {
    transform: scale(1.1);
    box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.18);
}

.b-select-checkbox:checked {
    animation: checkBounce 0.3s ease;
}

@keyframes checkBounce {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* ── Smooth Scroll ─────────────────────────────────────────── */
html {
    scroll-behavior: smooth;
}

/* ── Light Theme Specific ───────────────────────────────────── */
[data-theme="light"] button:hover, 
[data-theme="light"] .btn:hover,
[data-theme="light"] .submit-btn:hover,
[data-theme="light"] .enrich-btn:hover {
    box-shadow: 0 6px 16px rgba(9, 105, 218, 0.25);
}

[data-theme="light"] .business-card:hover,
[data-theme="light"] .branch-card:hover,
[data-theme="light"] .contact-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .user-row:hover {
    background: rgba(9, 105, 218, 0.05);
}

[data-theme="light"] .dropdown-list li:hover,
[data-theme="light"] .autocomplete-item:hover {
    background: rgba(9, 105, 218, 0.05);
}

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

body:not(.animate) *,
body:not(.animate) *::before,
body:not(.animate) *::after {
    animation: none !important;
    transition: none !important;
}

/* ═══════════════════════════════════════════════════════════════
   Loading Screen
   ═══════════════════════════════════════════════════════════════ */

.loading-screen {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-color, #181a1b);
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loading-screen .loading-logo {
    width: 100px;
    height: auto;
    margin-bottom: 36px;
    animation: loadingLogoPulse 2s ease-in-out infinite;
    filter: drop-shadow(0 4px 20px rgba(79, 140, 255, 0.15));
}

@keyframes loadingLogoPulse {
    0%, 100% { transform: scale(1); opacity: 0.85; }
    50% { transform: scale(1.04); opacity: 1; }
}

.loading-screen .loading-track {
    width: 220px;
    height: 3px;
    border-radius: 4px;
    background: var(--border, #2d323e);
    overflow: hidden;
    position: relative;
}

.loading-screen .loading-bar {
    height: 100%;
    width: 30%;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--primary, #4f8cff), #7aadff);
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.loading-screen .loading-bar.indeterminate {
    animation: loadingSlide 1.4s ease-in-out infinite;
}

@keyframes loadingSlide {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(433%); }
}
