* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    background-color: #f5f7fa;
    color: #333;
}

.app-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.app-header h1 {
    font-size: 24px;
    font-weight: 600;
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

#templateName {
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    width: 200px;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.btn-primary {
    background-color: #4CAF50;
    color: white;
}

.btn-primary:hover {
    background-color: #45a049;
}

.btn-secondary {
    background-color: #2196F3;
    color: white;
}

.btn-secondary:hover {
    background-color: #0b7dda;
}

.btn-success {
    background-color: #FF9800;
    color: white;
}

.btn-success:hover {
    background-color: #e68900;
}

.btn-danger {
    background-color: #f44336;
    color: white;
}

.btn-danger:hover {
    background-color: #da190b;
}

.btn-small {
    padding: 5px 10px;
    font-size: 18px;
    background: transparent;
    color: #666;
}

.btn-small:hover {
    background-color: #f0f0f0;
}

/* Main Content Layout */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background-color: white;
    border-right: 1px solid #e0e0e0;
    overflow-y: auto;
    padding: 20px;
}

.sidebar h2 {
    font-size: 18px;
    margin-bottom: 15px;
    color: #667eea;
}

.blocks-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.filter-btn {
    padding: 6px 12px;
    border: 1px solid #ddd;
    background-color: white;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn:hover {
    background-color: #f0f0f0;
}

.filter-btn.active {
    background-color: #667eea;
    color: white;
    border-color: #667eea;
}

.blocks-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.block-item {
    padding: 15px;
    background-color: #f9f9f9;
    border: 2px dashed #ddd;
    border-radius: 6px;
    cursor: move;
    transition: all 0.3s;
}

.block-item:hover {
    background-color: #e3f2fd;
    border-color: #667eea;
    transform: translateX(5px);
}

.block-item h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 5px;
    color: #333;
}

.block-item .block-category {
    font-size: 11px;
    color: #999;
    text-transform: uppercase;
}

/* Canvas Area */
.canvas-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #f5f7fa;
    overflow: hidden;
}

.canvas-toolbar {
    padding: 15px 20px;
    background-color: white;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
}

.email-canvas {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background-color: #e9ecef;
}

.empty-canvas-message {
    text-align: center;
    padding: 100px 20px;
    color: #999;
    font-size: 16px;
}

.canvas-block {
    background-color: white;
    margin-bottom: 15px;
    border: 2px solid transparent;
    border-radius: 4px;
    position: relative;
    cursor: move;
    transition: all 0.2s;
}

.canvas-block:hover {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.canvas-block.sortable-ghost {
    opacity: 0.4;
    background-color: #667eea;
}

.block-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 5px;
    opacity: 0;
    transition: opacity 0.2s;
}

.canvas-block:hover .block-controls {
    opacity: 1;
}

.block-control-btn {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 4px;
    background-color: rgba(255, 255, 255, 0.95);
    cursor: pointer;
    font-size: 14px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.2s;
}

.block-control-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.block-control-btn.edit {
    color: #2196F3;
}

.block-control-btn.vars {
    color: #9C27B0;
}

.block-control-btn.delete {
    color: #f44336;
}

.block-content {
    pointer-events: none;
}

/* Preview Panel */
.preview-panel {
    width: 400px;
    background-color: white;
    border-left: 1px solid #e0e0e0;
    display: none;
    flex-direction: column;
}

.preview-panel.active {
    display: flex;
}

.preview-header {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.preview-header h2 {
    font-size: 18px;
    color: #667eea;
}

.preview-device-selector {
    padding: 15px 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
}

.device-btn {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    background-color: white;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.device-btn:hover {
    background-color: #f0f0f0;
}

.device-btn.active {
    background-color: #667eea;
    color: white;
    border-color: #667eea;
}

.preview-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background-color: #f5f7fa;
}

.preview-iframe-wrapper {
    background-color: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    margin: 0 auto;
    transition: all 0.3s;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: white;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 20px;
    color: #333;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
    padding: 0;
    width: 30px;
    height: 30px;
}

.modal-close:hover {
    color: #333;
}

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

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    justify-content: flex-end;
}

#templatesList {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.template-item {
    padding: 15px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.template-item:hover {
    background-color: #f9f9f9;
    border-color: #667eea;
}

.template-info h3 {
    font-size: 16px;
    margin-bottom: 5px;
}

.template-info p {
    font-size: 12px;
    color: #999;
}

.template-actions {
    display: flex;
    gap: 5px;
}

#blockHtmlEditor {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    resize: vertical;
}

.variable-group {
    margin-bottom: 15px;
}

.variable-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #333;
    font-size: 14px;
}

.variable-input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.variable-input:focus {
    outline: none;
    border-color: #667eea;
}

.variable-group code {
    background-color: #f5f5f5;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 12px;
    color: #667eea;
}

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

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}
