/**
 * Public/Frontend Styles for ANFA Cake Customizer
 * Modern UI/UX Redesign
 */

:root {
    --acake-primary: #667eea;
    --acake-primary-dark: #5a6fd6;
    --acake-secondary: #764ba2;
    --acake-accent: #ff7e5f;
    --acake-success: #00b894;
    --acake-text-main: #2d3436;
    --acake-text-muted: #636e72;
    --acake-bg-light: #f8f9fa;
    --acake-border: #dfe6e9;
    --acake-white: #ffffff;
    --acake-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --acake-shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
    --acake-shadow-lg: 0 15px 35px rgba(0, 0, 0, 0.1);
    --acake-radius-sm: 8px;
    --acake-radius-md: 12px;
    --acake-radius-lg: 20px;
    --acake-transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Customize Button */
.acake-customize-wrapper {
    margin: 24px 0;
}

.acake-customize-btn {
    width: 100%;
    padding: 16px 32px;
    font-size: 18px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--acake-primary) 0%, var(--acake-secondary) 100%);
    color: #fff !important;
    border: none;
    border-radius: var(--acake-radius-md);
    cursor: pointer;
    transition: var(--acake-transition);
    text-align: center;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.acake-customize-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
}

/* Modal Styles */
.acake-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.acake-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.acake-modal-content {
    position: relative;
    max-width: 1300px;
    width: 92%;
    height: 85vh;
    margin: 7.5vh auto;
    background: var(--acake-white);
    border-radius: var(--acake-radius-lg);
    overflow: hidden;
    box-shadow: var(--acake-shadow-lg);
    display: flex;
    flex-direction: column;
    animation: acake-modal-slide-up 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes acake-modal-slide-up {
    from { transform: translateY(40px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.acake-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--acake-border);
    border-radius: 50%;
    cursor: pointer;
    z-index: 100;
    transition: var(--acake-transition);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--acake-shadow-sm);
}

.acake-modal-close:hover {
    background: #fff;
    transform: rotate(90deg);
    box-shadow: var(--acake-shadow-md);
}

.acake-modal-close .dashicons {
    color: var(--acake-text-main);
    font-size: 20px;
    width: 20px;
    height: 20px;
    line-height: 20px;
}

/* Customizer Container */
.acake-customizer-container {
    display: grid;
    grid-template-columns: 400px 1fr;
    height: 100%;
    overflow: hidden;
}

/* Preview Section */
.acake-preview-section {
    background: var(--acake-bg-light);
    padding: 30px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--acake-border);
    position: relative;
    z-index: 1;
}

.acake-preview-section h2 {
    margin: 0 0 25px 0;
    font-size: 24px;
    color: var(--acake-text-main);
    font-weight: 700;
    letter-spacing: -0.5px;
}

.acake-preview-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--acake-white);
    border-radius: var(--acake-radius-md);
    padding: 20px;
    margin-bottom: 25px;
    box-shadow: var(--acake-shadow-sm);
    position: relative;
    overflow: hidden;
}

#acake-preview-canvas {
    position: relative;
    width: 100%;
    max-width: 350px;
    aspect-ratio: 1;
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#acake-preview-canvas:hover {
    transform: scale(1.05);
}

.acake-preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--acake-text-muted);
    text-align: center;
}

.acake-preview-placeholder .dashicons {
    font-size: 64px;
    width: 64px;
    height: 64px;
    opacity: 0.2;
    margin-bottom: 15px;
}

/* Loading Overlay */
.acake-preview-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: var(--acake-radius-md);
}

.acake-preview-loading-emoji {
    font-size: 48px;
    margin-bottom: 15px;
    animation: cake-bounce 1s cubic-bezier(0.28, 0.84, 0.42, 1) infinite;
}

.acake-preview-loading-text {
    font-size: 16px;
    color: var(--acake-primary);
    font-weight: 600;
}

@keyframes cake-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

.acake-preview-base-image,
.acake-preview-color-overlay,
.acake-preview-topping,
.acake-preview-text {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.acake-preview-base-image img,
.acake-preview-topping img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 10px 20px rgba(0,0,0,0.15));
}

.acake-preview-color-overlay {
    mix-blend-mode: multiply;
    opacity: 0.3;
}

.acake-preview-text {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 800;
    color: var(--acake-text-main);
    text-align: center;
    padding: 30px;
    text-shadow: 0 2px 4px rgba(255, 255, 255, 0.9);
    z-index: 5;
}

.acake-price-display {
    background: var(--acake-white);
    border-radius: var(--acake-radius-md);
    padding: 25px;
    text-align: center;
    box-shadow: var(--acake-shadow-md);
    border: 1px solid rgba(102, 126, 234, 0.2);
    position: relative;
    overflow: hidden;
}

.acake-price-display::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--acake-primary);
}

.acake-price-label {
    display: block;
    font-size: 14px;
    color: var(--acake-text-muted);
    margin-bottom: 5px;
    font-weight: 500;
}

.acake-price-value {
    display: block;
    font-size: 36px;
    font-weight: 800;
    color: var(--acake-text-main);
    letter-spacing: -1px;
}

.acake-price-value bdi {
    font-family: inherit;
}

/* Steps Section */
.acake-steps-section {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--acake-white);
}

.acake-steps-nav {
    display: flex;
    background: var(--acake-white);
    padding: 0 20px;
    border-bottom: 1px solid var(--acake-border);
    overflow-x: auto;
    scrollbar-width: none; /* Firefox */
}

.acake-steps-nav::-webkit-scrollbar {
    display: none;
}

.acake-step-btn {
    flex: 1;
    min-width: 100px;
    padding: 20px 15px;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: var(--acake-transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    position: relative;
    opacity: 0.6;
}

.acake-step-btn:hover {
    opacity: 0.8;
    background: transparent;
}

.acake-step-btn.active {
    opacity: 1;
}

.acake-step-btn::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--acake-primary);
    transform: scaleX(0);
    transition: transform 0.3s ease;
    border-radius: 3px 3px 0 0;
}

.acake-step-btn.active::after {
    transform: scaleX(1);
}

.step-number {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--acake-bg-light);
    color: var(--acake-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    transition: var(--acake-transition);
    border: 2px solid transparent;
}

.acake-step-btn.active .step-number {
    background: var(--acake-primary);
    color: #fff;
    box-shadow: 0 4px 10px rgba(102, 126, 234, 0.4);
}

.acake-step-btn.completed .step-number {
    background: var(--acake-success);
    color: #fff;
}

.step-label {
    font-size: 13px;
    font-weight: 600;
    color: inherit;
}

.acake-step-btn.acake-step-locked {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Steps Content */
.acake-steps-content {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
    scroll-behavior: smooth;
}

/* Scrollbar Styling */
.acake-steps-content::-webkit-scrollbar {
    width: 8px;
}
.acake-steps-content::-webkit-scrollbar-track {
    background: transparent;
}
.acake-steps-content::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}
.acake-steps-content::-webkit-scrollbar-thumb:hover {
    background-color: rgba(0, 0, 0, 0.2);
}

.acake-step-panel {
    display: none;
    animation: fadeIn 0.4s ease;
}

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

.acake-step-panel.active {
    display: block;
}

.acake-step-panel h3 {
    margin: 0 0 10px 0;
    font-size: 28px;
    color: var(--acake-text-main);
    font-weight: 800;
}

.acake-step-description {
    color: var(--acake-text-muted);
    margin: 0 0 30px 0;
    font-size: 15px;
    line-height: 1.6;
}

/* Options Grid - Force 3 Columns */
.acake-options-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

/* Shapes Grid */
#acake-shapes-grid {
    grid-template-columns: repeat(3, 1fr);
}

/* Modern Card Style */
.acake-option-card {
    background: var(--acake-white);
    border: 1px solid var(--acake-border);
    border-radius: var(--acake-radius-md);
    padding: 20px;
    cursor: pointer;
    transition: var(--acake-transition);
    text-align: center;
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    box-sizing: border-box;
}

.acake-option-card:hover {
    border-color: var(--acake-primary);
    transform: translateY(-4px);
    box-shadow: var(--acake-shadow-md);
}

.acake-option-card.selected {
    border-color: var(--acake-primary);
    background: #fff;
    box-shadow: 0 0 0 2px var(--acake-primary), var(--acake-shadow-md);
}

.acake-option-card.selected::before {
    content: '✓';
    position: absolute;
    top: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    background: var(--acake-primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    from { transform: scale(0); }
    to { transform: scale(1); }
}

.acake-option-image {
    width: 100%;
    aspect-ratio: 1;
    margin: 0 auto 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--acake-bg-light);
    border-radius: var(--acake-radius-sm);
    padding: 10px;
    box-sizing: border-box;
}

.acake-option-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.acake-option-card:hover .acake-option-image img {
    transform: scale(1.1);
}

.acake-option-image .dashicons {
    font-size: 40px;
    width: 40px;
    height: 40px;
    color: var(--acake-border);
}

.acake-option-name {
    font-weight: 700;
    margin-bottom: 5px;
    color: var(--acake-text-main);
    font-size: 15px;
}

.acake-option-description {
    font-size: 12px;
    color: var(--acake-text-muted);
    margin-bottom: 12px;
    line-height: 1.4;
    flex-grow: 1;
}

.acake-option-price {
    font-weight: 700;
    color: var(--acake-primary);
    font-size: 15px;
    background: rgba(102, 126, 234, 0.1);
    padding: 6px 12px;
    border-radius: 20px;
    align-self: center;
}

/* Colors Grid - Fix for display issues */
.acake-colors-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    width: 100%;
}

.acake-colors-grid-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    width: 100%;
}

/* Container for color sections to ensure they stack properly */
.acake-step-panel[data-step="3"] {
    display: none;
}
.acake-step-panel[data-step="3"].active {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.acake-popular-colors {
    width: 100%;
    display: block;
}

.acake-custom-color-picker {
    width: 100%;
    display: block;
    margin-top: 20px;
}

.acake-color-option {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid rgba(0,0,0,0.05);
    transition: var(--acake-transition);
    position: relative;
    box-shadow: var(--acake-shadow-sm);
    flex-shrink: 0; /* Prevent shrinking */
}

.acake-color-option:hover {
    transform: scale(1.15);
    box-shadow: var(--acake-shadow-md);
    z-index: 2;
}

.acake-color-option.selected {
    transform: scale(1.1);
    box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--acake-primary);
    z-index: 2;
}

.acake-color-name {
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 10;
}

.acake-color-option:hover .acake-color-name {
    opacity: 1;
}

/* Toppings Filter */
.acake-toppings-filter {
    margin-bottom: 25px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.acake-filter-btn {
    padding: 8px 20px;
    background: var(--acake-bg-light);
    border: 1px solid var(--acake-border);
    border-radius: 30px;
    cursor: pointer;
    transition: var(--acake-transition);
    font-size: 14px;
    font-weight: 500;
    color: var(--acake-text-muted);
}

.acake-filter-btn:hover {
    background: #fff;
    border-color: var(--acake-primary);
    color: var(--acake-primary);
}

.acake-filter-btn.active {
    background: var(--acake-primary);
    color: #fff;
    border-color: var(--acake-primary);
    box-shadow: 0 4px 10px rgba(102, 126, 234, 0.3);
}

/* Text Input */
.acake-text-input-wrapper {
    max-width: 100%;
    background: var(--acake-bg-light);
    padding: 20px;
    border-radius: var(--acake-radius-md);
    border: 1px solid var(--acake-border);
}

.acake-custom-text-input {
    width: 100%;
    padding: 15px;
    border: 1px solid var(--acake-border);
    border-radius: var(--acake-radius-sm);
    font-size: 16px;
    resize: vertical;
    transition: var(--acake-transition);
    background: #fff;
    color: var(--acake-text-main);
    font-family: inherit;
    box-sizing: border-box;
}

.acake-custom-text-input:focus {
    outline: none;
    border-color: var(--acake-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.acake-char-counter {
    text-align: right;
    margin-top: 10px;
    color: var(--acake-text-muted);
    font-size: 13px;
    font-weight: 500;
}

/* Steps Footer */
.acake-steps-footer {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    padding: 25px 40px;
    background: var(--acake-white);
    border-top: 1px solid var(--acake-border);
    z-index: 10;
}

.acake-steps-footer .button {
    padding: 12px 25px !important;
    font-size: 15px !important;
    height: auto !important;
    line-height: 1.5 !important;
    border-radius: var(--acake-radius-sm) !important;
    font-weight: 600 !important;
    transition: var(--acake-transition) !important;
}

.acake-btn-next, .acake-btn-confirm {
    background: var(--acake-primary) !important;
    border-color: var(--acake-primary) !important;
    color: #fff !important;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.acake-btn-next:hover, .acake-btn-confirm:hover {
    background: var(--acake-primary-dark) !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(102, 126, 234, 0.4);
}

.acake-btn-prev {
    margin-right: auto;
    background: transparent !important;
    color: var(--acake-text-muted) !important;
    border: 1px solid var(--acake-border) !important;
}

.acake-btn-prev:hover {
    background: var(--acake-bg-light) !important;
    color: var(--acake-text-main) !important;
}

/* Loading State in panels */
.acake-loading {
    text-align: center;
    padding: 60px;
    color: var(--acake-text-muted);
    font-size: 16px;
    background: var(--acake-bg-light);
    border-radius: var(--acake-radius-md);
    grid-column: 1 / -1; /* Span full width in grid */
}

/* ================================
   RTL Support for Arabic
   ================================ */

[dir="rtl"] .acake-modal-content,
body.rtl .acake-modal-content {
    direction: rtl;
    text-align: right;
}

[dir="rtl"] .acake-customizer-container,
body.rtl .acake-customizer-container {
    direction: rtl;
}

[dir="rtl"] .acake-step-btn,
body.rtl .acake-step-btn {
    flex-direction: column; /* Keep vertical alignment */
}

[dir="rtl"] .acake-steps-footer,
body.rtl .acake-steps-footer {
    flex-direction: row-reverse;
}

[dir="rtl"] .acake-btn-prev,
body.rtl .acake-btn-prev {
    margin-right: 0;
    margin-left: auto;
}

[dir="rtl"] .acake-options-grid,
body.rtl .acake-options-grid {
    text-align: right;
}

[dir="rtl"] .acake-option-card,
body.rtl .acake-option-card {
    text-align: center;
}

[dir="rtl"] .acake-modal-close,
body.rtl .acake-modal-close {
    right: auto;
    left: 20px;
}

[dir="rtl"] .acake-preview-section,
body.rtl .acake-preview-section {
    border-right: none;
    border-left: 1px solid var(--acake-border);
}

[dir="rtl"] .acake-option-card.selected::before,
body.rtl .acake-option-card.selected::before {
    right: auto;
    left: 10px;
}

[dir="rtl"] .acake-customizer-container,
[dir="rtl"] .acake-step-panel,
[dir="rtl"] .acake-option-card,
body.rtl .acake-customizer-container,
body.rtl .acake-step-panel,
body.rtl .acake-option-card {
    font-family: 'Tajawal', 'Cairo', 'Droid Arabic Kufi', 'Noto Sans Arabic', -apple-system, sans-serif;
}

[dir="rtl"] .acake-step-description,
[dir="rtl"] .acake-option-description,
body.rtl .acake-step-description,
body.rtl .acake-option-description {
    text-align: right; /* Better readability for descriptions */
}

/* Responsive */
@media screen and (max-width: 1024px) {
    .acake-modal-content {
        width: 100%;
        height: 100%;
        margin: 0;
        border-radius: 0;
        max-height: 100vh;
    }
    
    .acake-customizer-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        height: 100%;
        overflow: hidden;
    }
    
    .acake-preview-section {
        border-right: none;
        border-bottom: 1px solid var(--acake-border);
        padding: 15px;
        flex-direction: row;
        align-items: center;
        gap: 20px;
        height: auto;
        flex: 0 0 auto;
    }
    
    .acake-preview-section h2 {
        display: none;
    }
    
    .acake-preview-wrapper {
        margin-bottom: 0;
        padding: 10px;
        width: 120px;
        height: 120px;
        flex: 0 0 120px;
    }

    #acake-preview-canvas {
        max-width: 100%;
    }
    
    .acake-price-display {
        padding: 10px 20px;
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: space-between;
        text-align: left;
    }
    
    [dir="rtl"] .acake-price-display {
        text-align: right;
    }
    
    .acake-price-label {
        margin-bottom: 0;
        display: inline-block;
        margin-left: 10px;
    }
    
    .acake-price-value {
        display: inline-block;
        font-size: 24px;
    }
    
    .acake-steps-section {
        overflow: hidden;
        display: flex;
        flex-direction: column;
        height: 100%;
    }
    
    .acake-steps-content {
        overflow-y: auto;
    }
}

@media screen and (max-width: 768px) {
    .acake-options-grid,
    #acake-shapes-grid {
        grid-template-columns: repeat(2, 1fr); /* Keep 2 on mobile for readability */
        gap: 12px;
    }
    
    .acake-colors-grid {
        justify-content: center;
    }
    
    .acake-step-btn {
        min-width: 80px;
        padding: 15px 10px;
    }
    
    .step-label {
        font-size: 12px;
        display: none;
    }
    
    .acake-steps-footer {
        padding: 15px 20px;
    }
}
