/* Custom Animations for Units Page */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleCheck {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Staggered Animation Classes */
.animate-fade-in {
    animation: fadeIn 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
    opacity: 0;
    /* Start hidden */
}


/* Checkbox Animation */
.checkbox-animate:checked+div {
    animation: scaleCheck 0.2s ease-out forwards;
}

/* Card Hover Effects - Vibrant & Premium */
.unit-card {
    transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1),
        box-shadow 0.4s cubic-bezier(0.165, 0.84, 0.44, 1),
        border-color 0.3s ease;
    cursor: pointer;
    position: relative;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.unit-card:hover {
    transform: translateY(-10px) scale(1.02);
    box-shadow: 0 30px 60px -12px rgba(0, 0, 0, 0.15), 0 18px 36px -18px rgba(0, 0, 0, 0.2);
    border-color: var(--primary-gold, #D4AF37) !important;
    z-index: 10;
}

.unit-card:active {
    transform: translateY(2px) scale(0.97);
    transition: transform 0.1s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
}

.unit-card:active .view-details-btn {
    transform: scale(0.95);
    background: #f8fafc;
}

.unit-card-img-container {
    position: relative;
    overflow: hidden;
}

.unit-card-img {
    transition: transform 0.8s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.unit-card:hover .unit-card-img {
    transform: scale(1.15);
}

/* View Details Overlay */
.view-details-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    /* Navy deep with opacity */
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    z-index: 5;
}

.unit-card:hover .view-details-overlay {
    opacity: 1;
}

.view-details-btn {
    background: #fff;
    color: #0f172a;
    padding: 10px 20px;
    border-radius: 50px;
    font-weight: 800;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    transform: translateY(20px);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 8px;
}

.unit-card:hover .view-details-btn {
    transform: translateY(0);
}

[dir="rtl"] .rtl-flip {
    transform: scaleX(-1);
}

.rtl-flip {
    display: inline-block;
    transition: transform 0.3s ease;
}

/* Comparison Panel Slide */
.panel-enter {
    transform: translate(-50%, -50%) scale(1) !important;
    opacity: 1 !important;
}

.backdrop-enter {
    opacity: 1 !important;
}

/* Filter Specifics */
.filter-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
    -webkit-appearance: none;
    appearance: none;
}

/* --- Unit Comparison Full Implementation --- */
#compare-bar {
    transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

#compare-bar.translate-y-0 {
    transform: translateY(0);
    opacity: 1;
}

#compare-modal #compare-backdrop {
    transition: opacity 0.3s ease;
    opacity: 0;
}

#compare-modal:not(.hidden) #compare-backdrop {
    opacity: 1;
}

#compare-modal #compare-panel {
    transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

#compare-modal:not(.hidden) #compare-panel {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* Sticky Column for Comparison Table */
.overflow-x-auto.scrollbar-thin {
    scrollbar-width: thin;
}

#compare-content td.sticky,
#compare-content th.sticky {
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.02);
}

[dir="rtl"] #compare-content td.sticky,
[dir="rtl"] #compare-content th.sticky {
    left: auto !important;
    right: 0 !important;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.02);
}

@media (max-width: 640px) {
    #compare-modal #compare-panel {
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: auto !important;
        width: 100vw !important;
        max-width: 100vw !important;
        border-radius: 0 0 24px 24px !important;
        /* Rounded corners at bottom */
        transform: translateY(-100%) !important;
        /* Start hidden above */
    }

    #compare-modal:not(.hidden) #compare-panel {
        transform: translateY(0) !important;
        left: 0 !important;
    }
}

.compare-checkbox {
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.compare-checkbox:checked {
    transform: scale(1.1);
}

#compare-avatars div {
    transition: all 0.3s ease;
}

#compare-avatars div:hover {
    transform: translateY(-4px) scale(1.1);
    z-index: 10;
}

#compare-content table {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
}

/* Comparison Helper Sidebar */
#comparison-helper {
    filter: drop-shadow(0 20px 50px rgba(0, 0, 0, 0.1));
}

/* Vertical Navigation Tab */
.writing-mode-vertical {
    writing-mode: vertical-rl;
    text-orientation: mixed;
}

.compare-tab-fixed {
    transition: all 0.3s ease;
}

.compare-hint-tooltip {
    transform: translateX(10px);
}

.compare-tab-fixed:hover .compare-hint-tooltip {
    transform: translateX(0);
}

/* Guidance Animation: Highlighting checkboxes when hovering the side tab */
@keyframes guidePulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(201, 162, 63, 0.7);
        border-color: #c9a23f;
    }

    50% {
        transform: scale(1.3);
        box-shadow: 0 0 25px 10px rgba(201, 162, 63, 0.4);
        border-color: #fff;
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(201, 162, 63, 0);
        border-color: #c9a23f;
    }
}

.guide-pulse {
    animation: guidePulse 1s infinite cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 50 !important;
}

/* Tooltip for comparison on mobile */
@media (max-width: 768px) {
    #comparison-helper {
        bottom: 15%;
        top: auto;
        transform: none;
    }

    .compare-tab-fixed .compare-hint-tooltip {
        display: none;
    }
}

#comparison-helper .bg-navy-deep\/90 {
    box-shadow: -10px 0 30px rgba(15, 23, 42, 0.1);
}

/* Comparison Helper Sidebar - Premium Style */
#comparison-helper {
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

#comparison-helper .group:hover {
    filter: brightness(1.1);
}

#comparison-helper .animate-pulse {
    box-shadow: 0 0 10px var(--gold-main);
}

@keyframes pulse-gold {
    0% {
        box-shadow: 0 0 0 0 rgba(201, 162, 63, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(201, 162, 63, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(201, 162, 63, 0);
    }
}

#comparison-helper .w-14 {
    animation: pulse-gold 2s infinite;
}

/* Checkbox wrapper interaction - Refined */
.compare-checkbox-wrapper {
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    border-width: 2px;
}

.compare-click-area:hover .compare-checkbox-wrapper {
    transform: scale(1.15);
    background: #fff;
    border-color: var(--gold-main);
}

.compare-checkbox-wrapper.bg-gold-main {
    animation: scaleCheck 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Ensure hit area is clear */
.compare-click-area {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

/* Checkbox wrapper interaction */
.compare-checkbox-wrapper {
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.compare-checkbox-wrapper:hover {
    background: #fff;
    border-color: var(--gold-main);
}

.compare-checkbox-wrapper.bg-gold-main {
    border-color: rgba(255, 255, 255, 0.3);
    color: #fff;
}

.compare-checkbox-wrapper.bg-gold-main input {
    filter: brightness(0) invert(1);
}

/* Hover hint for the entire card to show the comparison checkbox is important */
.unit-card:hover .compare-checkbox-wrapper:not(.bg-gold-main) {
    border-color: var(--gold-main);
    transform: scale(1.1);
}