/* HTML Form Builder - Clean Modern Styles */

/* Color Variables */
:root {
    --primary-color: #667eea;
    --primary-dark: #5568d3;
    --primary-light: #764ba2;
    --secondary-color: #f8f9fa;
    --border-color: #e9ecef;
    --text-primary: #212529;
    --text-secondary: #495057;
    --text-muted: #6c757d;
    --success-color: #28a745;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.1);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

/* Tool Hero Section */
.tool-hero {
    display: flex;
    flex-wrap: wrap;
    gap: 32px;
    align-items: flex-start;
    margin-bottom: 2.5rem;
}

.hero-text {
    flex: 1;
    min-width: 260px;
}

.hero-text h1 {
    font-size: 40px;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.hero-subtitle {
    font-size: 18px;
    color: var(--text-muted);
    max-width: 640px;
    margin: 0;
    line-height: 1.6;
}

@media (max-width: 767px) {
    .hero-text h1 {
        font-size: clamp(1.75rem, 5vw, 2.5rem);
    }
    
    .hero-subtitle {
        font-size: clamp(1rem, 3vw, 1.125rem);
    }
}

/* Form Builder Section */
.form-builder-section {
    margin-top: 2rem;
}

.form-builder-layout {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.builder-top-row {
    display: grid;
    grid-template-columns: 280px 1fr 380px;
    gap: 1.5rem;
    min-height: 650px;
}

@media (max-width: 1200px) {
    .builder-top-row {
        grid-template-columns: 260px 1fr 340px;
    }
}

@media (max-width: 992px) {
    .builder-top-row {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        min-height: auto;
    }
}

/* Panel Styles */
.form-elements-panel,
.form-settings-panel {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 220px);
    border: 1px solid var(--border-color);
}

.panel-header {
    padding: 1.25rem 1.5rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.panel-header h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.btn-icon {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

.panel-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.panel-body::-webkit-scrollbar {
    width: 6px;
}

.panel-body::-webkit-scrollbar-track {
    background: transparent;
}

.panel-body::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.panel-body::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Element Groups */
.element-group {
    margin-bottom: 1.75rem;
}

.element-group:last-child {
    margin-bottom: 0;
}

.element-group-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.element-group-title svg {
    width: 14px;
    height: 14px;
    opacity: 0.6;
}

.element-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.625rem;
}

.element-btn {
    background: var(--secondary-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.875rem 0.625rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
    font-weight: 500;
}

.element-btn:hover {
    background: #fff;
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
    color: var(--primary-color);
}

.element-btn:active {
    transform: translateY(0);
}

.element-icon {
    font-size: 1.375rem;
    line-height: 1;
}

/* Canvas */
.form-builder-canvas {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.canvas-header {
    padding: 1.25rem 1.5rem;
    background: var(--secondary-color);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.canvas-title {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.canvas-title h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.element-count {
    font-size: 0.8125rem;
    color: var(--text-muted);
    background: #fff;
    padding: 0.375rem 0.875rem;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    font-weight: 500;
}

.canvas-actions {
    display: flex;
    gap: 0.625rem;
}

.btn-action {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-secondary);
}

.btn-action:hover:not(:disabled) {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-action:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.canvas-body {
    padding: 1.5rem;
    flex: 1;
    overflow-y: auto;
    min-height: 450px;
    background: #fafbfc;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 350px;
    color: var(--text-muted);
    text-align: center;
}

.empty-state svg {
    margin-bottom: 1.25rem;
    opacity: 0.4;
    color: var(--primary-color);
}

.empty-state p {
    margin: 0.5rem 0;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.empty-state small {
    font-size: 0.875rem;
    opacity: 0.7;
}

/* Form Elements in Canvas */
.form-element-item {
    background: #fff;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 1rem;
    position: relative;
    transition: all 0.2s ease;
    cursor: move;
}

.form-element-item:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.1);
    background: #fafbff;
}

.form-element-item.selected {
    border-color: var(--primary-color);
    border-style: solid;
    background: #f8f9ff;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.15);
}

.form-element-item.dragging {
    opacity: 0.5;
    transform: scale(0.98);
}

.element-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.875rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.element-item-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.element-item-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-item-action {
    background: transparent;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s ease;
}

.btn-item-action:hover {
    background: var(--secondary-color);
    color: var(--primary-color);
}

.element-item-preview {
    pointer-events: none;
    opacity: 0.8;
}

/* Settings Panel */
.form-settings-panel {
    background: #fff;
}

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

.tab-btn {
    flex: 1;
    padding: 0.875rem 1rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.2s ease;
}

.tab-btn:hover {
    color: var(--primary-color);
    background: rgba(102, 126, 234, 0.05);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background: #fff;
    font-weight: 600;
}

.tab-content {
    display: none;
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
    max-height: calc(100vh - 300px);
}

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

.settings-section {
    margin-bottom: 2rem;
}

.settings-section:last-child {
    margin-bottom: 0;
}

.settings-section h4 {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.625rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    transition: all 0.2s ease;
    background: #fff;
    color: var(--text-primary);
    
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-control::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

/* Theme Selector */
.theme-selector {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.875rem;
}

.theme-option {
    position: relative;
}

.theme-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.theme-option label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.625rem;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    background: #fff;
}

.theme-option input[type="radio"]:checked + label {
    border-color: var(--primary-color);
    background: #f8f9ff;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}

.theme-option label:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.1);
}

.theme-preview {
    width: 100%;
    height: 48px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.theme-name {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Checkbox Group */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-secondary);
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: background 0.2s ease;
}

.checkbox-label:hover {
    background: var(--secondary-color);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
    flex-shrink: 0;
}

/* Buttons */
.button-group {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.btn-primary,
.btn-secondary {
    padding: 0.875rem 1.25rem;
    border-radius: var(--radius-sm);
    border: none;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: #fff;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

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

/* Preview Row */
.form-preview-row {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.preview-header {
    padding: 1.5rem 2rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.preview-header h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.preview-note {
    margin: 0;
    font-size: 0.875rem;
    opacity: 0.9;
}

.preview-container {
    min-height: 400px;
    padding: 2.5rem;
    background: #fafbfc;
}

.preview-container form {
    max-width: 800px;
    margin: 0 auto;
    background: #fff;
    padding: 2.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.preview-container form input,
.preview-container form textarea,
.preview-container form select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    transition: all 0.2s ease;
    background: #fff;
    box-sizing: border-box;
    
    color: var(--text-primary);
}

.preview-container form input:focus,
.preview-container form textarea:focus,
.preview-container form select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.preview-container form label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.625rem;
}

.preview-container form button {
    padding: 0.875rem 1.75rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    
}

.preview-container form button[type="submit"] {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.preview-container form button[type="submit"]:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.3);
}

.preview-container form button[type="reset"] {
    background: #fff;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.preview-container form button[type="reset"]:hover {
    background: var(--secondary-color);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.preview-placeholder {
    text-align: center;
    color: var(--text-muted);
    padding: 4rem 2rem;
    font-size: 1rem;
}

/* Code Output */
.code-header {
    margin-bottom: 1rem;
}

.code-format-select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    background: #fff;
    color: var(--text-primary);
    
    cursor: pointer;
    transition: all 0.2s ease;
}

.code-format-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.code-container {
    position: relative;
}

.code-output {
    width: 100%;
    min-height: 400px;
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    line-height: 1.6;
    background: #f8f9fa;
    color: var(--text-primary);
    resize: vertical;
    transition: border-color 0.2s ease;
}

.code-output:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
}

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

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-dialog {
    position: relative;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    z-index: 1001;
}

.modal-content {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--secondary-color);
}

.modal-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.modal-close {
    background: transparent;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--secondary-color);
    color: var(--text-primary);
}

.modal-body {
    padding: 2rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 1.25rem 2rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 0.875rem;
    background: var(--secondary-color);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .builder-top-row {
        gap: 1rem;
    }

    .panel-body {
        padding: 1rem;
    }

    .element-buttons {
        grid-template-columns: repeat(3, 1fr);
    }

    .element-btn {
        padding: 0.75rem 0.5rem;
        font-size: 0.7rem;
    }

    .element-icon {
        font-size: 1.125rem;
    }

    .canvas-body {
        padding: 1.25rem;
    }

    .tab-content {
        padding: 1.25rem;
    }

    .theme-selector {
        grid-template-columns: 1fr;
    }

    .modal-dialog {
        width: 95%;
        margin: 1rem;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1.25rem;
    }

    .preview-container {
        padding: 1.5rem;
    }

    .preview-container form {
        padding: 1.5rem;
    }
}

@media (max-width: 480px) {
    .element-buttons {
        grid-template-columns: repeat(2, 1fr);
    }

    .canvas-header {
        flex-direction: column;
        gap: 0.875rem;
        align-items: flex-start;
    }

    .canvas-actions {
        width: 100%;
        justify-content: space-between;
    }

    .panel-tabs {
        flex-direction: column;
    }

    .tab-btn {
        border-bottom: none;
        border-right: 2px solid transparent;
        border-left: 2px solid transparent;
    }

    .tab-btn.active {
        border-right-color: var(--primary-color);
        border-bottom-color: transparent;
    }
}

/* Drag and Drop Styles */
.drag-over {
    background: #f8f9ff;
    border-color: var(--primary-color);
}

.drag-placeholder {
    height: 60px;
    background: var(--secondary-color);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
}

/* Loading State */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Success Message */
.success-message {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--success-color);
    color: #fff;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    animation: slideIn 0.3s ease-out;
    font-size: 0.875rem;
    font-weight: 500;
}

.success-message.error-message {
    background: #dc3545;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Smooth Scrolling */
* {
    scroll-behavior: smooth;
}

/* Focus Visible */
*:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}
