/* Custom Flipbox Widget Styles */

.custom-flipbox {
    position: relative;
    perspective: 1000px;
    width: 100%;
    height: 300px;
    cursor: pointer;
    --hover-duration: 300ms;
}

.custom-flipbox .flipbox-side {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    transition: transform 0.6s cubic-bezier(0.4, 0.0, 0.2, 1);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.custom-flipbox .flipbox-content {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    color: #fff;
    padding: 15px;
    box-sizing: border-box;
}

.custom-flipbox .flipbox-top-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding-top: 0;
    text-align: center;
}

.custom-flipbox .flipbox-bottom-area {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    min-height: 50px;
    padding-top: 15px;
}

.custom-flipbox .flipbox-number {
    font-size: 2.5em;
    font-weight: bold;
    margin-bottom: 10px;
    opacity: 0.8;
    line-height: 1;
    color: inherit;
}

.custom-flipbox .flipbox-graphic {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all var(--hover-duration, 300ms) ease;
    box-sizing: border-box;
}

.custom-flipbox .flipbox-graphic-left {
    order: -1;
}

.custom-flipbox .flipbox-graphic-right {
    order: 1;
}

.custom-flipbox .flipbox-graphic:hover {
    transform: scale(1.05);
}

.custom-flipbox .flipbox-icon {
    font-size: 2em;
    color: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--hover-duration, 300ms) ease;
    line-height: 1;
}

.custom-flipbox .flipbox-icon i {
    font-size: inherit;
    color: inherit;
}

.custom-flipbox .flipbox-icon svg {
    width: 1em;
    height: 1em;
    fill: currentColor;
    color: inherit;
    transition: all var(--hover-duration, 300ms) ease;
}

.custom-flipbox .flipbox-image {
    transition: all var(--hover-duration, 300ms) ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.custom-flipbox .flipbox-image img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    transition: all var(--hover-duration, 300ms) ease;
}

.custom-flipbox .flipbox-title {
    font-size: 1.5em;
    font-weight: bold;
    margin: 0 0 15px 0;
    line-height: 1.3;
    color: inherit;
}

.custom-flipbox .flipbox-description {
    font-size: 1em;
    line-height: 1.5;
    margin: 0 0 20px 0;
    opacity: 0.9;
    color: inherit;
}

.custom-flipbox .flipbox-button {
    flex-shrink: 0;
}

.custom-flipbox .flipbox-btn {
    display: inline-block;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    text-decoration: none;
    border-radius: 5px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    transition: all var(--hover-duration, 300ms) ease;
    font-weight: 500;
    font-size: 0.9em;
    cursor: pointer;
    box-sizing: border-box;
}

.custom-flipbox .flipbox-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
    text-decoration: none;
}

/* Special layout for front panel when icon is on left */
.custom-flipbox .flipbox-front .flipbox-bottom-area .flipbox-graphic-left {
    margin-right: auto;
}

.custom-flipbox .flipbox-front .flipbox-bottom-area .flipbox-graphic-right {
    margin-left: auto;
}

/* Front panel bottom area - default center for icons */
.custom-flipbox .flipbox-front .flipbox-bottom-area {
    justify-content: center;
}

/* Back panel specific layout - Default Desktop */
.custom-flipbox .flipbox-back .flipbox-bottom-area {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.custom-flipbox .flipbox-back .flipbox-button {
    flex: 0 0 auto;
}

.custom-flipbox .flipbox-back .flipbox-graphic {
    flex: 0 0 auto;
}

/* Row layout - explicitly horizontal */
.custom-flipbox .flipbox-back .flipbox-bottom-area[style*="flex-direction: row"] {
    flex-direction: row !important;
    justify-content: space-between;
    align-items: center;
}

/* Column layout - vertical */
.custom-flipbox .flipbox-back .flipbox-bottom-area[style*="flex-direction: column"] {
    flex-direction: column !important;
    justify-content: flex-start;
    align-items: center;
}

.custom-flipbox .flipbox-back .flipbox-bottom-area[style*="flex-direction: column"] .flipbox-graphic {
    order: -1; /* Icon always appears first (above button) */
}

.custom-flipbox .flipbox-back .flipbox-bottom-area[style*="flex-direction: column"] .flipbox-button {
    order: 1; /* Button appears second (below icon) */
}

/* When only one element exists */
.custom-flipbox .flipbox-back .flipbox-bottom-area .flipbox-button:only-child {
    margin-left: 0;
}

.custom-flipbox .flipbox-back .flipbox-bottom-area .flipbox-graphic:only-child {
    margin-right: 0;
}

/* Default state */
.custom-flipbox .flipbox-front {
    transform: rotateY(0deg);
    z-index: 2;
}

.custom-flipbox .flipbox-back {
    transform: rotateY(-180deg);
    z-index: 1;
}

/* ===== FLIP ANIMATIONS ===== */

/* Horizontal Flip */
.custom-flipbox.flipbox-flip.flip-horizontal:hover .flipbox-front,
.custom-flipbox.flipbox-flip.flip-horizontal.flipped .flipbox-front {
    transform: rotateY(180deg);
    z-index: 1;
}

.custom-flipbox.flipbox-flip.flip-horizontal:hover .flipbox-back,
.custom-flipbox.flipbox-flip.flip-horizontal.flipped .flipbox-back {
    transform: rotateY(0deg);
    z-index: 2;
}

/* Vertical Flip */
.custom-flipbox.flipbox-flip.flip-vertical .flipbox-front {
    transform: rotateX(0deg);
}

.custom-flipbox.flipbox-flip.flip-vertical .flipbox-back {
    transform: rotateX(-180deg);
}

.custom-flipbox.flipbox-flip.flip-vertical:hover .flipbox-front,
.custom-flipbox.flipbox-flip.flip-vertical.flipped .flipbox-front {
    transform: rotateX(180deg);
    z-index: 1;
}

.custom-flipbox.flipbox-flip.flip-vertical:hover .flipbox-back,
.custom-flipbox.flipbox-flip.flip-vertical.flipped .flipbox-back {
    transform: rotateX(0deg);
    z-index: 2;
}

/* ===== FADE ANIMATIONS ===== */

.custom-flipbox.flipbox-fade .flipbox-side {
    transition: opacity 0.6s ease-in-out;
    transform: none !important;
}

.custom-flipbox.flipbox-fade .flipbox-front {
    opacity: 1;
    z-index: 2;
}

.custom-flipbox.flipbox-fade .flipbox-back {
    opacity: 0;
    z-index: 1;
}

.custom-flipbox.flipbox-fade:hover .flipbox-front,
.custom-flipbox.flipbox-fade.flipped .flipbox-front {
    opacity: 0;
    z-index: 1;
}

.custom-flipbox.flipbox-fade:hover .flipbox-back,
.custom-flipbox.flipbox-fade.flipped .flipbox-back {
    opacity: 1;
    z-index: 2;
}

/* ===== SWAP ANIMATIONS ===== */

.custom-flipbox.flipbox-swap .flipbox-side {
    transition: transform 0.6s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.custom-flipbox.flipbox-swap .flipbox-front {
    transform: translateX(0) scale(1);
    z-index: 2;
}

.custom-flipbox.flipbox-swap .flipbox-back {
    transform: translateX(100%) scale(0.8);
    z-index: 1;
}

.custom-flipbox.flipbox-swap:hover .flipbox-front,
.custom-flipbox.flipbox-swap.flipped .flipbox-front {
    transform: translateX(-100%) scale(0.8);
    z-index: 1;
}

.custom-flipbox.flipbox-swap:hover .flipbox-back,
.custom-flipbox.flipbox-swap.flipped .flipbox-back {
    transform: translateX(0) scale(1);
    z-index: 2;
}

/* ===== ZOOM IN ANIMATIONS ===== */

.custom-flipbox.flipbox-zoom-in .flipbox-side {
    transition: all 0.6s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.custom-flipbox.flipbox-zoom-in .flipbox-front {
    transform: scale(1);
    opacity: 1;
    z-index: 2;
}

.custom-flipbox.flipbox-zoom-in .flipbox-back {
    transform: scale(0.8);
    opacity: 0;
    z-index: 1;
}

.custom-flipbox.flipbox-zoom-in:hover .flipbox-front,
.custom-flipbox.flipbox-zoom-in.flipped .flipbox-front {
    transform: scale(1.2);
    opacity: 0;
    z-index: 1;
}

.custom-flipbox.flipbox-zoom-in:hover .flipbox-back,
.custom-flipbox.flipbox-zoom-in.flipped .flipbox-back {
    transform: scale(1);
    opacity: 1;
    z-index: 2;
}

/* ===== ZOOM OUT ANIMATIONS ===== */

.custom-flipbox.flipbox-zoom-out .flipbox-side {
    transition: all 0.6s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.custom-flipbox.flipbox-zoom-out .flipbox-front {
    transform: scale(1);
    opacity: 1;
    z-index: 2;
}

.custom-flipbox.flipbox-zoom-out .flipbox-back {
    transform: scale(1.2);
    opacity: 0;
    z-index: 1;
}

.custom-flipbox.flipbox-zoom-out:hover .flipbox-front,
.custom-flipbox.flipbox-zoom-out.flipped .flipbox-front {
    transform: scale(0.8);
    opacity: 0;
    z-index: 1;
}

.custom-flipbox.flipbox-zoom-out:hover .flipbox-back,
.custom-flipbox.flipbox-zoom-out.flipped .flipbox-back {
    transform: scale(1);
    opacity: 1;
    z-index: 2;
}

/* ===== CLICK TRIGGER SPECIFIC STYLES ===== */

.custom-flipbox.trigger-click {
    cursor: pointer;
}

.custom-flipbox.trigger-click:not(.flipped):hover .flipbox-front,
.custom-flipbox.trigger-click:not(.flipped):hover .flipbox-back {
    /* Reset hover effects for click trigger */
    transform: inherit;
    opacity: inherit;
    z-index: inherit;
}

/* Re-apply default states for click trigger */
.custom-flipbox.trigger-click:not(.flipped) .flipbox-front {
    z-index: 2;
}

.custom-flipbox.trigger-click:not(.flipped) .flipbox-back {
    z-index: 1;
}

/* ===== RESPONSIVE DESIGN ===== */

@media (max-width: 768px) {
    .custom-flipbox .flipbox-title {
        font-size: 1.3em;
    }
    
    .custom-flipbox .flipbox-description {
        font-size: 0.9em;
    }
    
    .custom-flipbox .flipbox-number {
        font-size: 2em;
    }
    
    .custom-flipbox .flipbox-icon {
        font-size: 1.8em;
    }
    
    .custom-flipbox .flipbox-image img {
        width: 40px;
        height: 40px;
    }
    
    .custom-flipbox .flipbox-bottom-area {
        min-height: 40px;
    }
    
    /* Default column layout for tablet - only when default (empty) option is selected */
    .custom-flipbox .flipbox-back .flipbox-bottom-area:not([style*="flex-direction: row"]):not([style*="flex-direction: column"]) {
        flex-direction: column !important;
        align-items: center;
        justify-content: flex-start;
    }
    
    .custom-flipbox .flipbox-back .flipbox-bottom-area:not([style*="flex-direction: row"]):not([style*="flex-direction: column"]) .flipbox-graphic {
        order: -1;
    }
    
    .custom-flipbox .flipbox-back .flipbox-bottom-area:not([style*="flex-direction: row"]):not([style*="flex-direction: column"]) .flipbox-button {
        order: 1;
    }
}

@media (max-width: 480px) {
    .custom-flipbox .flipbox-content {
        padding: 12px;
    }
    
    .custom-flipbox .flipbox-title {
        font-size: 1.2em;
        margin-bottom: 8px;
    }
    
    .custom-flipbox .flipbox-description {
        font-size: 0.85em;
        margin-bottom: 12px;
    }
    
    .custom-flipbox .flipbox-number {
        font-size: 1.8em;
        margin-bottom: 6px;
    }
    
    .custom-flipbox .flipbox-icon {
        font-size: 1.5em;
    }
    
    .custom-flipbox .flipbox-image img {
        width: 35px;
        height: 35px;
    }
    
    .custom-flipbox .flipbox-bottom-area {
        min-height: 35px;
        padding-top: 10px;
        gap: 10px;
    }
    
    /* Default column layout for mobile - only when default (empty) option is selected */
    .custom-flipbox .flipbox-back .flipbox-bottom-area:not([style*="flex-direction: row"]):not([style*="flex-direction: column"]) {
        gap: 12px;
        flex-direction: column !important;
        align-items: center;
        justify-content: flex-start;
    }
    
    .custom-flipbox .flipbox-back .flipbox-bottom-area:not([style*="flex-direction: row"]):not([style*="flex-direction: column"]) .flipbox-graphic {
        order: -1;
    }
    
    .custom-flipbox .flipbox-back .flipbox-bottom-area:not([style*="flex-direction: row"]):not([style*="flex-direction: column"]) .flipbox-button {
        order: 1;
    }
    
    .custom-flipbox .flipbox-btn {
        padding: 6px 12px;
        font-size: 0.8em;
    }
}
