/* Global Styles */
* {
    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%);
    color: #333;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
}

/* Header Styles */
header {
    background: white;
    padding: 25px 30px;
    border-radius: 12px;
    margin-bottom: 25px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

header h1 {
    color: #2c3e50;
    font-size: 28px;
    font-weight: 700;
}

.header-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

#formName {
    padding: 12px 18px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    width: 220px;
    transition: border-color 0.3s;
}

#formName:focus {
    outline: none;
    border-color: #667eea;
}

/* Button Styles */
button {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(240, 147, 251, 0.4);
}

.btn-success {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 172, 254, 0.4);
}

.btn-danger {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    color: white;
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(250, 112, 154, 0.4);
}

/* Builder Container */
.builder-container {
    display: grid;
    grid-template-columns: 280px 1fr 340px;
    gap: 25px;
    min-height: 70vh;
}

/* Field Palette */
.field-palette {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.field-palette h3 {
    margin-bottom: 10px;
    color: #2c3e50;
    font-size: 20px;
}

.palette-hint {
    font-size: 12px;
    color: #7f8c8d;
    margin-bottom: 20px;
}

.palette-items {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.palette-item {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    padding: 14px 16px;
    border-radius: 8px;
    cursor: move;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    font-weight: 500;
}

.palette-item:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.palette-item.dragging {
    opacity: 0.5;
    transform: rotate(5deg);
}

.icon {
    font-size: 22px;
}

/* Drop Zone */
.drop-zone {
    background: white;
    padding: 35px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    min-height: 70vh;
    position: relative;
    transition: all 0.3s ease;
}

.drop-zone.drag-over {
    background: linear-gradient(135deg, #e8f4f8 0%, #d4e9f7 100%);
    border: 3px dashed #667eea;
    transform: scale(0.98);
}

.empty-message {
    text-align: center;
    color: #95a5a6;
    padding: 80px 20px;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.empty-message h3 {
    font-size: 24px;
    margin-bottom: 10px;
    color: #7f8c8d;
}

.empty-message p {
    font-size: 16px;
}

/* Form Elements */
.form-element {
    background: #ffffff;
    padding: 20px;
    margin-bottom: 18px;
    border-radius: 10px;
    border: 2px solid #e0e0e0;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.form-element:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
    transform: translateY(-2px);
}

.form-element.selected {
    border-color: #667eea;
    background: linear-gradient(135deg, #f5f7ff 0%, #e8f4f8 100%);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.form-element label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: #2c3e50;
    font-size: 15px;
}

.form-element input,
.form-element textarea,
.form-element select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s;
    font-family: inherit;
}

.form-element input:focus,
.form-element textarea:focus,
.form-element select:focus {
    outline: none;
    border-color: #667eea;
}

.form-element textarea {
    resize: vertical;
    min-height: 100px;
}

.element-actions {
    position: absolute;
    top: 15px;
    right: 15px;
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.3s;
}

.form-element:hover .element-actions {
    opacity: 1;
}

.element-actions button {
    padding: 6px 12px;
    font-size: 12px;
}

/* Properties Panel */
.properties-panel {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.properties-panel h3 {
    margin-bottom: 20px;
    color: #2c3e50;
    font-size: 20px;
}

.no-selection {
    text-align: center;
    color: #95a5a6;
    padding: 40px 20px;
}

.no-selection-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.no-selection p {
    font-size: 14px;
}

.property-group {
    margin-bottom: 20px;
}

.property-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #2c3e50;
    font-size: 13px;
}

.property-group input,
.property-group textarea,
.property-group select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 13px;
    transition: border-color 0.3s;
}

.property-group input:focus,
.property-group textarea:focus,
.property-group select:focus {
    outline: none;
    border-color: #667eea;
}

.property-group input[type="checkbox"] {
    width: auto;
    margin-right: 8px;
    cursor: pointer;
}

/* Options List */
.options-list {
    margin-top: 12px;
}

.option-item {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.option-item input {
    flex: 1;
}

.option-item button {
    padding: 8px 12px;
    font-size: 12px;
}

.add-option {
    margin-top: 10px;
    width: 100%;
}

/* Radio and Checkbox Groups */
.radio-group, .checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.radio-item, .checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
}

.radio-item input, .checkbox-item input {
    width: auto;
    margin: 0;
    cursor: pointer;
}

.radio-item label, .checkbox-item label {
    margin: 0;
    cursor: pointer;
    font-weight: normal;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    margin: 60px auto;
    padding: 0;
    border-radius: 16px;
    width: 85%;
    max-width: 700px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    animation: slideDown 0.3s;
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content.large {
    max-width: 900px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px 30px;
    border-bottom: 2px solid #f0f0f0;
}

.modal-header h2 {
    color: #2c3e50;
    font-size: 24px;
}

.close {
    color: #aaa;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    transition: color 0.3s;
}

.close:hover {
    color: #333;
}

#savedFormsList, #previewContent {
    padding: 25px 30px;
}

.saved-form-item {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    padding: 20px;
    margin-bottom: 15px;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: transform 0.3s;
}

.saved-form-item:hover {
    transform: translateX(5px);
}

.saved-form-item h4 {
    color: #2c3e50;
    margin-bottom: 8px;
    font-size: 18px;
}

.saved-form-item p {
    color: #7f8c8d;
    font-size: 13px;
}

.saved-form-actions {
    display: flex;
    gap: 8px;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 24px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    display: none;
    z-index: 2000;
    animation: slideUp 0.3s;
}

@keyframes slideUp {
    from {
        transform: translateY(100px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.toast.show {
    display: block;
}

/* Scrollbar Styles */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

/* Responsive Design */
@media (max-width: 1200px) {
    .builder-container {
        grid-template-columns: 240px 1fr 300px;
    }
}

@media (max-width: 1024px) {
    .builder-container {
        grid-template-columns: 1fr;
    }
    
    .field-palette, .properties-panel {
        max-height: 400px;
    }
}

@media (max-width: 768px) {
    header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .header-actions {
        justify-content: stretch;
        flex-direction: column;
    }
    
    .header-actions button,
    #formName {
        width: 100%;
    }
    
    .modal-content {
        width: 95%;
        margin: 20px auto;
    }
}

/* Heading and Paragraph Styles */
.form-element h1,
.form-element h2,
.form-element h3 {
    margin: 0;
    color: #2c3e50;
}

.form-element .paragraph-text {
    color: #555;
    line-height: 1.6;
}