/* ==============================================================
   Tecshop Custom Builder - Estilos de Alta Fidelidad
   ============================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

.tecshop-builder-container {
    display: flex;
    gap: 24px;
    width: 100%;
    max-width: 100%;
    padding: 0;
    box-sizing: border-box;
    margin: 0;
    font-family: 'Inter', sans-serif;
    color: #1a1a1a;
    align-items: stretch;
}

/* --- Columnas --- */
.ts-col {
    background: #ffffff;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
    border: none;
}

.ts-sidebar-left { width: 300px; flex-shrink: 0; }
.ts-sidebar-right { width: 340px; flex-shrink: 0; }

.ts-canvas-area { 
    flex-grow: 1; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    background: #fdfdfd;
    position: relative;
}

/* --- Tipografía y Títulos --- */
.ts-step-title {
    font-size: 16px;
    font-weight: 600;
    color: #174ea6; /* Azul Tecshop */
    margin-top: 0;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
}

.ts-divider { border: 0; border-top: 1px solid #f0f0f0; margin: 24px 0; }

/* --- Formularios y Controles --- */
.ts-form-group { margin-bottom: 16px; }
.ts-form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #333;
    margin-bottom: 8px;
}
.ts-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #dcdcdc;
    border-radius: 8px;
    font-size: 14px;
    color: #333;
    background-color: #fff;
    box-sizing: border-box;
    margin-bottom: 14px;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}
.ts-input:focus {
    outline: none;
    border-color: #174ea6;
    box-shadow: 0 0 0 3px rgba(23, 78, 166, 0.1);
}
.ts-input:disabled { background-color: #f7f7f7; color: #999; }

/* --- Botones --- */
.ts-btn-primary {
    background-color: #174ea6;
    color: #ffffff;
    border: none;
    padding: 14px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.ts-btn-primary:hover { background-color: #103b82; }
.ts-btn-primary:disabled { background-color: #a0b8da; cursor: not-allowed; }
.ts-btn-block { width: 100%; display: block; }
.ts-btn-text {
    background: none;
    border: none;
    color: #555;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    padding: 8px;
}
.ts-btn-text:hover { color: #174ea6; }

/* --- Herramientas de Edición (Grid) --- */
.ts-tools-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-top: 15px;
}
.ts-tool-btn {
    background: #ffffff;
    border: 1px solid #dcdcdc;
    border-radius: 8px;
    padding: 12px 0;
    text-align: center;
    font-size: 11px;
    font-weight: 500;
    color: #444;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.ts-tool-btn:hover { background: #f4f6fb; border-color: #174ea6; color: #174ea6; }
.ts-tool-btn .ts-icon { font-size: 18px; }

/* --- Canvas y Overlay --- */
.ts-canvas-header {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 20px;
}
.ts-canvas-wrapper {
    position: relative;
    width: 320px;
    height: 640px;
    background-color: #f1f1f1;
    border-radius: 40px; /* Bordes suaves estilo iPhone */
    overflow: hidden;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.05);
    margin: 0 auto;
}
.ts-phone-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none; /* Ignora clics, deja interactuar con el canvas abajo */
    z-index: 10;
    background-size: 100% 100%; /* Estira la imagen para cubrir exactamente el marco */
    background-position: center;
    background-repeat: no-repeat; /* Evita que se repita el celular múltipes veces */
}
.ts-zoom-tools {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.ts-zoom-tools .ts-tool-btn { width: 40px; height: 40px; padding: 0; font-size: 18px; justify-content: center; }

/* --- Derecha: Resumen --- */
.ts-summary-box { margin-bottom: 24px; font-size: 14px; }
.ts-summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    color: #444;
}
.ts-summary-row .ts-label { color: #888; }
.ts-price {
    font-size: 22px;
    color: #174ea6;
    font-weight: 700;
    text-align: right;
    margin: 15px 0 0 0;
}

.ts-design-previews {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
}
.ts-preview-box {
    flex: 1;
    height: 90px;
    border: 1px dashed #ccc;
    border-radius: 8px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 8px;
    font-size: 11px;
    color: #888;
    background: #fafafa;
}

/* --- Checkbox Switch Toggle --- */
.ts-switch { position: relative; display: inline-block; width: 40px; height: 20px; margin-left: 10px; vertical-align: middle; }
.ts-switch input { opacity: 0; width: 0; height: 0; }
.ts-slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .4s; border-radius: 20px; }
.ts-slider:before { position: absolute; content: ""; height: 14px; width: 14px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
.ts-switch input:checked + .ts-slider { background-color: #174ea6; }
.ts-switch input:checked + .ts-slider:before { transform: translateX(20px); }

/* --- Hint --- */
.ts-hint { font-size: 12px; color: #777; text-align: center; margin-top: 8px; }
.ts-print-area-hint { text-align: center; font-size: 12px; color: #888; margin-top: 20px; line-height: 1.5; }
.ts-checkbox-label {
    font-size: 13px;
    color: #333;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 20px;
}
.ts-checkbox-label input { margin-top: 2px; }

/* --- Drop Area --- */
.ts-drop-area {
    border: 2px dashed #ccc;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    margin-top: 15px;
    margin-bottom: 20px;
    background-color: #f9f9f9;
    color: #666;
    transition: all 0.3s ease;
    cursor: pointer;
}
.ts-drop-area:hover, .ts-drop-area.dragover {
    border-color: #007bff;
    background-color: #eef5ff;
    color: #007bff;
}
.ts-drop-area .ts-icon {
    font-size: 24px;
    display: block;
    margin-bottom: 5px;
}
.ts-drop-area p { margin: 0; font-size: 13px; }

/* --- Modal Vista Previa --- */
.ts-modal {
    display: none; 
    position: fixed; 
    z-index: 999999; 
    left: 0; 
    top: 0; 
    width: 100%; 
    height: 100%; 
    background-color: rgba(0,0,0,0.85);
    backdrop-filter: blur(5px);
    overflow: auto;
}
.ts-modal-content {
    margin: 4% auto; 
    display: block; 
    width: 90%; 
    max-width: 450px;
    position: relative;
    text-align: center;
}
#ts-modal-img {
    width: 100%; 
    height: auto; 
    border-radius: 40px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    background-color: #f1f1f1;
}
.ts-close-modal {
    position: absolute; 
    top: -40px; 
    right: 0; 
    color: #ffffff; 
    font-size: 35px; 
    font-weight: bold; 
    cursor: pointer;
    transition: 0.2s;
}
.ts-close-modal:hover { color: #ccc; }

/* ==============================================================
   Responsive (Mobile & Tablet)
   ============================================================== */
@media (max-width: 1024px) {
    .tecshop-builder-container {
        flex-direction: column;
        align-items: center;
        margin: 0 !important;
        padding: 0 !important;
    }
    .ts-col {
        width: 100% !important; /* Forzar el ancho completo en contenedor */
        max-width: 100% !important;
        box-sizing: border-box;
        margin-bottom: 10px;
        padding: 0 !important;
        border-radius: 0;
        border-left: none;
        border-right: none;
        box-shadow: none;
    }
}

@media (max-width: 480px) {
    .ts-tools-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
    }
    .ts-tool-btn {
        padding: 8px 0;
        font-size: 10px;
    }
    .ts-tool-btn .ts-icon {
        font-size: 16px;
    }
    .ts-canvas-header {
        flex-direction: column;
        gap: 15px;
        align-items: center;
    }
}

/* Escalar el canvas fijo para pantallas muy pequeñas */
@media (max-width: 380px) {
    .ts-canvas-wrapper {
        transform: scale(0.85);
        transform-origin: top center;
        margin-bottom: -96px; /* Compensa la altura escalada (640 * 0.15 = 96px) */
    }
    .ts-zoom-tools {
        right: -10px; /* Ajuste por el escalado */
    }
}

@media (max-width: 340px) {
    .ts-canvas-wrapper {
        transform: scale(0.75);
        transform-origin: top center;
        margin-bottom: -160px; /* Compensa (640 * 0.25 = 160) */
    }
}

/* Toolbars Flotantes */
.ts-floating-toolbar {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 8px 12px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    display: flex;
    gap: 8px;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(5px);
    border: 1px solid #eaeaea;
}
.ts-floating-toolbar select.ts-tool-select,
.ts-floating-toolbar input.ts-tool-input {
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #ccc;
    font-size: 13px;
    height: 30px;
}
.ts-floating-toolbar input.ts-tool-input { width: 60px; }
.ts-floating-toolbar button.ts-tool-action {
    background: #f0f0f0; border: 1px solid #ccc; border-radius: 4px;
    height: 30px; width: 30px; cursor: pointer; font-weight: bold;
}
.ts-floating-toolbar button.ts-tool-action.active {
    background: #174ea6; color: #fff; border-color: #174ea6;
}
.ts-color-picker-wrapper { height: 30px; width: 30px; border-radius: 4px; }
.ts-filter-row { display: flex; flex-direction: column; font-size: 11px; gap: 2px; }
.ts-filter-row input { width: 70px; }

/* =========================================
   RESPONSIVE MODE STYLES
   ========================================= */
.ts-responsive-only {
    display: none;
}

.t3s-responsive-active {
    display: flex !important;
    flex-direction: column !important;
    position: relative;
    overflow: hidden;
}

.t3s-responsive-active .ts-responsive-only {
    display: block;
}

/* Close button on sidebar */
#ts-responsive-close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    background: #eee;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 20px;
    cursor: pointer;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001; /* Sobre el contenido del sidebar */
}

/* Left Sidebar - Sliding Drawer */
.t3s-responsive-active .ts-sidebar-left {
    position: fixed;
    left: -100%;
    top: 0;
    width: 85%;
    max-width: 400px;
    height: 100vh;
    z-index: 10000;
    transition: left 0.3s ease-in-out;
    background: #fff;
    box-shadow: 2px 0 15px rgba(0,0,0,0.5);
    overflow-y: auto;
    padding-top: 60px;
}
.t3s-responsive-active .ts-sidebar-left.open {
    left: 0;
}

/* Columns Full Width */
.t3s-responsive-active .ts-col {
    width: 100%;
    border: none;
}

/* Stepper logic (Controlled via data-step attribute on wrapper) */
.t3s-responsive-active[data-step="canvas"] .ts-sidebar-right {
    display: none;
}
.t3s-responsive-active[data-step="canvas"] .ts-canvas-area {
    display: block;
}

.t3s-responsive-active[data-step="checkout"] .ts-canvas-area {
    display: none;
}
.t3s-responsive-active[data-step="checkout"] .ts-sidebar-right {
    display: block;
}

/* Ocultar header del canvas en móvil (Deshacer, Rehacer, Preview) */
.t3s-responsive-active .ts-canvas-header {
    display: none !important;
}

/* Centering Canvas y evitar scroll vertical */
.t3s-responsive-active .ts-canvas-area {
    position: fixed !important;
    top: 70px; /* Debajo del header principal */
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(100vh - 70px) !important;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden !important;
    background: #fff; /* Fondo para que no se traslape con nada más */
    z-index: 9000;
}

.t3s-responsive-active .ts-canvas-wrapper {
    margin: 0 auto;
    transform-origin: center center;
    /* Escalar para que quepa en la pantalla restando header y botones */
    transform: scale(min(1, calc((100vh - 150px) / 630))); 
}

/* Botón Siguiente flotante en modo responsive */
.t3s-responsive-active #ts-responsive-next-btn {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    max-width: 300px;
    z-index: 9999;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    margin-top: 0 !important;
}

/* Sidebar Padding in Responsive Mode */
.t3s-responsive-active .ts-sidebar-left {
    width: 80% !important;
    padding: 60px 25px 25px 25px !important; /* Top 60px para el botón X, resto 25px */
    box-sizing: border-box !important;
}

/* Ocultar el resto del sidebar (Paso 2) en mobile */
.t3s-responsive-active .ts-sidebar-left > hr,
.t3s-responsive-active .ts-sidebar-left > h3:nth-of-type(2),
.t3s-responsive-active .ts-sidebar-left > #ts-btn-upload,
.t3s-responsive-active .ts-sidebar-left > #ts-drop-area,
.t3s-responsive-active .ts-sidebar-left > .ts-hint,
.t3s-responsive-active .ts-sidebar-left > .ts-tools-grid {
    display: none !important;
}

.t3s-responsive-active .ts-sidebar-right {
    padding: 20px;
    box-sizing: border-box;
}

/* Ocultar footer del sitio en modo responsive */
body.t3s-is-responsive footer,
body.t3s-is-responsive .site-footer,
body.t3s-is-responsive #colophon {
    display: none !important;
}

/* ==============================================================
   Herramientas Flotantes (Mobile)
   ============================================================== */
.ts-mobile-tools-container {
    position: fixed;
    bottom: 20px;
    left: 15px;
    display: none;
    flex-direction: column;
    gap: 5px;
    z-index: 9999;
}
.t3s-responsive-active .ts-mobile-tools-container {
    display: flex;
}
.t3s-responsive-active[data-step="checkout"] .ts-mobile-tools-container {
    display: none !important;
}

.ts-floating-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: #174ea6;
    color: #fff;
    border: none;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: transform 0.2s, background-color 0.2s;
}
.ts-floating-btn:active {
    transform: scale(0.95);
    background-color: #103b82;
}

/* Contenedores para toolbars que se mostrarán dinámicamente */
#ts-mobile-toolbar-bottom,
#ts-mobile-toolbar-right {
    position: fixed;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    display: flex;
    gap: 8px;
    padding: 10px;
    z-index: 9999;
    backdrop-filter: blur(5px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    opacity: 0;
    pointer-events: none;
}
#ts-mobile-toolbar-bottom.active,
#ts-mobile-toolbar-right.active {
    opacity: 1;
    pointer-events: auto;
}

#ts-mobile-toolbar-bottom {
    bottom: 20px;
    left: 50%;
    transform: translate(-50%, 20px);
}
#ts-mobile-toolbar-bottom.active {
    transform: translate(-50%, 0);
}

#ts-mobile-toolbar-right {
    right: 15px;
    top: 50%;
    flex-direction: column;
    transform: translate(20px, -50%);
}
#ts-mobile-toolbar-right.active {
    transform: translate(0, -50%);
}

#ts-mobile-toolbar-bottom .ts-tool-btn,
#ts-mobile-toolbar-right .ts-tool-btn {
    width: 60px;
    padding: 10px 0;
    border: none;
    background: transparent;
}
#ts-mobile-toolbar-bottom .ts-tool-btn:active,
#ts-mobile-toolbar-right .ts-tool-btn:active {
    background: #f4f6fb;
    border-radius: 8px;
}
