/* Diseñador HTML - Estilo Editor Digital Profesional */

/* Layout principal */
.designer-layout-new {
    display: grid;
    grid-template-columns: 280px 1fr 320px;
    gap: 0;
    height: calc(100vh - 70px);
    margin: 0;
    background: #1a1a1a;
    border-top: 1px solid #2d2d2d;
}

/* Sidebar izquierdo - Plantillas */
.designer-sidebar-new {
    background: #252525;
    border-right: 1px solid #2d2d2d;
    padding: 0;
    overflow-y: auto;
    color: #e0e0e0;
}

.designer-sidebar-new h3 {
    font-size: 11px;
    color: #9ca3af;
    margin: 0;
    padding: 12px 16px;
    border-bottom: 1px solid #2d2d2d;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    background: #1f1f1f;
}

.templates-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
}

.template-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    background: #2a2a2a;
}

.template-item:hover {
    background: #333333;
    border-color: #4a9eff;
    transform: translateX(2px);
}

.template-item.active {
    background: linear-gradient(135deg, #4a9eff 0%, #357abd 100%);
    border-color: #4a9eff;
    box-shadow: 0 2px 8px rgba(74, 158, 255, 0.3);
}

.template-item i {
    font-size: 20px;
    color: #9ca3af;
    width: 24px;
    text-align: center;
}

.template-item.active i {
    color: white;
}

.template-item strong {
    display: block;
    font-size: 13px;
    color: #e0e0e0;
    margin-bottom: 2px;
    font-weight: 500;
}

.template-item.active strong {
    color: white;
}

.template-item span {
    display: block;
    font-size: 11px;
    color: #9ca3af;
}

.template-item.active span {
    color: rgba(255, 255, 255, 0.8);
}

/* Área principal del canvas */
.designer-main-area {
    background: #1a1a1a;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Toolbar superior */
.designer-toolbar {
    background: #252525;
    border-bottom: 1px solid #2d2d2d;
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    min-height: 48px;
}

.toolbar-group {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 4px;
    background: #1f1f1f;
    border-radius: 6px;
    border: 1px solid #2d2d2d;
}

.toolbar-btn {
    padding: 8px 12px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #e0e0e0;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    position: relative;
}

.toolbar-btn:hover {
    background: #333333;
    color: #4a9eff;
}

.toolbar-btn:active {
    background: #4a9eff;
    color: white;
}

.toolbar-btn i {
    font-size: 14px;
}

.toolbar-divider {
    width: 1px;
    height: 24px;
    background: #2d2d2d;
    margin: 0 4px;
}

/* Contenedor del preview con grid background */
.designer-preview-container {
    flex: 1;
    overflow: auto;
    background: 
        linear-gradient(rgba(74, 158, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(74, 158, 255, 0.03) 1px, transparent 1px),
        #1a1a1a;
    background-size: 20px 20px;
    padding: 40px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Canvas wrapper con sombra y bordes - REDIMENSIONABLE */
.designer-canvas-wrapper {
    background: white;
    border-radius: 8px;
    box-shadow: 
        0 0 0 1px rgba(0, 0, 0, 0.1),
        0 20px 60px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    min-width: 400px;
    min-height: 300px;
    max-width: 1600px;
    max-height: 1200px;
    width: 800px;
    height: 600px;
    position: relative;
    overflow: hidden;
    resize: both;
    cursor: default;
}

/* Handles de redimensionamiento */
.canvas-resize-handles {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 10;
}

.resize-handle {
    position: absolute;
    background: #4a9eff;
    border: 2px solid white;
    border-radius: 50%;
    width: 12px;
    height: 12px;
    pointer-events: all;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
}

.designer-canvas-wrapper:hover .resize-handle {
    opacity: 1;
}

.resize-handle:hover {
    transform: scale(1.3);
    background: #357abd;
}

.resize-handle-n {
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    cursor: n-resize;
}

.resize-handle-s {
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    cursor: s-resize;
}

.resize-handle-e {
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    cursor: e-resize;
}

.resize-handle-w {
    left: -6px;
    top: 50%;
    transform: translateY(-50%);
    cursor: w-resize;
}

.resize-handle-ne {
    top: -6px;
    right: -6px;
    cursor: ne-resize;
}

.resize-handle-nw {
    top: -6px;
    left: -6px;
    cursor: nw-resize;
}

.resize-handle-se {
    bottom: -6px;
    right: -6px;
    cursor: se-resize;
}

.resize-handle-sw {
    bottom: -6px;
    left: -6px;
    cursor: sw-resize;
}

/* Indicador de tamaño */
.canvas-size-indicator {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(37, 37, 37, 0.9);
    color: #e0e0e0;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    z-index: 20;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}

.designer-canvas-wrapper:hover .canvas-size-indicator {
    opacity: 1;
}

.designer-canvas-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 19px,
            rgba(0, 0, 0, 0.02) 19px,
            rgba(0, 0, 0, 0.02) 20px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 19px,
            rgba(0, 0, 0, 0.02) 19px,
            rgba(0, 0, 0, 0.02) 20px
        );
    pointer-events: none;
    z-index: 1;
}

#templatePreview {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
    display: block;
    position: relative;
    z-index: 2;
}

/* Controles de zoom y navegación */
.designer-view-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    gap: 8px;
    background: rgba(37, 37, 37, 0.95);
    backdrop-filter: blur(10px);
    padding: 8px;
    border-radius: 8px;
    border: 1px solid #2d2d2d;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 100;
}

.view-control-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: #2a2a2a;
    color: #e0e0e0;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.view-control-btn:hover {
    background: #333333;
    color: #4a9eff;
}

.view-control-btn:active {
    background: #4a9eff;
    color: white;
}

.zoom-indicator {
    padding: 0 12px;
    display: flex;
    align-items: center;
    color: #9ca3af;
    font-size: 12px;
    font-weight: 500;
    min-width: 60px;
    justify-content: center;
}

/* Panel de propiedades derecho */
.designer-properties-panel {
    background: #252525;
    border-left: 1px solid #2d2d2d;
    padding: 0;
    overflow-y: auto;
    color: #e0e0e0;
    display: flex;
    flex-direction: column;
}

.designer-properties-panel h3 {
    font-size: 11px;
    color: #9ca3af;
    margin: 0;
    padding: 12px 16px;
    border-bottom: 1px solid #2d2d2d;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    background: #1f1f1f;
    position: sticky;
    top: 0;
    z-index: 10;
}

.properties-content {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 12px;
}

.property-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    margin-bottom: 8px;
    background: #2a2a2a;
    border-radius: 6px;
    border: 1px solid #2d2d2d;
}

.property-group label {
    font-size: 11px;
    color: #9ca3af;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.property-group input,
.property-group textarea,
.property-group select {
    padding: 10px 12px;
    border: 1px solid #2d2d2d;
    border-radius: 4px;
    font-size: 13px;
    width: 100%;
    background: #1f1f1f;
    color: #e0e0e0;
    transition: all 0.2s;
}

.property-group input:focus,
.property-group textarea:focus,
.property-group select:focus {
    outline: none;
    border-color: #4a9eff;
    box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.1);
}

.property-group textarea {
    min-height: 80px;
    resize: vertical;
    font-family: 'Courier New', monospace;
}

/* Botones de estilo en propiedades */
.property-group .style-buttons {
    display: flex;
    gap: 4px;
}

.property-group .style-buttons button {
    flex: 1;
    padding: 8px;
    border: 1px solid #2d2d2d;
    background: #1f1f1f;
    color: #e0e0e0;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.property-group .style-buttons button:hover {
    background: #333333;
    border-color: #4a9eff;
}

.property-group .style-buttons button.active {
    background: #4a9eff;
    border-color: #4a9eff;
    color: white;
}

/* Sidebar tabs */
.sidebar-tabs {
    display: flex;
    gap: 0;
    background: #1f1f1f;
    border-bottom: 1px solid #2d2d2d;
    padding: 4px;
}

.sidebar-tab {
    flex: 1;
    padding: 10px 12px;
    border: none;
    background: transparent;
    color: #9ca3af;
    cursor: pointer;
    font-size: 12px;
    border-radius: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-weight: 500;
}

.sidebar-tab:hover {
    background: #2a2a2a;
    color: #e0e0e0;
}

.sidebar-tab.active {
    background: #4a9eff;
    color: white;
}

.sidebar-content {
    display: none;
}

.sidebar-content.active {
    display: block;
}

/* Empty state mejorado */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 40px;
    color: #9ca3af;
}

.empty-state i {
    font-size: 64px;
    color: #2d2d2d;
    margin-bottom: 20px;
}

.empty-state h3 {
    color: #e0e0e0;
    margin-bottom: 10px;
    font-size: 18px;
}

.empty-state p {
    color: #9ca3af;
    margin-bottom: 20px;
    font-size: 14px;
}

/* Elementos editables destacados */
[data-editable] {
    position: relative;
    transition: all 0.2s;
}

[data-editable]:hover {
    outline: 2px dashed #4a9eff;
    outline-offset: 2px;
    cursor: pointer;
    background: rgba(74, 158, 255, 0.05);
}

[data-editable].editing {
    outline: 2px solid #4a9eff;
    background: rgba(74, 158, 255, 0.1);
    box-shadow: 0 0 0 4px rgba(74, 158, 255, 0.2);
}

/* Code editor mejorado */
.code-editor-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #1a1a1a;
    overflow: hidden;
}

.code-editor-header {
    background: #252525;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #e0e0e0;
    border-bottom: 1px solid #2d2d2d;
}

.code-editor {
    flex: 1;
    width: 100%;
    padding: 20px;
    background: #1a1a1a;
    color: #e0e0e0;
    border: none;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    resize: none;
    outline: none;
    tab-size: 4;
}

.code-editor::placeholder {
    color: #4a4a4a;
}

/* Panel de capas/elementos */
.designer-layers-panel {
    background: #2a2a2a;
    border-top: 1px solid #2d2d2d;
    padding: 12px;
    max-height: 200px;
    overflow-y: auto;
}

.layers-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.layer-item {
    padding: 8px 12px;
    background: #1f1f1f;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #e0e0e0;
    transition: all 0.2s;
}

.layer-item:hover {
    background: #333333;
}

.layer-item.active {
    background: #4a9eff;
    color: white;
}

.layer-item i {
    font-size: 12px;
    width: 16px;
}

/* Scrollbars personalizados */
.designer-sidebar-new::-webkit-scrollbar,
.designer-properties-panel::-webkit-scrollbar,
.designer-preview-container::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.designer-sidebar-new::-webkit-scrollbar-track,
.designer-properties-panel::-webkit-scrollbar-track,
.designer-preview-container::-webkit-scrollbar-track {
    background: #1f1f1f;
}

.designer-sidebar-new::-webkit-scrollbar-thumb,
.designer-properties-panel::-webkit-scrollbar-thumb,
.designer-preview-container::-webkit-scrollbar-thumb {
    background: #2d2d2d;
    border-radius: 4px;
}

.designer-sidebar-new::-webkit-scrollbar-thumb:hover,
.designer-properties-panel::-webkit-scrollbar-thumb:hover,
.designer-preview-container::-webkit-scrollbar-thumb:hover {
    background: #3d3d3d;
}

/* Variables modal mejorado */
.variables-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.variable-group {
    background: #2a2a2a;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid #2d2d2d;
}

.variable-group h4 {
    margin: 0 0 12px 0;
    color: #e0e0e0;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.variable-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.variable-item code {
    background: #1f1f1f;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 11px;
    color: #4a9eff;
    font-weight: 600;
    min-width: 150px;
    border: 1px solid #2d2d2d;
    font-family: 'Courier New', monospace;
}

.variable-item input {
    flex: 1;
    padding: 8px;
    border: 1px solid #2d2d2d;
    border-radius: 4px;
    font-size: 13px;
    background: #1f1f1f;
    color: #e0e0e0;
}

/* Template item actions */
.template-item-actions {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.3s;
}

.template-item:hover .template-item-actions {
    opacity: 1;
}

.template-item-actions button {
    padding: 4px 8px;
    border: none;
    background: rgba(37, 37, 37, 0.9);
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    color: #9ca3af;
    transition: all 0.2s;
}

.template-item-actions button:hover {
    background: #ef4444;
    color: white;
}

/* Responsive */
@media (max-width: 1400px) {
    .designer-layout-new {
        grid-template-columns: 240px 1fr 280px;
    }
}

@media (max-width: 1200px) {
    .designer-layout-new {
        grid-template-columns: 200px 1fr;
    }
    
    .designer-properties-panel {
        position: fixed;
        right: -320px;
        top: 118px;
        width: 300px;
        height: calc(100vh - 118px);
        transition: right 0.3s;
        z-index: 1000;
        border-left: 1px solid #2d2d2d;
    }
    
    .designer-properties-panel.open {
        right: 0;
    }
    
    .designer-toolbar {
        flex-wrap: wrap;
        min-height: auto;
    }
    
    .toolbar-group {
        flex-wrap: wrap;
    }
    
    .designer-canvas-wrapper {
        min-width: 600px;
    }
}

@media (max-width: 768px) {
    .designer-layout-new {
        grid-template-columns: 1fr;
    }
    
    .designer-sidebar-new {
        position: fixed;
        left: -280px;
        top: 70px;
        width: 280px;
        height: calc(100vh - 70px);
        transition: left 0.3s;
        z-index: 1000;
    }
    
    .designer-sidebar-new.open {
        left: 0;
    }
    
    .designer-canvas-wrapper {
        min-width: 100%;
    }
    
    .designer-preview-container {
        padding: 20px;
    }
}

/* Tutorial Modal Styles */
.tutorial-content {
    padding: 1rem 0;
}

.tutorial-section {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #e2e8f0;
}

.tutorial-section:last-child {
    border-bottom: none;
}

.tutorial-section h3 {
    color: #1e293b;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tutorial-section h3 i {
    color: #3b82f6;
}

.tutorial-section p {
    color: #475569;
    line-height: 1.6;
    margin-bottom: 0.75rem;
}

.tutorial-section ol,
.tutorial-section ul {
    color: #475569;
    line-height: 1.8;
    padding-left: 1.5rem;
}

.tutorial-section li {
    margin-bottom: 0.5rem;
}

.tutorial-section li strong {
    color: #1e293b;
}

.tutorial-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.feature-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.feature-item i {
    color: #3b82f6;
    font-size: 1.25rem;
    margin-top: 0.25rem;
}

.feature-item strong {
    color: #1e293b;
    display: block;
    margin-bottom: 0.25rem;
}

.variables-examples {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
    padding: 1rem;
    background: #f1f5f9;
    border-radius: 8px;
    border-left: 4px solid #3b82f6;
}

.variables-examples code {
    background: #ffffff;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    color: #3b82f6;
    border: 1px solid #e2e8f0;
    display: inline-block;
    margin-right: 0.5rem;
}

.shortcuts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.shortcut-item {
    padding: 0.75rem;
    background: #f8fafc;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    font-size: 0.875rem;
    color: #475569;
}

.shortcut-item kbd {
    background: #ffffff;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    border: 1px solid #cbd5e1;
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    color: #1e293b;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    margin: 0 0.25rem;
}

.tutorial-tip {
    background: #eff6ff;
    border-left: 4px solid #3b82f6;
    padding: 1rem;
    border-radius: 6px;
    margin-top: 1.5rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.tutorial-tip i {
    color: #3b82f6;
    font-size: 1.25rem;
    margin-top: 0.125rem;
}

.tutorial-tip strong {
    color: #1e40af;
}

.modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
}

.tutorial-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #475569;
    font-size: 0.875rem;
    cursor: pointer;
}

.tutorial-checkbox input[type="checkbox"] {
    cursor: pointer;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
}

/* Dark mode para tutorial */
body.dark-mode .tutorial-section,
html.dark-mode .tutorial-section {
    border-bottom-color: #334155;
}

body.dark-mode .tutorial-section h3,
html.dark-mode .tutorial-section h3 {
    color: #f1f5f9;
}

body.dark-mode .tutorial-section p,
html.dark-mode .tutorial-section p,
body.dark-mode .tutorial-section li,
html.dark-mode .tutorial-section li {
    color: #cbd5e1;
}

body.dark-mode .tutorial-section li strong,
html.dark-mode .tutorial-section li strong {
    color: #f1f5f9;
}

body.dark-mode .feature-item,
html.dark-mode .feature-item {
    background: #1e293b;
    border-color: #334155;
}

body.dark-mode .feature-item strong,
html.dark-mode .feature-item strong {
    color: #f1f5f9;
}

body.dark-mode .variables-examples,
html.dark-mode .variables-examples {
    background: #1e293b;
    border-left-color: #3b82f6;
}

body.dark-mode .variables-examples code,
html.dark-mode .variables-examples code {
    background: #0f172a;
    border-color: #334155;
    color: #60a5fa;
}

body.dark-mode .shortcut-item,
html.dark-mode .shortcut-item {
    background: #1e293b;
    border-color: #334155;
    color: #cbd5e1;
}

body.dark-mode .shortcut-item kbd,
html.dark-mode .shortcut-item kbd {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}

body.dark-mode .tutorial-tip,
html.dark-mode .tutorial-tip {
    background: #1e3a8a;
    border-left-color: #60a5fa;
}

body.dark-mode .tutorial-tip strong,
html.dark-mode .tutorial-tip strong {
    color: #93c5fd;
}

body.dark-mode .modal-footer,
html.dark-mode .modal-footer {
    background: #1e293b;
    border-top-color: #334155;
}

body.dark-mode .tutorial-checkbox,
html.dark-mode .tutorial-checkbox {
    color: #cbd5e1;
}
