/* ===================================
    Rotate Box Component - Crafto Theme Integration
    Compatible with existing theme colors and styles
====================================== */

/* Main rotate box container - Updated class names */
.rotate-boxes-section {
    margin-bottom: 50px;
    padding: 2rem 0;
}

.rotate-boxes-section .section-title {
    background-color: #2d4566;
    color: white;
    padding: 15px 20px;
    margin-bottom: 30px;
    border-radius: 8px;
    font-size: 1.25rem;
    font-weight: 600;
    text-align: center;
}

/* Grid layout for responsive columns - Updated class names */
.rotate-boxes-grid {
    display: grid;
    gap: 25px;
    margin-bottom: 20px;
    padding: 0 15px;
}

/* Column configurations - Updated class names */
.rotate-boxes-grid.cols-4 {
    grid-template-columns: repeat(4, 1fr);
}

.rotate-boxes-grid.cols-5 {
    grid-template-columns: repeat(5, 1fr);
}

.rotate-boxes-grid.cols-6 {
    grid-template-columns: repeat(6, 1fr);
}

/* Individual rotate box wrapper */
.rotate-box-wrapper {
    perspective: 1000px;
    -webkit-perspective: 1000px;
    height: 250px;
}

.rotate-box {
    width: 100%;
    height: 100%;
    cursor: default;
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.rotate-box:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* Hand cursor for boxes with links */
.rotate-box-wrapper[data-has-link="true"] .rotate-box {
    cursor: pointer;
}

/* Flip container */
.rotate-box-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    -webkit-transform-style: preserve-3d;
    transform-style: preserve-3d;
    -webkit-transition: -webkit-transform 0.6s ease;
    transition: transform 0.6s ease;
}

.rotate-box:hover .rotate-box-inner {
    -webkit-transform: rotateY(180deg);
    transform: rotateY(180deg);
}

/* Front and back faces */
.rotate-box-front,
.rotate-box-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border: 1px solid #e0e0e0;
    top: 0;
    left: 0;
}

/* Front face styling */
.rotate-box-front {
    background: white;
    color: #2d4566;
    z-index: 2;
}

/* Back face styling */
.rotate-box-back {
    background: #2d4566 !important;
    color: white !important;
    border-color: #2d4566;
    -webkit-transform: rotateY(180deg);
    transform: rotateY(180deg);
    z-index: 1;
}

/* Content structure */
.rotate-box-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.rotate-box-media {
    margin-bottom: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 80px;
    width: 80px;
}

.rotate-box-image {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    object-fit: cover;
}

/* Icon styling */
.rotate-box-icon {
    font-size: 3rem;
    color: #2d4566;
    transition: transform 0.3s ease;
}

.rotate-box-back .rotate-box-icon {
    color: #ffffff;
}

.rotate-box:hover .rotate-box-icon {
    transform: scale(1.1);
}

/* Background image support */
.rotate-box-front.has-bg-image {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
}

.rotate-box-front.has-bg-image::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 12px;
}

.rotate-box-front.has-bg-image * {
    position: relative;
    z-index: 2;
}

/* Typography */
.rotate-box-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    color: #2d4566;
    line-height: 1.4;
    font-family: var(--alt-font);
}

.rotate-box-description {
    font-size: 0.9rem !important;
    line-height: 1.4 !important;
    margin: 0 0 1rem 0 !important;
    color: rgba(255, 255, 255, 0.9) !important;
    font-family: var(--primary-font);
}

.rotate-box-back .rotate-box-description {
    opacity: 0.95;
}

/* Button styling */
.rotate-box-link {
    margin-top: auto;
    background-color: #0286dd;
    border-color: #0286dd;
    font-size: 0.85rem;
    padding: 0.4rem 0.8rem;
    display: inline-block;
    color: white;
    text-decoration: none;
    border-radius: 25px;
    font-weight: 500;
    transition: all 0.3s ease;
    border: 2px solid #0286dd;
}

.rotate-box-link:hover {
    background-color: #0170bb;
    border-color: #0170bb;
    color: white;
    transform: translateY(-2px);
}

.rotate-box-back .rotate-box-link {
    background-color: white;
    color: #2d4566;
    border-color: white;
}

.rotate-box-back .rotate-box-link:hover {
    background-color: transparent;
    color: white;
    border-color: white;
}

/* Tablet Layout */
@media (min-width: 768px) and (max-width: 1023px) {
    .rotate-boxes-grid.cols-4,
    .rotate-boxes-grid.cols-5,
    .rotate-boxes-grid.cols-6 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile responsiveness */
@media (max-width: 991px) {
    .rotate-boxes-grid.cols-4,
    .rotate-boxes-grid.cols-5,
    .rotate-boxes-grid.cols-6 {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }
    
    .rotate-box-wrapper {
        height: 250px;
    }
    
    .rotate-box-icon {
        font-size: 2.5rem;
        margin-bottom: 15px;
    }
    
    .rotate-box-title {
        font-size: 1.1rem;
    }
    
    .rotate-box-description {
        font-size: 0.9rem;
    }
}

/* Desktop and Mobile Sections */
.rotate-boxes-desktop {
    display: block;
}

.rotate-boxes-mobile {
    display: none;
}

/* MOBILE STYLES - Simple Clean List */
.mobile-rotate-item {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: box-shadow 0.3s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    cursor: default;
}

.mobile-rotate-item:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Hand cursor for mobile boxes with links */
.mobile-rotate-item[data-has-link="true"] {
    cursor: pointer;
}

.mobile-icon {
    width: 50px;
    height: 50px;
    background: #f8f9fa;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.75rem;
    flex-shrink: 0;
}

.mobile-icon-font {
    font-size: 1.8rem;
    color: #2d4566;
}

.mobile-image {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    object-fit: cover;
}

.mobile-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.mobile-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #2d4566;
    margin-bottom: 0.5rem;
    line-height: 1.2;
}

.mobile-description {
    font-size: 0.75rem;
    color: #6c757d;
    line-height: 1.3;
    margin: 0;
}

@media (max-width: 767px) {
    .rotate-boxes-desktop {
        display: none !important;
    }
    
    .rotate-boxes-mobile {
        display: block !important;
    }
}

/* Loading animation */
.rotate-box-loading {
    opacity: 0;
    transform: translateY(30px);
    animation: rotateBoxFadeIn 0.6s ease forwards;
}

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

/* Stagger animation delays */
.rotate-box:nth-child(1) { animation-delay: 0.1s; }
.rotate-box:nth-child(2) { animation-delay: 0.2s; }
.rotate-box:nth-child(3) { animation-delay: 0.3s; }
.rotate-box:nth-child(4) { animation-delay: 0.4s; }
.rotate-box:nth-child(5) { animation-delay: 0.5s; }
.rotate-box:nth-child(6) { animation-delay: 0.6s; }
.rotate-box:nth-child(7) { animation-delay: 0.7s; }
.rotate-box:nth-child(8) { animation-delay: 0.8s; }
.rotate-box:nth-child(9) { animation-delay: 0.9s; }
.rotate-box:nth-child(10) { animation-delay: 1.0s; }
.rotate-box:nth-child(11) { animation-delay: 1.1s; }
.rotate-box:nth-child(12) { animation-delay: 1.2s; }

/* Enhanced mobile interactions */
.rotate-box-mobile .rotate-box {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.rotate-box.user-flipped .rotate-box-inner {
    transform: rotateY(180deg) !important;
}

.rotate-box.interaction-active {
    z-index: 10;
}

/* Form integration styles */
.rotate-box.form-loading .rotate-box-back::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: rotate-spin 1s linear infinite;
    z-index: 10;
}

.rotate-box.form-success .rotate-box-back {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
}

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

/* Enhanced accessibility */
.rotate-box:focus {
    outline: 3px solid #0286dd;
    outline-offset: 2px;
}

.rotate-box:focus:not(:focus-visible) {
    outline: none;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .rotate-box-front {
        border: 2px solid;
    }
    
    .rotate-box-back {
        border: 2px solid white;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .rotate-box-inner {
        transition: none;
    }
    
    .rotate-box {
        animation: none;
    }
    
    .rotate-box-loading {
        opacity: 1;
        transform: none;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .rotate-box-front {
        background: linear-gradient(135deg, #2d3748 0%, #4a5568 100%);
        color: #e2e8f0;
        border-color: #4a5568;
    }
    
    .rotate-box-front.has-bg-image::before {
        background: rgba(45, 55, 72, 0.9);
    }
}

/* Enhanced performance optimizations */
.rotate-box-inner {
    will-change: transform;
    backface-visibility: hidden;
    transform-style: preserve-3d;
    perspective: 1000px;
}

.rotate-box-front,
.rotate-box-back {
    will-change: transform;
    backface-visibility: hidden;
}

/* Print styles */
@media print {
    .rotate-box {
        break-inside: avoid;
        height: auto;
        perspective: none;
    }
    
    .rotate-box-inner {
        transform: none;
        transform-style: flat;
    }
    
    .rotate-box-front,
    .rotate-box-back {
        position: relative;
        backface-visibility: visible;
        transform: none;
    }
    
    .rotate-box-back {
        margin-top: 20px;
        border-top: 2px solid #2d4566;
        padding-top: 20px;
    }
}

/* Fallback for older browsers */
.no-css3dtransforms .rotate-box:hover .rotate-box-front {
    display: none;
}

.no-css3dtransforms .rotate-box:hover .rotate-box-back {
    display: flex;
    transform: none;
}

/* Custom CSS variables for theme integration */
:root {
    --rotate-box-duration: 0.6s;
    --rotate-box-easing: cubic-bezier(0.4, 0.0, 0.2, 1);
    --rotate-box-hover-lift: 5px;
    --rotate-box-border-radius: 12px;
}

.rotate-box-inner {
    transition: transform var(--rotate-box-duration) var(--rotate-box-easing);
}

.rotate-box:hover {
    transform: translateY(calc(-1 * var(--rotate-box-hover-lift)));
}

.rotate-box-front,
.rotate-box-back {
    border-radius: var(--rotate-box-border-radius);
}

/* Enhanced grid system */
.rotate-box-grid {
    --min-column-width: 250px;
    --grid-gap: 25px;
    
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(var(--min-column-width), 1fr));
    gap: var(--grid-gap);
    margin-bottom: 20px;
}

.rotate-box-grid.columns-4 {
    --min-column-width: 250px;
}

.rotate-box-grid.columns-5 {
    --min-column-width: 220px;
}

.rotate-box-grid.columns-6 {
    --min-column-width: 200px;
}

/* Enhanced responsive behavior */
@media (max-width: 1400px) {
    .rotate-box-grid {
        --min-column-width: 280px;
    }
}

@media (max-width: 1200px) {
    .rotate-box-grid.columns-5,
    .rotate-box-grid.columns-6 {
        --min-column-width: 300px;
    }
}

@media (max-width: 991px) {
    .rotate-box-grid {
        --min-column-width: 320px;
        --grid-gap: 20px;
    }
}

@media (max-width: 767px) {
    .rotate-box-grid {
        --min-column-width: calc(50% - 7.5px);
        grid-template-columns: 1fr 1fr;
        --grid-gap: 15px;
    }
}

/* Micro-interactions */
.rotate-box .rotate-box-button {
    transform: translateY(0);
    transition: all 0.3s ease;
}

.rotate-box .rotate-box-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(2, 134, 221, 0.4);
}

.rotate-box .rotate-box-button:active {
    transform: translateY(-1px);
}

/* Loading states */
.rotate-box-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

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

/* Error states */
.rotate-box.error-state .rotate-box-front {
    background: linear-gradient(135deg, #fee 0%, #fdd 100%);
    border-color: #f5c6cb;
}

.rotate-box.error-state .rotate-box-back {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
}