/* =============================================
   3D Flipbook WooCommerce - Public Styles
   ============================================= */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;700&family=DM+Sans:wght@400;500;600&display=swap');

:root {
    --fb-pub-primary: #5046e4;
    --fb-pub-gold: #c9a84c;
    --fb-pub-dark: #0d0d1a;
    --fb-pub-surface: rgba(255,255,255,0.05);
    --fb-pub-border: rgba(255,255,255,0.12);
    --fb-pub-pin: #5046e4;
    --fb-pub-pin-hover: #6c63ff;
    --fb-pub-success: #22c55e;
    --fb-pub-radius: 12px;
}

/* ===========================
   Container
   =========================== */
.flipbook-woo-container {
    position: relative;
    font-family: 'DM Sans', sans-serif;
    -webkit-font-smoothing: antialiased;
    background: linear-gradient(135deg, #0d0d1a 0%, #1a1040 50%, #0d0d1a 100%);
    border-radius: 16px;
    overflow: hidden;
    padding: 30px 20px 20px;
    min-height: 200px;
}

.flipbook-woo-container[data-theme="light"] {
    background: linear-gradient(135deg, #f0f4ff 0%, #e8edff 50%, #f0f4ff 100%);
}

.flipbook-woo-container[data-theme="warm"] {
    background: linear-gradient(135deg, #1a0e00 0%, #2d1a05 50%, #1a0e00 100%);
}

/* ===========================
   Loader
   =========================== */
.flipbook-loader {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: inherit;
    z-index: 50;
    transition: opacity 0.4s;
}
.flipbook-loader.hidden { opacity: 0; pointer-events: none; }

.flipbook-loader-inner {
    text-align: center;
    color: rgba(255,255,255,0.7);
}
.flipbook-loader-inner p {
    margin-top: 16px;
    font-size: 0.875rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.flipbook-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: var(--fb-pub-primary);
    border-radius: 50%;
    animation: fbSpin 0.8s linear infinite;
    margin: 0 auto;
}

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

/* ===========================
   Stage
   =========================== */
.flipbook-stage {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 2000px;
}

/* ===========================
   3D Book wrapper
   =========================== */
.flipbook-3d-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    filter: drop-shadow(0 40px 60px rgba(0,0,0,0.6));
}

.flipbook-book {
    position: relative;
}

/* Turn.js overrides for 3D effect */
.flipbook-book .page {
    overflow: hidden;
    backface-visibility: hidden;
}

.flipbook-book .page img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

/* Hard shadow for depth illusion */
.flipbook-3d-wrapper .turn-page-wrapper {
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

/* ===========================
   Product Pins
   =========================== */
.flipbook-pin-container {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 20;
}

.fb-product-pin {
    position: absolute;
    transform: translate(-50%, -100%);
    pointer-events: auto;
    cursor: pointer;
    z-index: 25;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.fb-product-pin:hover { transform: translate(-50%, -110%) scale(1.15); z-index: 30; }

.fb-pin-marker {
    width: 36px;
    height: 36px;
    background: var(--fb-pub-pin);
    border: 3px solid #fff;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    box-shadow: 0 4px 16px rgba(80,70,228,0.6), 0 0 0 4px rgba(80,70,228,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, box-shadow 0.2s;
    animation: pinPulse 2.5s ease-in-out infinite;
}

.fb-product-pin:hover .fb-pin-marker {
    background: var(--fb-pub-pin-hover);
    box-shadow: 0 6px 24px rgba(108,99,255,0.8), 0 0 0 6px rgba(108,99,255,0.25);
    animation: none;
}

.fb-pin-icon {
    transform: rotate(45deg);
    font-size: 0.9rem;
    line-height: 1;
}

@keyframes pinPulse {
    0%, 100% { box-shadow: 0 4px 16px rgba(80,70,228,0.6), 0 0 0 4px rgba(80,70,228,0.2); }
    50% { box-shadow: 0 4px 16px rgba(80,70,228,0.8), 0 0 0 8px rgba(80,70,228,0.1); }
}

/* Pin quick tooltip */
.fb-pin-tooltip {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    background: #fff;
    color: #111;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    transform: translateX(-50%) translateY(4px) rotate(45deg);
}
.fb-product-pin:hover .fb-pin-tooltip {
    opacity: 1;
    transform: translateX(-50%) translateY(0) rotate(45deg);
}

/* ===========================
   Product Modal
   =========================== */
.flipbook-product-overlay {
    position: absolute;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.flipbook-overlay-bg {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: fbFadeIn 0.2s ease;
}

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

.flipbook-product-modal {
    position: relative;
    z-index: 101;
    background: #ffffff;
    border-radius: 16px;
    width: 90%;
    max-width: 460px;
    max-height: 85%;
    overflow-y: auto;
    box-shadow: 0 25px 80px rgba(0,0,0,0.5);
    animation: fbSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes fbSlideUp {
    from { opacity: 0; transform: translateY(30px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0)    scale(1); }
}

.flipbook-modal-close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: #f3f4f6;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    z-index: 10;
    transition: background 0.15s;
}
.flipbook-modal-close:hover { background: #e5e7eb; }

.flipbook-product-modal-content { padding: 24px; }

/* Product image gallery */
.fb-modal-gallery {
    margin-bottom: 16px;
    border-radius: 10px;
    overflow: hidden;
    aspect-ratio: 4/3;
    background: #f3f4f6;
}
.fb-modal-gallery img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.fb-modal-product-name {
    font-family: 'Playfair Display', serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: #111;
    margin: 0 0 4px;
    line-height: 1.3;
}

.fb-modal-product-sku {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-bottom: 8px;
}

.fb-modal-product-price {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--fb-pub-primary);
    margin-bottom: 10px;
}
.fb-modal-product-price del { color: #9ca3af; font-size: 1rem; margin-right: 6px; }

.fb-modal-product-desc {
    font-size: 0.875rem;
    color: #6b7280;
    line-height: 1.6;
    margin-bottom: 16px;
    border-bottom: 1px solid #f3f4f6;
    padding-bottom: 14px;
}

.fb-stock-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 999px;
    margin-bottom: 14px;
}
.fb-stock-in { background: #dcfce7; color: #15803d; }
.fb-stock-out { background: #fee2e2; color: #b91c1c; }

/* Variations */
.fb-variations { margin-bottom: 14px; }
.fb-variation-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #374151;
    display: block;
    margin-bottom: 6px;
}
.fb-variation-options { display: flex; flex-wrap: wrap; gap: 6px; }
.fb-variation-opt {
    padding: 5px 12px;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    background: #fff;
    transition: all 0.15s;
}
.fb-variation-opt:hover { border-color: var(--fb-pub-primary); color: var(--fb-pub-primary); }
.fb-variation-opt.selected { border-color: var(--fb-pub-primary); background: var(--fb-pub-primary); color: #fff; }

/* Qty + Add */
.fb-modal-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.fb-qty-control {
    display: flex;
    align-items: center;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
}
.fb-qty-btn {
    background: #f9fafb;
    border: none;
    padding: 0 14px;
    height: 44px;
    font-size: 1.1rem;
    cursor: pointer;
    color: #374151;
    transition: background 0.15s;
}
.fb-qty-btn:hover { background: #e5e7eb; }
.fb-qty-val {
    width: 40px;
    text-align: center;
    font-weight: 700;
    font-size: 0.95rem;
    border: none;
    outline: none;
    background: #fff;
    color: #111;
}

.fb-add-to-cart-btn {
    flex: 1;
    background: var(--fb-pub-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    height: 44px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.fb-add-to-cart-btn:hover:not(:disabled) { background: #3d35c8; transform: translateY(-1px); box-shadow: 0 4px 16px rgba(80,70,228,0.4); }
.fb-add-to-cart-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.fb-add-to-cart-btn.loading .btn-text { display: none; }
.fb-add-to-cart-btn.loading::after {
    content: '';
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: fbSpin 0.6s linear infinite;
}
.fb-add-to-cart-btn.success { background: var(--fb-pub-success); }

.fb-view-product-link {
    display: block;
    text-align: center;
    font-size: 0.8rem;
    color: #9ca3af;
    text-decoration: none;
    margin-top: 10px;
}
.fb-view-product-link:hover { color: var(--fb-pub-primary); text-decoration: underline; }

/* ===========================
   Toast Notification
   =========================== */
.flipbook-toast {
    position: absolute;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #1f2937;
    color: #fff;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 200;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    white-space: nowrap;
}
.flipbook-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.flipbook-toast-icon {
    background: var(--fb-pub-success);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    flex-shrink: 0;
}

.flipbook-toast-cart-link {
    color: var(--fb-pub-pin-hover);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.8rem;
}
.flipbook-toast-cart-link:hover { text-decoration: underline; }

/* ===========================
   Controls
   =========================== */
.flipbook-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 16px;
    padding: 10px 20px;
}

.flipbook-ctrl-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.8);
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.15s;
    font-family: 'DM Sans', sans-serif;
    text-decoration: none;
}
.flipbook-ctrl-btn:hover {
    background: rgba(255,255,255,0.18);
    color: #fff;
    transform: translateY(-1px);
}
[data-theme="light"] .flipbook-ctrl-btn {
    background: rgba(0,0,0,0.08);
    border-color: rgba(0,0,0,0.12);
    color: rgba(0,0,0,0.7);
}
[data-theme="light"] .flipbook-ctrl-btn:hover {
    background: rgba(0,0,0,0.14);
    color: #000;
}

.flipbook-page-indicator {
    color: rgba(255,255,255,0.6);
    font-size: 0.85rem;
    min-width: 90px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
[data-theme="light"] .flipbook-page-indicator { color: rgba(0,0,0,0.5); }

.flipbook-cart-btn { position: relative; }
.flipbook-cart-count {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #ef4444;
    color: #fff;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 0.65rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.flipbook-cart-count:empty, .flipbook-cart-count[data-count="0"] { display: none; }

/* ===========================
   Fullscreen
   =========================== */
.flipbook-woo-container.is-fullscreen {
    position: fixed !important;
    inset: 0 !important;
    z-index: 99999 !important;
    border-radius: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    padding: 20px !important;
    margin: 0 !important;
}
.flipbook-woo-container.is-fullscreen .flipbook-stage {
    height: calc(100vh - 120px) !important;
    width: 100% !important;
}

/* ===========================
   Mobile
   =========================== */
@media (max-width: 768px) {
    .flipbook-woo-container { padding: 16px 10px 14px; }
    .flipbook-controls { gap: 6px; padding: 8px; }
    .flipbook-ctrl-btn { padding: 6px 10px; font-size: 0.78rem; }
    .flipbook-page-indicator { min-width: 60px; font-size: 0.78rem; }
    .flipbook-product-modal { width: 95%; max-width: none; }
    .fb-modal-product-name { font-size: 1.1rem; }
    .fb-modal-product-price { font-size: 1.2rem; }
    .flipbook-toast { font-size: 0.78rem; padding: 10px 14px; }
}

@media (max-width: 480px) {
    .fb-add-to-cart-btn { font-size: 0.8rem; }
    .flipbook-3d-wrapper { padding: 10px; }
}
