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

:root {
    --primary-color: #2563eb;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --error-color: #ef4444;
    --bg-color: #f8fafc;
    --border-color: #e2e8f0;
    --text-color: #1e293b;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
}

body {
    font-family:
        -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

html,
body,
#canvas3D {
    width: 100%;
    height: 100%;
}

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

/* Header */
.form-section header {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    color: white;
    padding: 20px 30px;
    margin: -30px -30px 20px -30px;
    box-shadow: var(--shadow);
}

.form-section header h1 {
    font-size: 20px;
    margin-bottom: 5px;
    text-align: center;
}

.form-section header p {
    font-size: 12px;
    opacity: 0.9;
    text-align: center;
}

.form-section header a {
    color: inherit;
}
header a:after {
    /* content: " ⎋"; */
    /* content: " 🔗"; */
    /* content: " " url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAQElEQVR42qXKwQkAIAxDUUdxtO6/RBQkQZvSi8I/pL4BoGw/XPkh4XigPmsUgh0626AjRsgxHTkUThsG2T/sIlzdTsp52kSS1wAAAABJRU5ErkJggg==); */
    content: ' ';
    background: url("data:image/svg+xml; utf8, <svg fill='white' height='1024' width='768' xmlns='http://www.w3.org/2000/svg'><path d='M640 768H128V257.90599999999995L256 256V128H0v768h768V576H640V768zM384 128l128 128L320 448l128 128 192-192   128 128V128H384z'/></svg>");
    background-size: cover;
    display: inline-block;
    position: relative;
    top: 0.3em;
    width: 0.6em;
    height: 0.8em;
    margin-left: 0.3em;
    margin-right: 0.3em;
}

/* Main grid */
.main-grid {
    display: grid;
    grid-template-columns: 450px 8px 1fr;
    gap: 0;
    flex: 1;
    overflow: hidden;
}

/* Resize handle */
.resize-handle {
    background-color: var(--border-color);
    cursor: col-resize;
    transition: background-color 0.2s;
    z-index: 10;
}

.resize-handle:hover {
    background-color: var(--primary-color);
}

.resize-handle.resizing {
    background-color: var(--primary-color);
}

/* Form section */
.form-section {
    background: white;
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    padding: 30px;
    box-shadow: inset -1px 0 0 var(--border-color);
    display: flex;
    flex-direction: column;
}

.form-section h2 {
    font-size: 16px;
    margin-top: 25px;
    margin-bottom: 15px;
    color: var(--text-color);
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}

.form-section h3 {
    font-size: 16px;
    /* margin-top: 25px; */
    margin-bottom: 15px;
    color: var(--text-color);
    padding-top: 15px;
    /* border-top: 1px solid var(--border-color); */
}

.form-group {
    margin-bottom: 12px;
    display: flex;
    align-items: center;
}

.form-group label {
    flex: 1;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-color);
}

.form-group input,
.form-group select {
    flex: 2;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: inherit;
    color: var(--text-color);
    transition:
        border-color 0.2s,
        box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    font-weight: 400;
    cursor: pointer;
}

.checkbox-group input[type='checkbox'] {
    width: auto;
    margin-right: 10px;
    cursor: pointer;
}

/* Radio group */
.radio-group {
    display: flex;
    gap: 15px;
    align-items: center;
}

.radio-label {
    display: flex;
    align-items: center;
    font-weight: 400;
    cursor: pointer;
    font-size: 13px;
}

.radio-label input[type='radio'] {
    width: auto;
    margin-right: 6px;
    cursor: pointer;
}

/* Button group */
.button-group {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.btn {
    flex: 1;
    padding: 8px 12px;
    border: none;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

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

.btn-secondary:hover:not(:disabled) {
    background-color: #475569;
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

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

/* Form warning */
.form-warning {
    background-color: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: var(--radius);
    padding: 8px 12px;
    font-size: 12px;
    color: #92400e;
    margin-top: -6px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Disabled form state */
form.disabled {
    pointer-events: none;
    opacity: 0.7;
}

/* Status message */
.status-message {
    margin-top: 15px;
    padding: 12px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    display: none;
    animation: slideIn 0.3s ease;
}

.status-message.show {
    display: block;
}

.status-message.success {
    background-color: #d1fae5;
    color: #065f46;
    border-left: 4px solid var(--success-color);
}

.status-message.error {
    background-color: #fee2e2;
    color: #a3220f;
    border-left: 4px solid var(--error-color);
}

.status-message.info {
    background-color: #dbeafe;
    color: #1e40af;
    border-left: 4px solid var(--primary-color);
}

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

/* Viewer section */
.viewer-section {
    display: flex;
    flex: 1;
    position: relative;
    overflow: hidden;
}

#canvas3D {
    flex: 1;
}

/* Properties panel */
.properties-panel {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 400px;
    max-height: 60px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    overflow: hidden;
    z-index: 5;
    transition: max-height 0.3s ease;
}

.properties-panel.expanded {
    max-height: calc(100% - 40px);
    overflow-y: auto;
}

.properties-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    /* border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px; */
}

.properties-panel h3 {
    font-size: 14px;
    margin: 0;
    color: var(--text-color);
}

.properties-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--secondary-color);
    transition:
        transform 0.3s ease,
        color 0.2s;
}

.properties-toggle:hover {
    color: var(--primary-color);
}

.chevron {
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease;
}

.properties-panel:not(.expanded) .chevron {
    transform: rotate(-180deg);
}

.properties-panel .placeholder {
    font-size: 13px;
    color: var(--secondary-color);
    font-style: italic;
}

.pset-header {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary-color);
    margin: 10px 0 4px;
    padding-bottom: 3px;
    border-bottom: 1px solid var(--primary-color);
}

.property-item {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    padding: 4px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    line-height: 1.3;
}

.property-item:last-child {
    border-bottom: none;
}

.property-key {
    flex: 1;
    color: var(--secondary-color);
    font-weight: 600;
    flex-shrink: 0;
    margin-right: 8px;
}

.property-value {
    flex: 1;
    color: var(--text-color);
    text-align: right;
    white-space: normal;
    word-break: break-word;
    /* max-width: 60%; */
}

/* Footer */
footer {
    background: var(--secondary-color);
    color: white;
    padding: 15px 30px;
    text-align: center;
    font-size: 12px;
    margin-top: auto;
}

.form-section footer {
    background: transparent;
    color: var(--secondary-color);
    border-top: 1px solid var(--border-color);
    padding: 10px 0 0;
}

/* Responsive */
@media (max-width: 1024px) {
    .main-grid {
        grid-template-columns: 1fr !important;
    }

    .form-section {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        max-height: 40vh;
        box-shadow: inset 0 -1px 0 var(--border-color);
    }

    .resize-handle {
        display: none;
    }

    .viewer-section {
        height: 60vh;
    }

    .viewer-section #canvas3D {
        height: 100%;
    }

    .properties-panel {
        width: 320px;
        max-height: 60px;
        overflow: hidden;
    }

    .properties-panel.expanded {
        max-height: calc(100% - 40px);
        overflow-y: auto;
    }
}

/* Scrollbar styling */
.form-section::-webkit-scrollbar,
.properties-panel::-webkit-scrollbar {
    width: 8px;
}

.form-section::-webkit-scrollbar-track,
.properties-panel::-webkit-scrollbar-track {
    background: transparent;
}

.form-section::-webkit-scrollbar-thumb,
.properties-panel::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.form-section::-webkit-scrollbar-thumb:hover,
.properties-panel::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* Loading spin */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(37, 99, 235, 0.2);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
