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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
}

header p {
    font-size: 1.2em;
    opacity: 0.9;
}

.main-content {
    display: grid;
    grid-template-columns: 250px 1fr 300px;
    gap: 0;
    height: calc(100vh - 200px);
    min-height: 600px;
}

/* Sidebar Styles */
.sidebar {
    background: #f8f9fa;
    border-right: 2px solid #e9ecef;
    padding: 20px;
    overflow-y: auto;
}

.sidebar h2 {
    color: #495057;
    font-size: 1.3em;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #dee2e6;
}

.elements-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.section-title {
    font-weight: 700;
    color: #667eea;
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 15px;
    margin-bottom: 5px;
    padding-left: 5px;
}

.element-item {
    background: white;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: move;
    transition: all 0.2s;
    user-select: none;
}

.element-item:hover {
    background: #e7f5ff;
    border-color: #4dabf7;
    transform: translateX(5px);
}

.element-item:active {
    opacity: 0.5;
}

.element-item .icon {
    font-size: 1.5em;
}

.element-item span:last-child {
    font-weight: 500;
    color: #495057;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #dee2e6;
}

.snap-toggle {
    background: white;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.snap-toggle:hover {
    border-color: #4dabf7;
    background: #e7f5ff;
}

.snap-toggle input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.snap-toggle span {
    font-weight: 500;
    color: #495057;
    flex: 1;
}

.btn-control {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: transform 0.2s;
}

.btn-control:hover {
    transform: scale(1.05);
}

.btn-control:active {
    transform: scale(0.95);
}

/* Canvas Styles */
.canvas-wrapper {
    display: flex;
    flex-direction: column;
    background: #ffffff;
}

.canvas-toolbar {
    background: #495057;
    color: white;
    padding: 15px;
    text-align: center;
    font-weight: 600;
}

.canvas {
    flex: 1;
    background: white;
    background-image: 
        linear-gradient(rgba(102, 126, 234, 0.15) 1px, transparent 1px),
        linear-gradient(90deg, rgba(102, 126, 234, 0.15) 1px, transparent 1px);
    background-size: 20px 20px;
    background-position: 0 0;
    position: relative;
    overflow: auto;
    padding: 20px;
    min-height: 800px;
}

.canvas.drag-over {
    background-color: #e7f5ff;
}

.canvas-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #adb5bd;
    font-size: 1.2em;
    pointer-events: none;
}

.canvas:not(:empty) .canvas-placeholder {
    display: none;
}

/* Dropped Elements */
.dropped-element {
    position: absolute;
    cursor: move;
    padding: 10px;
    border: 2px solid transparent;
    transition: all 0.2s;
    min-width: 100px;
}

.dropped-element:hover {
    border-color: #4dabf7;
}

.dropped-element.selected {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.dropped-element .delete-btn {
    position: absolute;
    top: -12px;
    right: -12px;
    background: #fa5252;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 0.9em;
    display: none;
    z-index: 10;
}

.dropped-element:hover .delete-btn,
.dropped-element.selected .delete-btn {
    display: block;
}

/* Nested Drop Zones */
.drop-zone {
    position: relative;
    min-height: 100px;
}

.drop-zone.drag-over-nested {
    background-color: rgba(102, 126, 234, 0.1);
    outline: 2px dashed #667eea;
    outline-offset: -2px;
}

.drop-zone-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #adb5bd;
    font-size: 0.9em;
    pointer-events: none;
    text-align: center;
}

.drop-zone:not(:empty) .drop-zone-placeholder {
    display: none;
}

/* Element Type Styles */
.dropped-element[data-element-type="heading"] {
    font-size: 2em;
    font-weight: bold;
    color: #212529;
}

.dropped-element[data-element-type="paragraph"] {
    font-size: 1em;
    line-height: 1.6;
    color: #495057;
}

.dropped-element[data-element-type="button"] button {
    background: #4dabf7;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    font-size: 1em;
    cursor: pointer;
}

.dropped-element[data-element-type="image"] {
    background: #f1f3f5;
    border: 2px dashed #adb5bd;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100px;
}

.dropped-element[data-element-type="input"] input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 1em;
}

.dropped-element[data-element-type="link"] a {
    color: #4dabf7;
    text-decoration: none;
    font-weight: 500;
}

/* Layout Building Blocks */
.dropped-element[data-element-type="header"] {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    width: 100%;
    max-width: 100%;
}

.dropped-element[data-element-type="navbar"] {
    background: #2c3e50;
    color: white;
    padding: 15px 20px;
    width: 100%;
    max-width: 100%;
    display: flex;
    gap: 20px;
}

.dropped-element[data-element-type="navbar"] a {
    color: white;
    text-decoration: none;
    padding: 5px 10px;
}

.dropped-element[data-element-type="hero"] {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    padding: 60px 40px;
    text-align: center;
    width: 100%;
    max-width: 100%;
    min-height: 300px;
}

/* Row - New in v2 */
.dropped-element[data-element-type="row"] {
    background: rgba(102, 126, 234, 0.05);
    border: 2px dashed #667eea;
    padding: 20px;
    width: 100%;
    max-width: 100%;
    min-height: 150px;
}

.dropped-element[data-element-type="row"] > .drop-zone {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

/* Columns - Enhanced for nesting */
.dropped-element[data-element-type="columns"] {
    display: flex;
    gap: 20px;
    padding: 20px;
    width: 100%;
    max-width: 100%;
}

.dropped-element[data-element-type="columns"] .column {
    flex: 0 0 auto;
    min-width: 0;
    background: #f8f9fa;
    padding: 15px;
    border: 2px dashed #adb5bd;
    min-height: 150px;
    position: relative;
    overflow: hidden;
}

.dropped-element[data-element-type="columns"] .column.drop-zone {
    min-height: 150px;
}

.dropped-element[data-element-type="card"] {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    width: 300px;
}

.dropped-element[data-element-type="container"] {
    background: #f8f9fa;
    border: 2px dashed #adb5bd;
    min-height: 150px;
    padding: 20px;
}

.dropped-element[data-element-type="container"] > .drop-zone {
    min-height: 100px;
}

.dropped-element[data-element-type="footer"] {
    background: #343a40;
    color: white;
    padding: 30px 20px;
    text-align: center;
    width: 100%;
    max-width: 100%;
}

.dropped-element[data-element-type="logo"] {
    font-size: 1.8em;
    font-weight: bold;
    color: #667eea;
    padding: 10px;
}

/* Nested elements inside drop zones */
.drop-zone > .dropped-element {
    position: relative;
    margin-bottom: 0;
    max-width: 100%;
    box-sizing: border-box;
}

/* Ensure nested elements are flexible */
.drop-zone[style*="flex-direction: row"] > .dropped-element {
    flex-shrink: 0;
}

.drop-zone[style*="flex-direction: column"] > .dropped-element {
    width: 100%;
}

/* Content inside columns should fit */
.column .dropped-element {
    width: 100% !important;
    left: 0 !important;
    top: auto !important;
}

/* Properties Panel */
.properties-panel {
    background: #f8f9fa;
    border-left: 2px solid #e9ecef;
    padding: 20px;
    overflow-y: auto;
}

.properties-panel h2 {
    color: #495057;
    font-size: 1.3em;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #dee2e6;
}

.properties-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.no-selection {
    color: #868e96;
    text-align: center;
    padding: 20px;
}

.property-group {
    background: white;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.property-group label {
    display: block;
    color: #495057;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 0.9em;
}

.property-group input,
.property-group select,
.property-group textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 0.95em;
}

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

.property-group input[type="color"] {
    height: 40px;
    cursor: pointer;
}

.property-group input[type="range"] {
    cursor: pointer;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: white;
    padding: 30px;
    border-radius: 15px;
    width: 80%;
    max-width: 800px;
    max-height: 80vh;
    overflow: auto;
}

.modal-content.disclaimer {
    max-width: 600px;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close {
    color: #adb5bd;
    float: right;
    font-size: 2em;
    font-weight: bold;
    cursor: pointer;
    line-height: 0.8;
}

.close:hover {
    color: #495057;
}

.modal-content h2 {
    color: #495057;
    margin-bottom: 20px;
}

.export-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    border-bottom: 2px solid #dee2e6;
}

.tab-btn {
    background: none;
    border: none;
    padding: 10px 20px;
    font-size: 1em;
    font-weight: 600;
    color: #6c757d;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: #495057;
    background: #f8f9fa;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.tab-content {
    display: none;
}

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

#exportedHTML,
#exportedCSS,
#exportedJS,
#importHTMLTextarea {
    width: 100%;
    min-height: 300px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    padding: 15px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    margin-bottom: 15px;
}

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

@media (max-width: 992px) {
    .main-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
    }
    
    .sidebar,
    .properties-panel {
        border: none;
        border-bottom: 2px solid #e9ecef;
    }
}
