/* Box 3D Configurator - Frontend Styles */

/* Container principale */
#box-3d-configurator-wrapper {
    margin: 30px 0;
    clear: both;
}

#box-3d-customize-container {
    margin: 18px 0;
    display: flex;
    justify-content: center;
    background: transparent;
    padding: 0;
    border: 0;
}

#box-3d-customize-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 28px;
    border-radius: 10px;
    font-weight: 700;
    text-decoration: none;
    line-height: 1;
    background: var(--box-3d-customize-bg, #d35400);
    border: 2px solid var(--box-3d-customize-bg, #d35400);
    color: var(--box-3d-customize-text, #fff);
    transition: 0.2s;
}

#box-3d-customize-btn:hover {
    background: var(--box-3d-customize-bg-hover, #b45309);
    border-color: var(--box-3d-customize-bg-hover, #b45309);
    color: var(--box-3d-customize-text, #fff);
    transform: translateY(-1px);
}

#box-3d-customize-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(211, 84, 0, 0.25);
}

#box-3d-configurator-panel {
    margin-top: 18px;
}

.box-3d-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    clear: both;
}

#box-3d-quote-message {
    width: 100%;
}

/* Loading */
#box-3d-loading {
    text-align: center;
    padding: 50px;
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 8px;
    margin: 20px 0;
}

#box-3d-loading .spinner {
    display: block;
    margin: 0 auto 15px;
    float: none !important;
}

/* Layout configuratore */
#box-3d-frontend-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin: 30px 0;
    min-height: 600px;
}

/* 3D Viewport */
#box-3d-viewport-frontend {
    border: 1px solid #ddd;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: 500px;
}

#box-3d-viewport-frontend canvas {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
}

/* 2D Editor - STRUTTURA ESATTA DALL'ADMIN */
#box-3d-2d-editor-frontend {
    display: flex;
    flex-direction: column;
    background: #222;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
}

#box-3d-2d-editor-header {
    background: #f9f9f9;
    padding: 10px;
    border-bottom: 1px solid #ddd;
    display: flex;
    align-items: center;
    gap: 10px;
}

.box-3d-tab-btn-frontend {
    flex: 1;
    padding: 12px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-weight: 600;
    color: #666;
    border-bottom: 3px solid transparent;
    transition: 0.2s;
    border-radius: 4px 4px 0 0;
}

.box-3d-tab-btn-frontend:hover {
    color: var(--box-3d-customize-text, #ffffff);
    background: var(--box-3d-customize-bg, #d35400);
}

.box-3d-tab-btn-frontend.active {
    color: var(--box-3d-customize-text, #ffffff);
    border-bottom-color: var(--box-3d-customize-bg-hover, #b45309);
    background: var(--box-3d-customize-bg, #d35400);
}

#box-3d-2d-editor-container {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#box-3d-2d-editor-scroll {
    flex: 1;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
    position: relative;
    background: #fff;
}

#box-3d-canvas-wrapper-frontend {
    width: 100%;
    aspect-ratio: 1 / 1;
    max-width: 700px;
    background-color: #fff;
    border: 1px solid #444;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    position: relative;
}

#box-3d-bg-layer-frontend,
#box-3d-elements-layer-frontend {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    transform-origin: center center;
}

#box-3d-bg-layer-frontend {
    z-index: 1;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    transition: transform 0.1s linear;
}

#box-3d-elements-layer-frontend {
    z-index: 10;
    pointer-events: auto;
}

/* Elementi */
.box-3d-el-frontend {
    position: absolute;
    cursor: grab;
    user-select: none;
    border: 1px dashed transparent;
    display: flex;
    justify-content: center;
    align-items: center;
    transform-origin: center center;
    padding: 0; /* Rimuovo padding fisso - il bordo deve adattarsi al contenuto */
    min-width: 30px;
    min-height: 30px;
    border-radius: 4px;
    box-sizing: border-box; /* Assicura che il bordo sia incluso nelle dimensioni */
}

.box-3d-el-frontend:hover {
    border: 1px dashed rgba(211, 84, 0, 0.8);
    z-index: 20;
    background: rgba(211, 84, 0, 0.1);
    border-radius: 4px;
}

.box-3d-el-frontend.selected {
    border: 2px solid #d35400;
    z-index: 30;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

/* Handles */
.box-3d-resizer-frontend {
    width: 20px;
    height: 20px;
    background: #d35400;
    position: absolute;
    bottom: -10px;
    right: -10px;
    cursor: nwse-resize;
    border-radius: 4px;
    display: none;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 35;
    font-size: 12px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.box-3d-resizer-frontend::before {
    content: '↘';
    font-weight: bold;
}

.box-3d-rotator-frontend {
    width: 24px;
    height: 24px;
    background: #2563eb;
    position: absolute;
    top: -12px;
    right: -12px;
    cursor: alias;
    border-radius: 4px;
    display: none;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 35;
    font-size: 14px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.box-3d-rotator-frontend::before {
    content: '↻';
    font-weight: bold;
}

.box-3d-deleter-frontend {
    width: 24px;
    height: 24px;
    background: #dc2626;
    position: absolute;
    top: -12px;
    left: -12px;
    cursor: pointer;
    border-radius: 4px;
    display: none;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 35;
    font-size: 14px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.box-3d-deleter-frontend::before {
    content: '×';
    font-weight: bold;
    font-size: 16px;
}

.box-3d-deleter-frontend:hover {
    background: #b91c1c;
}

.box-3d-el-frontend.selected .box-3d-resizer-frontend,
.box-3d-el-frontend.selected .box-3d-rotator-frontend,
.box-3d-el-frontend.selected .box-3d-deleter-frontend {
    display: flex;
}

.box-3d-el-frontend img {
    width: 100%;
    height: 100%;
    pointer-events: none;
    object-fit: contain;
    display: block;
}

.box-3d-el-frontend span {
    display: flex;
    width: 100%;
    height: 100%;
    pointer-events: none;
    white-space: nowrap;
    text-align: center;
    line-height: 1;
    text-shadow: 0 0 4px rgba(255,255,255,0.9), 0 0 2px rgba(0,0,0,0.9);
    align-items: center;
    justify-content: center;
    overflow: hidden; /* Il testo viene contenuto nel bordo */
    box-sizing: border-box;
}

/* Assicurati che i handles ricevano gli eventi */
.box-3d-resizer-frontend,
.box-3d-rotator-frontend {
    pointer-events: auto !important;
}

.box-3d-el-frontend.selected {
    pointer-events: auto !important;
}

/* Toolbar */
.box-3d-editor-toolbar-frontend {
    background: #fff;
    padding: 15px;
    border-top: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
}

.box-3d-tools-title-frontend {
    font-weight: 700;
    color: #333;
    font-size: 13px;
}

.box-3d-toolbar-row-frontend {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.box-3d-tools-frontend {
    display: flex;
    gap: 10px;
    flex-wrap: nowrap;
}

.box-3d-tool-btn-frontend {
    padding: 12px 20px;
    background: #fff;
    border: 2px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: 0.2s;
}

.box-3d-tool-btn-frontend:hover {
    border-color: #d35400;
    color: #d35400;
    background: #fff7ed;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(211, 84, 0, 0.1);
}

.box-3d-tool-btn-frontend i {
    font-size: 18px;
}

/* Selection controls */
.box-3d-selection-panel-frontend {
    background: #fafafa;
    padding: 20px;
    border-top: 1px solid #ddd;
    margin-top: 20px;
    border-radius: 0 0 8px 8px;
}

#box-3d-selection-controls-frontend {
    opacity: 0.5;
    pointer-events: none;
    transition: 0.2s;
}

#box-3d-selection-controls-frontend.active {
    opacity: 1;
    pointer-events: auto;
}

/* Nascondi controlli specifici per testo (font, colore, dimensione) quando selezionato immagine */
.box-3d-text-only-frontend.hidden,
#box-3d-text-content-field-frontend.hidden,
.box-3d-text-only-frontend[style*="display: none"],
.box-3d-text-only-frontend[style*="display:none"] {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
}

.box-3d-field-frontend {
    margin-bottom: 15px;
}

.box-3d-field-frontend label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
}

.box-3d-field-frontend input[type="text"],
.box-3d-field-frontend select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

.box-3d-field-frontend input[type="number"] {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    height: 42px;
    line-height: normal;
}

.box-3d-field-frontend input[type="color"] {
    width: 60px;
    height: 40px;
    padding: 0;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
}

.box-3d-btn-delete-frontend {
    width: 100%;
    padding: 12px;
    background: #dc2626;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: 0.2s;
}

.box-3d-btn-delete-frontend:hover {
    background: #b91c1c;
    box-shadow: 0 2px 4px rgba(220, 38, 38, 0.2);
}

/* Zoom controls */
.box-3d-zoom-group-frontend {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    padding: 8px 16px;
    border: 1px solid #ddd;
    border-radius: 20px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* Responsive */
@media (max-width: 1024px) {
    #box-3d-frontend-wrapper {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
    }
    
    #box-3d-viewport-frontend {
        order: 1;
    }
    
    #box-3d-2d-editor-frontend {
        order: 2;
    }
}

@media (max-width: 768px) {
    #box-3d-configurator-wrapper {
        margin: 15px 0;
    }
    
    #box-3d-frontend-wrapper {
        gap: 15px;
    }
    
    #box-3d-2d-editor-header {
        padding: 10px;
    }
    
    .box-3d-tool-btn-frontend {
        padding: 10px 15px;
        font-size: 13px;
    }
}
