/* ===== RESET Y CONFIGURACIÓN BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: Arial, sans-serif;
    background: transparent;
}

/* ===== CONTENEDOR 3D ===== */
.full-screen-3d {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    background: #1a1a2e;
}

/* ===== HEADER ===== */
#LogoImg{
  width: 100px;
  height: auto;
}

.div1-header {
    background-color: #008B8B;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 30px;
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
    height: 93px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

#Titulo {
  width: 390px;
  height: auto;
}

.project-name input {
    background: rgba(33, 229, 255, 0.8);
    border: 2px rgba(33, 229, 255, 0.8);
    color: #333;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 1rem;
    width: 250px;
    text-align: center;
    transition: all 0.3s ease;
}

.project-name input:focus {
    outline: none;
    border-color: #4ecdc4;
    background: white;
    box-shadow: 0 0 10px rgba(78, 205, 196, 0.3);
}

/* ===== PANEL IZQUIERDO ===== */
.div2-left {
    position: fixed;
    top: 84px; /* Justo debajo del header */
    left: 0;
    width: 280px;
    height: calc(100vh - 70px);
    background: #02b6b6;
    padding: 20px;
    box-sizing: border-box;
    border-right: 2px solid #e0e0e0;
    z-index: 900; /* Menor que el header pero mayor que el 3D */
    transition: all 0.3s ease-in-out;
    overflow-y: auto;
}

/* ===== PANEL DERECHO ===== */
.div3-right {
    position: fixed;
    top: 84px; /* Justo debajo del header */
    right: 0;
    width: 320px;
    height: calc(100vh - 70px);
    background: #02b6b6;
    padding: 20px;
    box-sizing: border-box;
    border-left: 2px solid #e0e0e0;
    z-index: 900; /* Menor que el header pero mayor que el 3D */
    transition: all 0.3s ease-in-out;
    overflow-y: auto;
}

/* ===== BOTONES DE COLAPSAR ===== */
.collapse-btn-left, .collapse-btn-right {
    position: absolute;
    top: 15px;
    background: rgba(255, 255, 255, 0.8);
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    color: #2c3e50;
    transition: all 0.3s ease;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 950;
}

.collapse-btn-left {
    left: 10px;
}

.collapse-btn-right {
    right: 10px;
}

.collapse-btn-left:hover, .collapse-btn-right:hover {
    background: #ff6b6b;
    color: white;
    border-color: #ff6b6b;
    transform: scale(1.1);
}

/* ===== TÍTULOS ===== */
.div2-left h3, .div3-right h3 {
    color: white;
    text-align: center;
    font-size: 1.3rem;
    font-weight: 600;
    padding: 8px 0;
    margin: 0 0 25px 0;
}

.div2-left h3 {
    margin-left: 40px;
}

.div3-right h3 {
    margin-right: 40px;
}

/* ===== CONTENEDORES DE BOTONES ===== */
.model-buttons, .tool-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ===== BOTONES PRINCIPALES ===== */
.model-btn, .tool-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    transition: all 0.3s ease;
    width: 100%;
}

.model-btn:hover, .tool-btn:hover {
    background: rgba(255, 255, 255, 1);
    border-color: #02b6b6;
    transform: translateY(-2px);
}

.model-btn.active, .tool-btn.active {
    background: rgba(33, 229, 255, 0.9);
    color: white;
    border-color: rgba(33, 229, 255, 0.8);
}

/* ===== ICONOS ===== */
.btn-icon, .tool-icon {
    font-size: 20px;
    line-height: 1;
    width: 24px;
    text-align: center;
    color: #02b6b6;
}

.model-btn.active .btn-icon,
.tool-btn.active .tool-icon {
    color: white;
}

/* ===== TEXTO DE BOTONES ===== */
.btn-text, .tool-btn span:last-child {
    font-weight: 500;
    color: #2c3e50;
}

.model-btn.active .btn-text,
.tool-btn.active span:last-child {
    color: white;
}

/* ===== SUBPANELES ===== */
.subpanel {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    padding: 15px;
    margin-top: 8px;
    border: 2px solid #e0e0e0;
    display: none;
}

.tool-btn.active + .subpanel {
    display: block;
}

/* Títulos de subpaneles */
.subpanel h4 {
    color: #2c3e50;
    margin: 0 0 15px 0;
    font-size: 1.1rem;
    font-weight: 600;
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
}

.subpanel h5 {
    color: #2c3e50;
    margin: 15px 0 10px 0;
    font-size: 1rem;
    font-weight: 600;
}

/* ===== PANEL DE TAMAÑO ===== */
.size-controls {
   display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 15px;
}   

.size-input-group {
   display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 5px 0;
}

.size-input-group label {
    font-weight: 600;
    color: #2c3e50;
    font-size: 0.9rem;
    min-width: 120px;
    text-align: left;
}

.size-input {
     width: 70px;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    text-align: center;
    background: white;
    font-size: 0.9rem;
}

.size-unit {
     color: #666;
    font-size: 0.85rem;
    min-width: 15px;
    text-align: left;
}

.size-presets {
   margin: 15px 0;
}

.size-presets h5 {
    color: #2c3e50;
    margin: 0 0 10px 0;
    font-size: 0.95rem;
    font-weight: 600;
}

.preset-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.preset-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 8px 6px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.3s ease;
}

.preset-btn:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

.size-actions {
   display: flex;
    gap: 12px;
    margin-top: 15px;
}

.apply-size-btn, .reset-size-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.apply-size-btn {
    background: #28a745;
    color: white;
}

.apply-size-btn:hover {
    background: #218838;
}

.reset-size-btn {
    background: #6c757d;
    color: white;
}

.reset-size-btn:hover {
    background: #5a6268;
}

/* ===== PANEL DE TEXTURAS ===== */
.texture-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.texture-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 8px;
    border: 2px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
}

.texture-option:hover {
    border-color: #02b6b6;
    transform: translateY(-2px);
}

.texture-preview {
    width: 40px;
    height: 40px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

/* Colores de texturas */
.texture-preview.mate { background: linear-gradient(45deg, #a0a0a0, #c0c0c0); }
.texture-preview.brillante { background: linear-gradient(45deg, #f0f0f0, #ffffff); }
.texture-preview.metalizado { background: linear-gradient(45deg, #cccccc, #eeeeee, #cccccc); }
.texture-preview.blanco { background: white; }
.texture-preview.carton { background: #d2b48c; }
.texture-preview.madera { background: #8B4513; }

.texture-option span {
    font-size: 0.8rem;
    color: #2c3e50;
    text-align: center;
}

/* ===== PANEL DE COLORES ===== */
.color-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: 10px 0;
}

.color-option {
    width: 40px;
    height: 40px;
    border: 2px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.color-option:hover {
    transform: scale(1.1);
    border-color: #02b6b6;
}

.custom-color-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 15px;
}

.custom-color-container label {
    font-weight: 500;
    color: #2c3e50;
    font-size: 0.9rem;
}

.custom-color-picker {
    width: 50px;
    height: 40px;
    border: 2px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
}

/* ===== PANEL DE MEDIDAS ===== */
.measure-panel p {
    color: #666;
    font-style: italic;
    text-align: center;
    margin: 0;
}

/* ===== ESTADOS COLAPSADOS ===== */
.div2-left.panel-collapsed {
    width: 70px;
    padding: 15px 8px;
}

.div3-right.panel-collapsed {
    width: 70px;
    padding: 15px 8px;
}

.div2-left.panel-collapsed h3,
.div3-right.panel-collapsed h3,
.div2-left.panel-collapsed .btn-text,
.div3-right.panel-collapsed .tool-btn span:last-child {
    display: none;
}

.div2-left.panel-collapsed .model-btn,
.div3-right.panel-collapsed .tool-btn {
    padding: 10px;
    justify-content: center;
    gap: 0;
}

.div2-left.panel-collapsed .model-buttons,
.div3-right.panel-collapsed .tool-buttons {
    gap: 8px;
}

.div2-left.panel-collapsed .btn-icon,
.div3-right.panel-collapsed .tool-icon {
    font-size: 22px;
    width: auto;
    margin: 0;
}

.div2-left.panel-collapsed .collapse-btn-left,
.div3-right.panel-collapsed .collapse-btn-right {
    position: relative;
    top: 0;
    margin: 0 auto 20px auto;
    display: block;
}

.div2-left.panel-collapsed .collapse-btn-left {
    margin-left: 0;
    margin-right: auto;
}

.div3-right.panel-collapsed .collapse-btn-right {
    margin-left: auto;
    margin-right: 0;
}

/* Ocultar subpaneles cuando el panel está colapsado */
.div2-left.panel-collapsed .subpanel,
.div3-right.panel-collapsed .subpanel {
    display: none !important;
}

/* ===== PANEL DE POSICIÓN (AL FRENTE DE TODO) ===== */
.axis-info {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 12px 15px;
    border-radius: 12px;
    z-index: 2000; /* MAYOR que todo */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(5px);
    min-width: 260px;
    max-width: 260px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    cursor: move;
    user-select: none;
    transition: box-shadow 0.3s ease;
}

/* Efecto cuando se está arrastrando */
.axis-info.dragging {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.7);
    border-color: rgba(33, 229, 255, 0.5);
}

/* Área de agarre para arrastrar */
.axis-info h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 15px;
    text-align: center;
    color: #ffffff;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 6px;
    font-weight: 600;
    cursor: move;
    position: relative;
}

/* Indicador visual de que es arrastrable */
.axis-info h3::after {
    content: "⤮";
    position: absolute;
    right: 5px;
    font-size: 14px;
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

.axis-info:hover h3::after {
    opacity: 1;
}

.axis-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 5px;
}

.axis-row span {
    font-size: 13px;
    font-weight: bold;
    padding: 6px 8px;
    border-radius: 6px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    justify-content: center;
    min-width: 0;
}

/* Colores vibrantes y saturados para cada coordenada */
.x-axis {
    color: #FF4444 !important;
    background-color: rgba(255, 68, 68, 0.15);
    border: 1px solid rgba(255, 68, 68, 0.3);
}

.y-axis {
    color: #44FF44 !important;
    background-color: rgba(68, 255, 68, 0.15);
    border: 1px solid rgba(68, 255, 68, 0.3);
}

.z-axis {
    color: #4488FF !important;
    background-color: rgba(68, 136, 255, 0.15);
    border: 1px solid rgba(68, 136, 255, 0.3);
}

/* Responsive para pantallas más pequeñas */
@media (max-width: 768px) {
    .axis-info {
        bottom: 10px;
        right: 10px;
        padding: 10px 12px;
        min-width: 240px;
        max-width: 240px;
    }
    
    .axis-info h3 {
        font-size: 14px;
    }
    
    .axis-row span {
        font-size: 12px;
        padding: 5px 6px;
    }
}

/* ===== PANEL DE EXPORTACIÓN ===== */
.export-panel {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    padding: 15px;
    margin-top: 8px;
    border: 2px solid #e0e0e0;
    display: none;
}

.export-panel h4 {
    color: #2c3e50;
    margin: 0 0 15px 0;
    font-size: 1.1rem;
    font-weight: 600;
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
}

.export-panel h5 {
    color: #2c3e50;
    margin: 15px 0 10px 0;
    font-size: 1rem;
    font-weight: 600;
}

.export-format-buttons {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin: 15px 0;
}

.export-format-btn {
    background: #17a2b8;
    color: white;
    border: none;
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.export-format-btn:hover {
    background: #138496;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.export-format-btn:active {
    transform: translateY(0);
}

/* Iconos específicos para formatos de exportación */
.export-format-btn::before {
    font-size: 16px;
}

.export-format-btn[data-format="obj"]::before {
    content: "📦";
}

.export-format-btn[data-format="json"]::before {
    content: "📄";
}

.export-format-btn[data-format="glb"]::before {
    content: "🎯";
}

.export-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.export-confirm-btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    background: #28a745;
    color: white;
}

.export-confirm-btn:hover {
    background: #218838;
    transform: translateY(-1px);
}

.export-cancel-btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    background: #6c757d;
    color: white;
}

.export-cancel-btn:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

/* ===== BOTÓN DE MEDIDAS ===== */
.tool-btn[data-tool="measures"] {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    transition: all 0.3s ease;
    width: 100%;
    text-decoration: none;
    color: #2c3e50;
    font-weight: 500;
    font-family: inherit;
}

.tool-btn[data-tool="measures"]:hover {
    background: rgba(255, 255, 255, 1);
    border-color: #02b6b6;
    transform: translateY(-2px);
    text-decoration: none;
    color: #2c3e50;
}

.tool-btn[data-tool="measures"].active {
    background: rgba(33, 229, 255, 0.9);
    color: white;
    border-color: rgba(33, 229, 255, 0.8);
    text-decoration: none;
}

.tool-btn[data-tool="measures"] .tool-icon {
    font-size: 20px;
    line-height: 1;
    width: 24px;
    text-align: center;
    color: #02b6b6;
}

.tool-btn[data-tool="measures"].active .tool-icon {
    color: white;
}

.div3-right .tool-btn[data-tool="measures"] {
    box-sizing: border-box;
}

.div3-right.panel-collapsed .tool-btn[data-tool="measures"] {
    padding: 10px;
    justify-content: center;
    gap: 0;
}

.div3-right.panel-collapsed .tool-btn[data-tool="measures"] span:last-child {
    display: none;
}

.div3-right.panel-collapsed .tool-btn[data-tool="measures"] .tool-icon {
    font-size: 22px;
    width: auto;
    margin: 0;
}

/* ===== CORRECCIONES PARA THREE.JS ===== */
/* Asegurar que el canvas de Three.js esté detrás de todo */
#container3d canvas {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    z-index: 1 !important;
}

/* Contenedor de UI overlay */
.ui-overlay {
    position: relative;
    z-index: 10;
    pointer-events: none;
    width: 100%;
    height: 100vh;
}

/* Elementos interactivos deben tener pointer-events */
.div1-header, 
.div2-left,
.div3-right,
.axis-info,
button,
input,
a,
.model-btn,
.tool-btn,
.texture-option,
.color-option {
    pointer-events: auto;
}

/* Header siempre al frente */
.div1-header {
    z-index: 1000;
}

/* Paneles laterales */
.div2-left, .div3-right {
    z-index: 900;
}

/* Panel de posición SIEMPRE al frente */
.axis-info {
    z-index: 2000;
}

/* ===== CONTROLES DE ZOOM MODIFICADOS ===== */
.zoom-controls {
    position: fixed;
    bottom: 20px;
    right: 700px;
    display: flex;
    flex-direction: row; /* Cambiado de column a row */     
    gap: 10px;
    z-index: 900;
    transform: translateX(50%); /* Centrar horizontalmente */
}

.zoom-btn {
    width: 50px;
    height: 50px;
    background: rgba(2, 182, 182, 0.9);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    color: white;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
}

.zoom-btn:hover {
    background: rgba(33, 229, 255, 0.9);
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.zoom-btn:active {
    transform: scale(0.95);
}

#resetView {
    background: rgba(255, 107, 107, 0.9);
}

#resetView:hover {
    background: rgba(255, 107, 107, 1);
}

/* Mensajes de estado para carga de modelos */
.model-loading-message,
.model-error-message,
.model-confirmation-message,
.model-selection-message {
    position: fixed;
    top: 120px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    border-radius: 8px;
    z-index: 10000;
    font-weight: bold;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    text-align: center;
    max-width: 80%;
    backdrop-filter: blur(10px);
}

.model-loading-message {
    background: #ffc107;
    color: black;
    border: 2px solid #ff9800;
}

.model-error-message {
    background: #dc3545;
    color: white;
    border: 2px solid #c82333;
}

.model-confirmation-message {
    background: #28a745;
    color: white;
    border: 2px solid #218838;
}

.model-selection-message {
    background: #17a2b8;
    color: white;
    border: 2px solid #138496;
}

/* Preview de texturas actualizadas */
.texture-preview.mate { 
    background: #888888;
    border: 2px solid #666666;
}

.texture-preview.brillante { 
    background: white;
    border: 2px solid #cccccc;
    box-shadow: 0 0 10px rgba(255,255,255,0.8);
}

.texture-preview.metalizado { 
    background: #cccccc;
    border: 2px solid #999999;
    box-shadow: 0 0 8px rgba(200,200,200,0.6);
}

.texture-preview.blanco { 
    background: white;
    border: 2px solid #dddddd;
}

.texture-preview.carton { 
    background: #d2b48c;
    border: 2px solid #b89464;
}

.texture-preview.madera { 
    background: #8B4513;
    border: 2px solid #5D2906;
}

/* Mensaje inicial de bienvenida */
#initialMessage {
    animation: fadeIn 0.8s ease-out;
    pointer-events: none; /* No interferir con clicks */
}

@keyframes fadeIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* Asegurar que el mensaje esté sobre todo */
#initialMessage div {
    pointer-events: auto;
}

/* En style.css - agrega esto */
.apply-color-btn {
    margin-top: 10px;
    padding: 10px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    width: 100%;
    transition: all 0.3s ease;
}

.apply-color-btn:hover {
    background: #218838;
    transform: translateY(-2px);
}

.color-option {
    transition: all 0.3s ease;
    position: relative;
}

.color-option:hover::after {
    content: "↑";
    position: absolute;
    top: -5px;
    right: -5px;
    background: white;
    border-radius: 50%;
    width: 15px;
    height: 15px;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.apply-color-btn {
    margin-top: 10px;
    padding: 10px;
    background: linear-gradient(45deg, #28a745, #20c997);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    width: 100%;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(40, 167, 69, 0.3);
}

.apply-color-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.4);
}