/* Reset y variables */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #004D35;
    --primary-dark: #003d2a;
    --secondary-color: #9dc419;
    --success-color: #48bb78;
    --danger-color: #e53e3e;
    --warning-color: #ed8936;
    --text-dark: #2d3748;
    --text-light: #718096;
    --text-muted: #a0aec0;
    --border-color: #e2e8f0;
    --bg-light: #f7fafc;
    --bg-dark: #2d3748;
    --bg-white: #ffffff;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-light);
    min-height: 100vh;
    color: var(--text-dark);
    line-height: 1.5;
}

/* Layout principal */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Header de la app */
.app-header {
    background: var(--bg-white);
    padding: 12px 24px;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-logo {
    height: 40px;
    width: auto;
}

.app-header h1 {
    color: var(--primary-color);
    font-size: 1.25rem;
    font-weight: 600;
}

/* Layout de 3 columnas */
.main-layout {
    display: grid;
    grid-template-columns: 240px 1fr 320px;
    flex: 1;
    overflow: hidden;
}

/* Panel de bloques (izquierda) */
.blocks-panel {
    background: var(--bg-white);
    border-right: 1px solid var(--border-color);
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.blocks-panel h2 {
    color: var(--primary-color);
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.panel-description {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.blocks-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 24px;
}

.block-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 8px;
    background: var(--bg-light);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: grab;
    transition: all 0.2s ease;
    font-size: 0.75rem;
    text-align: center;
    color: var(--text-dark);
}

.block-item:hover {
    border-color: var(--primary-color);
    background: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.block-item:active {
    cursor: grabbing;
    transform: scale(0.95);
}

.block-item.dragging {
    opacity: 0.5;
}

.block-icon {
    width: 32px;
    height: 32px;
    color: var(--primary-color);
}

.block-icon svg {
    width: 100%;
    height: 100%;
}

/* Configuracion global */
.global-settings {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.global-settings h3 {
    font-size: 0.875rem;
    color: var(--text-dark);
    margin-bottom: 12px;
}

.setting-group {
    margin-bottom: 12px;
}

.setting-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 4px;
}

.setting-group input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
}

.setting-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 77, 53, 0.1);
}

.setting-group small {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Area del canvas (centro) */
.canvas-area {
    background: #e2e8f0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.canvas-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
}

.canvas-header h2 {
    font-size: 0.875rem;
    color: var(--text-dark);
}

.canvas-actions {
    display: flex;
    gap: 8px;
}

.email-canvas-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    justify-content: center;
}

.email-canvas {
    width: 480px;
    background: #fafafa;
    box-shadow: var(--shadow-lg);
    flex-shrink: 0;
}

/* Header y footer fijos */
.fixed-header,
.fixed-footer {
    background: var(--bg-white);
    pointer-events: none;
    user-select: none;
}

.fixed-header img {
    display: block;
    width: 100%;
}

.fixed-footer {
    background: var(--primary-color);
    color: white;
    text-align: center;
    font-family: Helvetica, Arial, sans-serif;
    font-size: 14px;
}

.footer-main {
    padding: 15px 10px 10px;
}

.footer-main img {
    display: inline-block;
    margin-bottom: 8px;
}

.footer-main p {
    margin: 0;
}

.footer-legal {
    background: white;
    color: #939393;
    font-size: 10px;
    padding: 10px;
    line-height: 1.5;
}

.footer-legal a {
    color: #939393;
}

/* Contenedor de bloques */
.blocks-container {
    background: white;
    min-height: 200px;
}

.drop-zone {
    min-height: 100px;
    padding: 20px;
    transition: all 0.2s ease;
}

.drop-zone.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    border: 2px dashed var(--border-color);
    margin: 10px;
    border-radius: var(--radius-md);
}

.drop-zone.drag-over {
    background: rgba(0, 77, 53, 0.05);
    border-color: var(--primary-color);
}

.empty-message {
    text-align: center;
    color: var(--text-muted);
}

.empty-message svg {
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-message p {
    font-size: 0.875rem;
}

/* Bloques en el canvas */
.canvas-block {
    position: relative;
    background: white;
    border: 2px solid transparent;
    transition: all 0.2s ease;
    cursor: pointer;
}

.canvas-block:hover {
    border-color: var(--primary-color);
}

.canvas-block.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 77, 53, 0.2);
}

.canvas-block.drag-over {
    border-top: 3px solid var(--secondary-color);
}

.block-controls {
    position: absolute;
    top: 4px;
    right: 4px;
    display: none;
    gap: 4px;
    z-index: 10;
}

.canvas-block:hover .block-controls,
.canvas-block.selected .block-controls {
    display: flex;
}

.block-control-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--bg-white);
    color: var(--text-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.block-control-btn:hover {
    background: var(--primary-color);
    color: white;
}

.block-control-btn.delete:hover {
    background: var(--danger-color);
}

.block-control-btn svg {
    width: 16px;
    height: 16px;
}

/* Indicador de arrastre */
.drag-indicator {
    height: 3px;
    background: var(--secondary-color);
    margin: 0;
}

/* Panel de propiedades (derecha) */
.properties-panel {
    background: var(--bg-white);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.panel-tab {
    flex: 1;
    padding: 12px 8px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-light);
    transition: all 0.2s ease;
}

.panel-tab:hover {
    color: var(--text-dark);
}

.panel-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: none;
}

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

.no-selection {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-muted);
    text-align: center;
}

.no-selection svg {
    margin-bottom: 12px;
    opacity: 0.5;
}

.no-selection p {
    font-size: 0.875rem;
}

/* Formulario de propiedades */
.properties-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.property-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.property-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-dark);
}

.property-group input[type="text"],
.property-group input[type="url"],
.property-group input[type="number"],
.property-group select,
.property-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-family: inherit;
}

.property-group input:focus,
.property-group select:focus,
.property-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 77, 53, 0.1);
}

.property-group textarea {
    min-height: 80px;
    resize: vertical;
}

.color-input-group {
    display: flex;
    gap: 8px;
}

.color-input-group input[type="color"] {
    width: 48px;
    height: 36px;
    padding: 2px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.color-input-group input[type="text"] {
    flex: 1;
    font-family: monospace;
}

.edit-rich-text-btn {
    padding: 8px 12px;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--primary-color);
    transition: all 0.2s ease;
}

.edit-rich-text-btn:hover {
    background: var(--primary-color);
    color: white;
}

/* Panel de preview */
.preview-actions,
.code-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.preview-frame-container {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #f5f5f5;
}

#previewFrame {
    width: 100%;
    height: 500px;
    border: none;
    background: white;
}

/* Panel de codigo */
#htmlCode {
    background: var(--bg-dark);
    color: #e2e8f0;
    padding: 16px;
    border-radius: var(--radius-md);
    overflow: auto;
    max-height: 500px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.75rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
}

#htmlCode code {
    color: inherit;
}

/* Botones */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--bg-light);
    color: var(--text-dark);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #c53030;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.75rem;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
}

.modal.active {
    display: block;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1rem;
    color: var(--text-dark);
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

.modal-close:hover {
    background: var(--bg-light);
    color: var(--text-dark);
}

.modal-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
}

/* Quill editor en modal */
#richTextEditor {
    min-height: 200px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

#richTextEditor .ql-toolbar {
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    background: var(--bg-light);
}

#richTextEditor .ql-container {
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
}

/* Notificaciones */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    background: var(--success-color);
    color: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s ease;
    pointer-events: none;
    z-index: 2000;
    font-weight: 600;
    font-size: 0.875rem;
}

.notification.show {
    opacity: 1;
    transform: translateY(0);
}

.notification.error {
    background: var(--danger-color);
}

.notification.warning {
    background: var(--warning-color);
}

/* Estilos para bloques en el canvas */
.block-content {
    padding: 20px;
    font-family: Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

.block-content.hero-block {
    padding: 0;
}

.block-content.hero-block img {
    display: block;
    width: 100%;
    max-width: 480px;
}

.block-content.hero-block .placeholder-image {
    background: var(--bg-light);
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.block-content h1 {
    margin: 0;
    font-size: 24px;
    line-height: 1.3;
    color: #002619;
    text-align: center;
}

.block-content h2 {
    margin: 0;
    font-size: 20px;
    line-height: 1.3;
    color: #002619;
    text-align: center;
}

.block-content p {
    margin: 0;
    color: #333;
    text-align: justify;
}

.block-content .button-container {
    text-align: center;
}

.block-content .email-button {
    display: inline-block;
    padding: 10px 30px;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 3px;
    font-weight: bold;
}

.block-content .two-buttons-container {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.block-content .two-buttons-container .email-button {
    padding: 10px 20px;
}

.block-content .two-columns-container {
    display: table;
    width: 100%;
}

.block-content .column {
    display: table-cell;
    width: 50%;
    vertical-align: top;
    padding: 10px;
}

.block-content .column img {
    max-width: 100%;
    height: auto;
}

.block-content .spacer-block {
    height: 20px;
}

.block-content .image-block img {
    display: block;
    max-width: 100%;
    margin: 0 auto;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-light);
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

/* Responsive */
@media (max-width: 1200px) {
    .main-layout {
        grid-template-columns: 200px 1fr 280px;
    }
}

@media (max-width: 900px) {
    .main-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
    }

    .blocks-panel {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        max-height: 200px;
    }

    .blocks-list {
        grid-template-columns: repeat(4, 1fr);
    }

    .properties-panel {
        border-left: none;
        border-top: 1px solid var(--border-color);
        max-height: 300px;
    }
}
