:root {
    /* Color Palette */
    --form-bg: #ffffff;
    --text-color: #333333;
    --light-text: #666666;

    /* Border Colors */
    --border-color: #e0e0e0;
    --border-dark: #d0d0d0;

    /* Interactive States */
    --focus-color: #4a6fa5;
    --focus-glow: rgba(74, 111, 165, 0.08);

    /* Spacing Scale */
    --spacing-xs: 0.5rem;
    --spacing-sm: 0.75rem;
    --spacing-md: 1.25rem;
    --spacing-lg: 1.75rem;

    /* Visual Properties */
    --soft-radius: 6px;
    --shadow-light: 0 2px 8px rgba(0, 0, 0, 0.04);
    --transition-speed: 0.2s;
}

/* ==========================================================================
   BASE RESET & UTILITIES
   ========================================================================== */

/* Text Utilities */
.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.text-right {
    text-align: right;
}

/* Spacing Utilities */
.p-xs {
    padding: var(--spacing-xs);
}

.p-sm {
    padding: var(--spacing-sm);
}

.p-md {
    padding: var(--spacing-md);
}

.p-lg {
    padding: var(--spacing-lg);
}

.m-xs {
    margin: var(--spacing-xs);
}

.m-sm {
    margin: var(--spacing-sm);
}

.m-md {
    margin: var(--spacing-md);
}

.m-lg {
    margin: var(--spacing-lg);
}

.mt-xs {
    margin-top: var(--spacing-xs);
}

.mt-sm {
    margin-top: var(--spacing-sm);
}

.mt-md {
    margin-top: var(--spacing-md);
}

.mt-lg {
    margin-top: var(--spacing-lg);
}

.mb-xs {
    margin-bottom: var(--spacing-xs);
}

.mb-sm {
    margin-bottom: var(--spacing-sm);
}

.mb-md {
    margin-bottom: var(--spacing-md);
}

.mb-lg {
    margin-bottom: var(--spacing-lg);
}

.full-width {
    width: 100%;
}

/* ==========================================================================
   UNIVERSAL GRID SYSTEM
   ========================================================================== */

/* Grid Containers */
.grid {
    display: grid;
    gap: var(--spacing-md);
    width: 100%;
}

/* Grid Template Columns */
.grid-1 {
    grid-template-columns: 1fr;
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

.grid-5 {
    grid-template-columns: repeat(5, 1fr);
}

.grid-6 {
    grid-template-columns: repeat(6, 1fr);
}

.grid-12 {
    grid-template-columns: repeat(12, 1fr);
}

/* Grid Gaps */
.gap-xs {
    gap: var(--spacing-xs);
}

.gap-sm {
    gap: var(--spacing-sm);
}

.gap-md {
    gap: var(--spacing-md);
}

.gap-lg {
    gap: var(--spacing-lg);
}

.gap-xl {
    gap: 2.5rem;
}

/* Column Spans */
.col-span-1 {
    grid-column: span 1;
}

.col-span-2 {
    grid-column: span 2;
}

.col-span-3 {
    grid-column: span 3;
}

.col-span-4 {
    grid-column: span 4;
}

.col-span-5 {
    grid-column: span 5;
}

.col-span-6 {
    grid-column: span 6;
}

.col-span-7 {
    grid-column: span 7;
}

.col-span-8 {
    grid-column: span 8;
}

.col-span-9 {
    grid-column: span 9;
}

.col-span-10 {
    grid-column: span 10;
}

.col-span-11 {
    grid-column: span 11;
}

.col-span-12 {
    grid-column: span 12;
}

.col-span-full {
    grid-column: 1 / -1;
}

/* Row Spans */
.row-span-1 {
    grid-row: span 1;
}

.row-span-2 {
    grid-row: span 2;
}

.row-span-3 {
    grid-row: span 3;
}

.row-span-full {
    grid-row: 1 / -1;
}

/* Grid Alignment */
.items-start {
    align-items: start;
}

.items-center {
    align-items: center;
}

.items-end {
    align-items: end;
}

.items-stretch {
    align-items: stretch;
}

.justify-start {
    justify-content: start;
}

.justify-center {
    justify-content: center;
}

.justify-end {
    justify-content: end;
}

.justify-between {
    justify-content: space-between;
}

.justify-around {
    justify-content: space-around;
}

.self-start {
    align-self: start;
}

.self-center {
    align-self: center;
}

.self-end {
    align-self: end;
}

.self-stretch {
    align-self: stretch;
}

/* Grid Auto Utilities */
.grid-auto-flow-row {
    grid-auto-flow: row;
}

.grid-auto-flow-col {
    grid-auto-flow: column;
}

.grid-auto-rows {
    grid-auto-rows: auto;
}

.grid-auto-cols {
    grid-auto-columns: auto;
}

/* ==========================================================================
   LAYOUT COMPONENTS
   ========================================================================== */

/* Panel Component */
.panel {
    background-color: var(--form-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--soft-radius);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-light);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid var(--border-color);
}

.panel-title {
    font-weight: 500;
    color: var(--text-color);
    font-size: 1.1rem;
}

/* Content Block */
.content-block {
    background-color: var(--form-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--soft-radius);
    padding: var(--spacing-md);
}

/* ==========================================================================
   FORM GRID SYSTEM
   ========================================================================== */

/* Form Layout */
.form-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: var(--spacing-md);
    width: 100%;
}

.form-section {
    background-color: var(--form-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--soft-radius);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-light);
    margin-bottom: var(--spacing-md);
}

.section-title {
    font-weight: 500;
    color: var(--text-color);
    font-size: 1.1rem;
    margin-bottom: var(--spacing-md);
}

/* Form Columns */
.fcol-1 {
    grid-column: span 1;
}

.fcol-2 {
    grid-column: span 2;
}

.fcol-3 {
    grid-column: span 3;
}

.fcol-4 {
    grid-column: span 4;
}

.fcol-5 {
    grid-column: span 5;
}

.fcol-6 {
    grid-column: span 6;
}

.fcol-7 {
    grid-column: span 7;
}

.fcol-8 {
    grid-column: span 8;
}

.fcol-9 {
    grid-column: span 9;
}

.fcol-10 {
    grid-column: span 10;
}

.fcol-11 {
    grid-column: span 11;
}

.fcol-12 {
    grid-column: span 12;
}

/* Form Field Base */
.form-field {
    display: flex;
    flex-direction: column;
    margin-bottom: var(--spacing-md);
}

.form-field label {
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--light-text);
    margin-bottom: 0.4rem;
}

/* Form Inputs */
.form-field input[type="text"],
.form-field input[type="email"],
.form-field input[type="tel"],
.form-field input[type="password"],
.form-field input[type="number"],
.form-field input[type="date"],
.form-field input[type="time"],
.form-field input[type="url"],
.form-field input[type="search"],
.form-field select,
.form-field textarea {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--soft-radius);
    background-color: #fff;
    color: var(--text-color);
    font-size: 1rem;
    font-family: inherit;
    transition: all var(--transition-speed) ease;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    outline: none;
    border-color: var(--focus-color);
    box-shadow: 0 0 0 3px var(--focus-glow);
}

/* Form Field Helpers */
.field-hint {
    font-size: 0.8rem;
    color: var(--light-text);
    margin-top: 0.25rem;
}

.field-error {
    font-size: 0.8rem;
    color: #c44;
    margin-top: 0.25rem;
}

.inline-fields {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
}

/* ==========================================================================
   FORM CONTROLS
   ========================================================================== */

/* Checkbox & Radio Groups */
.checkbox-group,
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 0.5rem;
}

.checkbox-item,
.radio-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.checkbox-item input[type="checkbox"],
.radio-item input[type="radio"] {
    width: 1.2rem;
    height: 1.2rem;
    cursor: pointer;
}

.checkbox-item label,
.radio-item label {
    font-size: 0.95rem;
    color: var(--text-color);
    cursor: pointer;
    margin-bottom: 0;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 3.5rem;
    height: 1.75rem;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #e0e0e0;
    border-radius: 2rem;
    transition: .4s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 1.4rem;
    width: 1.4rem;
    left: 0.2rem;
    bottom: 0.2rem;
    background-color: white;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: .4s;
}

input:checked+.toggle-slider {
    background-color: #a0a0a0;
}

input:checked+.toggle-slider:before {
    transform: translateX(1.7rem);
}

input:focus+.toggle-slider {
    box-shadow: 0 0 0 3px var(--focus-glow);
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
}

/* File Upload */
.file-upload {
    position: relative;
    display: inline-block;
    width: 100%;
}

.file-upload input[type="file"] {
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.file-upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    border: 2px dashed var(--border-color);
    border-radius: var(--soft-radius);
    background-color: #fcfcfc;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
}

.file-upload-label:hover {
    border-color: var(--border-dark);
    background-color: #f8f8f8;
}

.file-upload-label:has(input:focus) {
    border-color: var(--focus-color);
    box-shadow: 0 0 0 3px var(--focus-glow);
}

.file-upload-icon {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    opacity: 0.6;
}

.file-upload-text {
    font-size: 0.9rem;
    color: var(--light-text);
}

.file-upload-hint {
    font-size: 0.8rem;
    color: var(--light-text);
    margin-top: 0.5rem;
}

/* Range Slider */
.range-slider {
    width: 100%;
    padding: 0.5rem 0;
}

.range-slider input[type="range"] {
    width: 100%;
    height: 0.25rem;
    background: #e0e0e0;
    border-radius: 0.25rem;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.range-slider input[type="range"]::-webkit-slider-thumb {
    width: 1.25rem;
    height: 1.25rem;
    background: #fff;
    border: 2px solid #a0a0a0;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    -webkit-appearance: none;
    appearance: none;
}

.range-slider input[type="range"]:focus::-webkit-slider-thumb {
    border-color: var(--focus-color);
    box-shadow: 0 0 0 3px var(--focus-glow);
}

.range-slider-value {
    font-size: 0.9rem;
    color: var(--light-text);
    text-align: center;
    margin-top: 0.5rem;
}

/* Form Actions */
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-lg);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--border-color);
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */

@media (max-width: 1200px) {
    .grid-5 {
        grid-template-columns: repeat(4, 1fr);
    }

    .grid-6 {
        grid-template-columns: repeat(3, 1fr);
    }

    .grid-12 {
        grid-template-columns: repeat(6, 1fr);
    }

    .fcol-1,
    .fcol-2,
    .fcol-3,
    .fcol-4 {
        grid-column: span 6;
    }
}

@media (max-width: 900px) {
    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-4,
    .grid-5,
    .grid-6 {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-12 {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 768px) {

    .grid-2,
    .grid-3,
    .grid-4,
    .grid-5,
    .grid-6 {
        grid-template-columns: 1fr;
    }

    .grid-12 {
        grid-template-columns: repeat(2, 1fr);
    }

    .form-grid {
        gap: var(--spacing-sm);
    }

    .form-section {
        padding: var(--spacing-md);
    }

    .panel {
        padding: var(--spacing-md);
    }

    .form-actions {
        flex-direction: column;
    }

    .inline-fields {
        flex-direction: column;
        gap: 0.5rem;
    }

    .fcol-1,
    .fcol-2,
    .fcol-3,
    .fcol-4,
    .fcol-5,
    .fcol-6 {
        grid-column: span 12;
    }

    /* Stack wide columns on mobile */
    .col-span-2,
    .col-span-3,
    .col-span-4,
    .col-span-5,
    .col-span-6,
    .col-span-7,
    .col-span-8,
    .col-span-9,
    .col-span-10,
    .col-span-11 {
        grid-column: 1 / -1;
    }
}

@media (max-width: 480px) {
    .grid-12 {
        grid-template-columns: 1fr;
    }

    .form-field {
        margin-bottom: var(--spacing-sm);
    }

    .form-section {
        padding: var(--spacing-sm);
    }
}