/**
 * WC 3D Product Viewer - Frontend Styles
 */

/* Wrapper */
.wc3d-viewer-wrapper {
    margin-bottom: 20px;
}

/* Container */
.wc3d-viewer-container {
    position: relative;
    width: 100%;
    background: linear-gradient(145deg, #f8fafc 0%, #e2e8f0 100%);
    border-radius: 12px;
    overflow: hidden;
    cursor: grab;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.wc3d-viewer-container:active {
    cursor: grabbing;
}

/* Canvas */
.wc3d-canvas {
    width: 100%;
    height: 100%;
}

.wc3d-canvas canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

/* Loading */
.wc3d-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.95);
    z-index: 10;
    transition: opacity 0.3s ease;
}

.wc3d-loading.hidden {
    opacity: 0;
    pointer-events: none;
}

.wc3d-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e2e8f0;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: wc3d-spin 1s linear infinite;
}

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

.wc3d-loading span {
    margin-top: 15px;
    color: #64748b;
    font-size: 14px;
}

/* Hint */
.wc3d-hint {
    position: absolute;
    top: 15px;
    left: 15px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 5;
    transition: opacity 0.3s ease;
}

.wc3d-hint .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.wc3d-viewer-container:active .wc3d-hint {
    opacity: 0;
}

/* Controls */
.wc3d-controls {
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    background: rgba(255, 255, 255, 0.95);
    padding: 10px 15px;
    border-radius: 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    z-index: 5;
}

.wc3d-btn {
    background: #f1f5f9;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
}

.wc3d-btn:hover {
    background: #3b82f6;
    color: white;
}

.wc3d-btn:hover svg {
    stroke: white;
}

.wc3d-btn svg {
    width: 18px;
    height: 18px;
    stroke: #475569;
    transition: stroke 0.2s ease;
}

.wc3d-btn.active {
    background: #3b82f6;
}

.wc3d-btn.active svg {
    stroke: white;
}

/* Thumbnails */
.wc3d-thumbnails {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 15px;
    padding: 0 5px;
}

.wc3d-thumb {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 72px;
    width: auto;
    padding: 0 10px;
    height: 64px;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    color: #64748b;
    font-size: 11px;
    text-align: center;
    white-space: nowrap;
}

.wc3d-thumb:hover {
    border-color: #3b82f6;
    color: #3b82f6;
}

.wc3d-thumb.active {
    border-color: #3b82f6;
    background: #eff6ff;
    color: #1e40af;
}

.wc3d-thumb .dashicons {
    font-size: 24px;
    width: 24px;
    height: 24px;
    margin-bottom: 5px;
}

/* Fullscreen */
.wc3d-viewer-container:fullscreen {
    background: #1e293b;
    border-radius: 0;
}

.wc3d-viewer-container:fullscreen .wc3d-hint {
    top: 20px;
    left: 20px;
}

.wc3d-viewer-container:fullscreen .wc3d-controls {
    bottom: 30px;
}

/* Responsive */
@media (max-width: 600px) {
    .wc3d-controls {
        padding: 8px 12px;
        gap: 5px;
    }
    
    .wc3d-btn {
        width: 35px;
        height: 35px;
    }
    
    .wc3d-btn .dashicons {
        font-size: 18px;
        width: 18px;
        height: 18px;
    }
    
    .wc3d-hint {
        font-size: 12px;
        padding: 6px 12px;
    }
    
    .wc3d-thumb {
        min-width: 60px;
        padding: 0 8px;
        height: 58px;
        font-size: 10px;
    }
}

/* ========================================
   2D/3D View Switcher
   ======================================== */

/* Viste 2D e 3D */
.wc3d-2d-view,
.wc3d-3d-view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.wc3d-2d-view.active,
.wc3d-3d-view.active {
    opacity: 1;
    visibility: visible;
}

/* Vista 2D - Immagine Responsive */
.wc3d-2d-view {
    background: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.wc3d-2d-image-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 20px;
    box-sizing: border-box;
    overflow: auto;
}

.wc3d-2d-image {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.wc3d-2d-view iframe {
    flex: 1;
    border: none;
    background: #f8fafc;
}

.wc3d-2d-download {
    position: absolute;
    bottom: 15px;
    right: 15px;
    z-index: 5;
}

.wc3d-download-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #3b82f6 0%, #1e40af 100%);
    color: white !important;
    text-decoration: none !important;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
    transition: all 0.2s ease;
}

.wc3d-download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.5);
    color: white !important;
}

.wc3d-download-btn .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* Badge 3D Pronto */
.wc3d-ready-badge {
    position: absolute;
    top: 15px;
    right: 15px;
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
    color: white;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.4);
    animation: pulse 2s infinite;
    z-index: 15;
}

.wc3d-ready-badge .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Indicatore caricamento sul pulsante 3D */
.wc3d-loading-indicator {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #f59e0b;
    animation: blink 1s infinite;
}

.wc3d-loading-indicator.ready {
    background: #16a34a;
    animation: none;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Pulsante 3D con stato loaded */
.wc3d-thumb[data-view="3d"] {
    position: relative;
}

.wc3d-thumb[data-view="3d"].loaded {
    border-color: #16a34a;
}

.wc3d-thumb[data-view="3d"].loaded::after {
    content: '✓';
    position: absolute;
    top: -5px;
    right: -5px;
    width: 18px;
    height: 18px;
    background: #16a34a;
    color: white;
    border-radius: 50%;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Vista 3D */
.wc3d-3d-view {
    display: flex;
    flex-direction: column;
}

.wc3d-3d-view .wc3d-canvas {
    flex: 1;
}

/* ── Tab con lucchetto (3D / Scheda Tecnica per utenti non loggati) ── */
.wc3d-thumb--locked {
    opacity: 0.55;
    cursor: not-allowed;
}
.wc3d-thumb--locked:hover {
    border-color: #cbd5e1 !important;
    background: transparent !important;
}

/* ── Login Gate — pannello centrato nella vista 3D ── */
.wc3d-login-gate {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(241, 245, 249, 0.97);
    z-index: 10;
}
.wc3d-login-gate__inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.75rem;
    padding: 2rem 1.5rem;
    max-width: 320px;
}
.wc3d-login-gate__inner > svg {
    color: #64748b;
}
.wc3d-login-gate__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: #0f172a;
}
.wc3d-login-gate__sub {
    margin: 0;
    font-size: 0.85rem;
    color: #64748b;
    line-height: 1.5;
}
.wc3d-login-gate__btn {
    display: inline-block;
    margin-top: 0.25rem;
    padding: 0.55rem 1.4rem;
    background: #0B3D6C;
    color: #fff !important;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.15s;
}
.wc3d-login-gate__btn:hover {
    background: #00919D;
}

/* ── Banner "Registrati" sotto il viewer ── */
.wc3d-register-notice {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin-top: 0.6rem;
    padding: 0.55rem 0.85rem;
    background: #f0f7ff;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    font-size: 0.8rem;
    color: #1e40af;
    line-height: 1.4;
}
.wc3d-register-notice svg {
    flex-shrink: 0;
    color: #3b82f6;
}
.wc3d-register-notice a {
    color: #1d4ed8;
    font-weight: 600;
    text-decoration: underline;
}
.wc3d-register-notice a:hover {
    color: #00919D;
}

/* ══════════════════════════════════════════
   Modal — Richiesta accesso contenuti tecnici
   ══════════════════════════════════════════ */
#wc3d-access-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    align-items: center;
    justify-content: center;
}
#wc3d-access-modal.is-open {
    display: flex;
}
.wc3d-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
}
.wc3d-modal__box {
    position: relative;
    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(11, 61, 108, 0.18);
    padding: 2rem 2rem 1.75rem;
    width: min(480px, calc(100vw - 2rem));
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    z-index: 1;
}
.wc3d-modal__close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 32px;
    height: 32px;
    border: none;
    background: #f1f5f9;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.wc3d-modal__close:hover { background: #e2e8f0; }

.wc3d-modal__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: #eff6ff;
    border-radius: 50%;
    color: #1d4ed8;
    margin-bottom: 0.25rem;
}
.wc3d-modal__title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.3;
}
.wc3d-modal__sub {
    margin: 0;
    font-size: 0.85rem;
    color: #64748b;
    line-height: 1.55;
}

/* Campi form */
.wc3d-modal__field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-top: 0.4rem;
}
.wc3d-modal__field label {
    font-size: 0.82rem;
    font-weight: 600;
    color: #374151;
}
.wc3d-modal__optional {
    font-weight: 400;
    color: #9ca3af;
}
.wc3d-modal__field input {
    height: 42px;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    padding: 0 0.85rem;
    font-size: 0.875rem;
    color: #0f172a;
    background: #f9fafb;
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
    width: 100%;
    box-sizing: border-box;
}
.wc3d-modal__field input:focus {
    border-color: #0B3D6C;
    box-shadow: 0 0 0 3px rgba(11, 61, 108, 0.1);
    background: #fff;
}

/* Messaggio esito */
.wc3d-modal__msg {
    font-size: 0.82rem;
    border-radius: 6px;
    padding: 0;
    min-height: 0;
    transition: all 0.2s;
}
.wc3d-modal__msg.is-success {
    color: #15803d;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    padding: 0.5rem 0.75rem;
}
.wc3d-modal__msg.is-error {
    color: #b91c1c;
    background: #fef2f2;
    border: 1px solid #fecaca;
    padding: 0.5rem 0.75rem;
}

/* Bottone submit */
.wc3d-modal__submit {
    margin-top: 0.5rem;
    height: 44px;
    background: #0B3D6C;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    width: 100%;
    position: relative;
}
.wc3d-modal__submit:hover:not(:disabled) { background: #00919D; }
.wc3d-modal__submit:disabled { opacity: 0.6; cursor: default; }
.wc3d-modal__submit-loading { display: none; }
.wc3d-modal__submit.is-loading .wc3d-modal__submit-text { display: none; }
.wc3d-modal__submit.is-loading .wc3d-modal__submit-loading { display: inline; }

/* Separatore "oppure" + link login */
.wc3d-modal__sep {
    position: relative;
    text-align: center;
    color: #94a3b8;
    font-size: 0.78rem;
    margin: 0.75rem 0 0;
}
.wc3d-modal__sep::before,
.wc3d-modal__sep::after {
    content: '';
    position: absolute;
    top: 50%;
    width: calc(50% - 1.75rem);
    height: 1px;
    background: #e2e8f0;
}
.wc3d-modal__sep::before { left: 0; }
.wc3d-modal__sep::after  { right: 0; }

.wc3d-modal__login-hint {
    margin: 0;
    text-align: center;
    font-size: 0.8125rem;
    color: #64748b;
    line-height: 1.5;
}
.wc3d-modal__login-hint a {
    color: #0b3d6c;
    font-weight: 600;
    text-decoration: none;
}
.wc3d-modal__login-hint a:hover {
    text-decoration: underline;
}
