/* ========================================
   FORMS - Form Elements
   ========================================
   Sections:
   1. Base inputs (.form-control, .form-select)
   2. Input with label (.input-label)
   3. Checkbox & Switch
   4. Custom dropdown
   5. Range slider
   6. Validation
   7. Input groups
   8. Tooltips
   ======================================== */

/* Global form variables */
:root {
    --input-label-surface: var(--color-bg-card);
    --input-height: 54px; /* 56px = standard, 54px = current, 52px = medium, 48px = compact */
}

/* ========================================
   1. BASE INPUTS
   ======================================== */

.form-control,
.form-select,
.form-input {
    display: block;
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    font-family: inherit;
    background: var(--color-bg-input);
    color: var(--color-text);
    transition: border-color var(--transition-fast);
}

.form-control:focus,
.form-select:focus,
.form-input:focus {
    border-color: var(--color-border-focus);
    box-shadow: none;
    outline: none;
}

.form-control::placeholder,
.form-input::placeholder {
    color: var(--color-text-secondary);
}

/* Autofill override */
.form-control:-webkit-autofill,
.form-control:-webkit-autofill:hover,
.form-control:-webkit-autofill:focus,
.form-input:-webkit-autofill,
.form-input:-webkit-autofill:hover,
.form-input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 30px var(--color-bg-input) inset;
    -webkit-text-fill-color: var(--color-text);
    transition: background-color 5000s ease-in-out 0s;
}

/* Textarea */
textarea.form-control {
    min-height: 120px;
    resize: vertical;
}

/* Select dropdown arrow */
select.form-select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%239494a8' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 16px 12px;
    padding-right: 2.5rem;
    cursor: pointer;
}


/* ========================================
   2. INPUT WITH LABEL
   ======================================== */

.input-label {
    position: relative;
    margin-bottom: 1.5rem;
    --input-label-surface: var(--color-bg-card);
}

.input-label:first-child {
    margin-top: 0.5rem;
}

.input-label:last-child {
    margin-bottom: 0;
}

.input-label .form-control,
.input-label .form-select {
    height: var(--input-height);
    padding: 1rem;
    background: var(--input-label-surface);
}

/* Color input preview uses var(--input-label-surface) from base style */

.input-label-text {
    position: absolute;
    top: 0;
    left: 0.75rem;
    transform: translateY(-50%);
    background: var(--input-label-surface);
    padding: 0 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    pointer-events: none;
    z-index: 1;
}

/* Label follows input validation state */
.input-label:has(.form-control.is-warning) .input-label-text,
.input-label:has(.form-select.is-warning) .input-label-text,
.input-label.is-warning .input-label-text {
    color: var(--color-warning);
}

.input-label:has(.form-control.is-error) .input-label-text,
.input-label:has(.form-select.is-error) .input-label-text,
.input-label.is-error .input-label-text {
    color: var(--color-error);
}

/* Label on page background */
.input-label.on-page {
    --input-label-surface: var(--color-bg-page);
}

.input-label .form-control:-webkit-autofill,
.input-label .form-control:-webkit-autofill:hover,
.input-label .form-control:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 30px var(--input-label-surface) inset;
}

.input-label-inline {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    column-gap: 0.75rem;
    row-gap: 1.4rem;
    align-items: start;
}

.input-label-inline-item {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.input-label-inline-item .input-label,
.input-label-inline-item .dropdown-floating {
    margin: 0;
}

/* Dropdown menu stays with card background */
.input-label-inline .dropdown-custom-menu {
    background: var(--color-bg-card);
}

.input-label-inline-item .form-control,
.input-label-inline-item .form-select,
.input-label-inline-item .dropdown-custom-toggle,
.input-label-inline-item .dropdown-selected,
.input-label-inline-item .pay-id-input,
.input-label-inline-item .color-picker-shell,
.input-label-inline-item .color-input-preview,
.input-label-inline-item .datetime-display,
.input-label-inline-item .checkbox-setting-box,
.input-label-inline-item .switch-setting-box {
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

/* These elements now use var(--input-label-surface) from base styles */

.input-label-inline-item .input-label:hover .form-control,
.input-label-inline-item .input-label:hover .form-select,
.input-label-inline-item .input-label:hover .dropdown-custom-toggle,
.input-label-inline-item .input-label:hover .dropdown-selected,
.input-label-inline-item .input-label:hover .pay-id-input,
.input-label-inline-item .input-label:hover .color-picker-shell,
.input-label-inline-item .input-label:hover .color-input-preview,
.input-label-inline-item .input-label:hover .datetime-display,
.input-label-inline-item .input-label:hover .checkbox-setting-box,
.input-label-inline-item .input-label:hover .switch-setting-box {
    border-color: var(--color-brand-primary);
    box-shadow: none;
}

.input-label-inline-item .input-label:hover .form-control.is-warning,
.input-label-inline-item .input-label:hover .form-select.is-warning,
.input-label-inline-item .input-label:hover .dropdown-custom-toggle.is-warning,
.input-label-inline-item .input-label:hover .dropdown-selected.is-warning {
    border-color: var(--color-warning);
}

.input-label-inline-item .input-label:hover .form-control.is-error,
.input-label-inline-item .input-label:hover .form-select.is-error,
.input-label-inline-item .input-label:hover .dropdown-custom-toggle.is-error,
.input-label-inline-item .input-label:hover .dropdown-selected.is-error {
    border-color: var(--color-error);
}

.input-embedded-dropdown {
    width: 100%;
}

.input-with-icon-shell {
    position: relative;
}

.input-with-icon-shell .form-control-icon {
    padding-right: 3.5rem;
    font-size: 0.95rem;
    font-weight: 400;
    line-height: normal;
    font-family: inherit;
}

.input-inline-icon-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition-fast), background var(--transition-fast);
}

.input-inline-icon-btn:hover {
    background-color: var(--color-bg-card-hover);
    color: var(--color-text);
}

.input-inline-icon-btn svg {
    width: 18px;
    height: 18px;
}

/* DateTime Display (date + time combined) */
.datetime-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--input-height);
    padding: 0 1rem;
    background: var(--input-label-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

.datetime-display:hover {
    border-color: var(--color-border-focus);
}

.datetime-date,
.datetime-time {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    font-family: inherit;
    font-weight: 400;
    color: var(--color-text);
}

.datetime-date svg,
.datetime-time svg {
    width: 18px;
    height: 18px;
    color: var(--color-text-secondary);
    flex-shrink: 0;
}

.color-picker-shell {
    height: var(--input-height);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg-card);
    padding: 0 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.color-input {
    -webkit-appearance: none;
    appearance: none;
    width: 34px;
    height: 34px;
    border: none;
    padding: 0;
    background: transparent;
    cursor: pointer;
    border-radius: 999px;
    overflow: hidden;
    flex-shrink: 0;
}

.color-input::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-input::-webkit-color-swatch {
    border: 1px solid var(--color-border);
    border-radius: 999px;
}

.color-input::-moz-color-swatch {
    border: 1px solid var(--color-border);
    border-radius: 999px;
}

.color-value {
    font-size: 0.95rem;
    color: var(--color-text);
    font-family: 'SF Mono', 'Fira Code', monospace;
    letter-spacing: 0.02em;
}

/* Color Input with Preview */
.color-input-preview {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    height: var(--input-height);
    padding: 0 1rem;
    background: var(--input-label-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast);
    cursor: pointer;
}

.color-input-preview:hover,
.color-input-preview:focus-within {
    border-color: var(--color-border-focus);
}

.color-input-hash {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.95rem;
    color: var(--color-text-secondary);
    user-select: none;
}

.color-input-text {
    flex: 1;
    background: transparent;
    border: none;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.95rem;
    color: var(--color-text);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    outline: none;
    width: 70px;
    min-width: 0;
}

.color-input-swatch {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    background: var(--swatch-color, var(--color-brand-primary));
    border: 1px solid var(--color-border);
    flex-shrink: 0;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.color-input-swatch:hover {
    transform: scale(1.05);
    box-shadow: 0 0 8px var(--swatch-color, var(--color-brand-primary));
}

.color-input-swatch-demo-accent {
    --swatch-color: #a381f0;
}

.checkbox-setting-box,
.switch-setting-box {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg-card);
    padding: 0.875rem 1rem;
    display: block;
    cursor: pointer;
}

.checkbox-setting-box {
    display: flex;
    align-items: center;
    height: var(--input-height);
}

.switch-setting-box {
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: var(--input-height);
    padding: 0 1rem;
}

.checkbox-setting-box .form-check {
    margin: 0;
}

.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
}

.switch-row-title {
    font-size: 0.95rem;
    font-weight: 400;
    line-height: 1.2;
    color: var(--color-text);
    white-space: nowrap;
}

.switch-frame-control.form-check.form-switch {
    padding-left: 0;
    margin: 0;
    height: 40px;
    line-height: 0;
    display: inline-flex;
    align-items: center;
}

.switch-frame-control.form-check.form-switch .form-check-input {
    width: 40px;
    height: 22px;
    margin: 0;
    border-radius: 22px;
    align-self: center;
}

.input-element-name {
    display: inline-block;
    align-self: center;
    background: transparent;
    border: none;
    padding: 0;
    text-align: center;
    font-size: 0.72rem;
    line-height: 1.25;
    color: var(--color-text-secondary);
    font-family: 'SF Mono', 'Fira Code', monospace;
    text-decoration: none;
    cursor: pointer;
    transition: color var(--transition-fast), text-decoration-color var(--transition-fast);
}

.input-element-name:hover {
    color: var(--color-brand-primary);
    text-decoration: underline;
    text-decoration-color: var(--color-brand-primary-50);
    text-underline-offset: 0.2em;
}

.input-element-name.copied {
    color: var(--color-success);
    text-decoration-color: var(--color-success-40);
}

.form-control:disabled {
    color: var(--color-text-disabled);
    border-color: var(--color-border);
    cursor: not-allowed;
    opacity: 0.7;
}


/* ========================================
   3. CHECKBOX & SWITCH
   ======================================== */

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.form-check-input {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    min-width: 18px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg-input);
    cursor: pointer;
    transition: all var(--transition-fast);
    margin: 0;
}

.form-check-input:checked {
    background-color: var(--color-brand-primary);
    border-color: var(--color-brand-primary);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10l3 3l6-6'/%3e%3c/svg%3e");
    background-size: 14px;
    background-position: center;
    background-repeat: no-repeat;
}

.form-check-input:focus {
    outline: none;
    border-color: var(--color-brand-primary);
}

.form-check-label {
    cursor: pointer;
    color: var(--color-text);
}

/* Switch */
.form-switch {
    display: flex;
    align-items: center;
    padding-left: 3rem;
    position: relative;
}

.form-switch .form-check-input {
    width: 40px;
    height: 22px;
    margin-left: -3rem;
    border-radius: 22px;
    border: none;
    background: var(--color-border) url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e") no-repeat left center / contain;
    transition: background-position var(--transition-fast), background-color var(--transition-fast);
}

.form-switch .form-check-input:checked {
    background: var(--color-brand-primary) url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e") no-repeat right center / contain;
}


/* ========================================
   4. CUSTOM DROPDOWN
   ======================================== */

.dropdown-custom {
    position: relative;
}

.dropdown-custom-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--input-label-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-size: 0.95rem;
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

.dropdown-custom-toggle:hover,
.dropdown-custom.open .dropdown-custom-toggle {
    border-color: var(--color-brand-primary);
}

.dropdown-custom-toggle.is-warning,
.dropdown-custom-toggle.is-warning:hover,
.dropdown-custom.open .dropdown-custom-toggle.is-warning {
    border-color: var(--color-warning);
}

.dropdown-custom-toggle.is-error,
.dropdown-custom-toggle.is-error:hover,
.dropdown-custom.open .dropdown-custom-toggle.is-error {
    border-color: var(--color-error);
}

.dropdown-custom-toggle::after {
    content: '';
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%239494a8' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-size: contain;
    background-repeat: no-repeat;
    transition: transform var(--transition-fast);
}

.dropdown-custom.open .dropdown-custom-toggle::after {
    transform: rotate(180deg);
}

.dropdown-custom-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--color-bg-card);
    border: none;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    display: none;
    max-height: 90vh;
    overflow-y: auto;
}

.dropdown-custom.open .dropdown-custom-menu {
    display: block;
}

.dropdown-custom.dropdown-open-up .dropdown-custom-menu {
    top: auto;
    bottom: calc(100% + 4px);
}

/* Disabled dropdown */
.dropdown-custom.disabled {
    opacity: 0.7;
    pointer-events: none;
}

.dropdown-custom.disabled .dropdown-custom-toggle {
    cursor: not-allowed;
    background: var(--input-label-surface);
}

.dropdown-custom-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    padding: 0.4rem 2rem 0.4rem 1rem;
    color: var(--color-text);
    font-size: 0.95rem;
    cursor: pointer;
    transition: background var(--transition-fast);
    border-radius: 0;
}

.dropdown-custom-item:hover,
.dropdown-custom-item.selected {
    background: var(--color-bg-card-hover);
}

.dropdown-custom-item::after {
    content: '';
    position: absolute;
    right: 0.85rem;
    top: 50%;
    width: 6px;
    height: 10px;
    border-right: 2px solid transparent;
    border-bottom: 2px solid transparent;
    transform: translateY(-60%) rotate(45deg);
}

.dropdown-custom-item.selected::after {
    border-right-color: var(--color-brand-primary);
    border-bottom-color: var(--color-brand-primary);
}

/* Floating label dropdown */
.dropdown-floating {
    margin-bottom: 1.5rem;
}

.dropdown-floating:first-child {
    margin-top: 0.5rem;
}

.dropdown-floating:last-child {
    margin-bottom: 0;
}

.input-label-inline-item .dropdown-floating,
.input-label-inline-item .dropdown-floating:first-child,
.input-label-inline-item .dropdown-floating:last-child {
    margin-top: 0;
    margin-bottom: 0;
}

.dropdown-floating .dropdown-custom-toggle {
    height: var(--input-height);
    padding: 1rem;
}

.dropdown-floating-label {
    position: absolute;
    top: 0;
    left: 0.75rem;
    transform: translateY(-50%);
    background: var(--input-label-surface);
    padding: 0 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    pointer-events: none;
    z-index: 1;
}

.dropdown-floating-label.is-warning {
    color: var(--color-warning);
}

.dropdown-floating-label.is-error {
    color: var(--color-error);
}

/* Dropdown with icons */
.dropdown-select {
    position: relative;
}

.dropdown-selected {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    height: var(--input-height);
    padding: 0 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    background: var(--input-label-surface);
}

.dropdown-selected:hover {
    border-color: var(--color-brand-primary);
}

.dropdown-select.open .dropdown-selected {
    border-color: var(--color-brand-primary);
}

.dropdown-selected-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dropdown-selected-icon img {
    width: 24px;
    height: 24px;
}

.dropdown-selected-text {
    flex: 1;
}

.dropdown-selected-name {
    font-weight: 500;
    font-size: 1rem;
    color: var(--color-text);
}

.dropdown-arrow {
    width: 16px;
    height: 16px;
    color: var(--color-text-secondary);
    transition: transform var(--transition-fast);
}

.dropdown-select.open .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-select .dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--color-bg-card);
    border: none;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    display: none;
    max-height: 90vh;
    overflow-y: auto;
}

.dropdown-select.open .dropdown-menu {
    display: block;
}

.dropdown-select .dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.4rem 1rem;
    cursor: pointer;
    transition: background-color var(--transition-fast);
    color: var(--color-text);
    border-radius: 4px;
}

.dropdown-select .dropdown-item:hover,
.dropdown-select .dropdown-item.active {
    background: var(--color-bg-card-hover);
}

.dropdown-item-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dropdown-item-icon img {
    width: 24px;
    height: 24px;
}

.dropdown-item-name {
    font-weight: 500;
    flex: 1;
}


/* ========================================
   5. RANGE SLIDER
   ======================================== */

.range-showcase-box {
    padding-bottom: 1.9rem;
}

.range-showcase {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.range-row {
    display: grid;
    gap: 0.75rem;
    align-items: start;
}

.range-row-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.range-row-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.range-row-1 {
    grid-template-columns: 1fr;
}

.range-input-label {
    margin: 0;
    --input-label-surface: var(--color-bg-card);
    --range-fill: var(--color-brand-primary);
    --range-track-size: 8px;
    --range-thumb-size: 18px;
    --range-thumb-radius: 999px;
    --range-thumb-shadow: 0 0 0 3px var(--color-brand-primary-20);
}

.range-input-label .input-label-text {
    background: var(--input-label-surface);
}

.range-input-label .range-value-label {
    position: absolute;
    top: 0;
    right: 0.75rem;
    transform: translateY(-50%);
    background: var(--input-label-surface);
    padding: 0 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--range-fill);
    line-height: 1;
    pointer-events: none;
    z-index: 1;
}

.range-control {
    display: grid;
    grid-template-columns: 1.75rem minmax(0, 1fr) 2.25rem;
    column-gap: 0;
    align-items: center;
    height: var(--input-height);
    box-sizing: border-box;
    padding: 0 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--input-label-surface);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input-label-inline-item .range-input-label:hover .range-control {
    border-color: var(--range-fill);
}

.range-input {
    grid-column: 2;
    grid-row: 1;
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: var(--range-track-size);
    border-radius: 999px;
    outline: none;
    cursor: pointer;
    background: linear-gradient(
        90deg,
        var(--range-fill) 0%,
        var(--range-fill) var(--range-value, 0%),
        var(--color-border) var(--range-value, 0%),
        var(--color-border) 100%
    );
    transition: filter var(--transition-fast), box-shadow var(--transition-fast);
}

.range-input:hover {
    filter: brightness(1.08);
}

.range-input:focus-visible {
    box-shadow: 0 0 0 2px var(--range-fill);
}

.range-input::-webkit-slider-runnable-track {
    height: var(--range-track-size);
    border-radius: 999px;
    background: transparent;
}

.range-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: var(--range-thumb-size);
    height: var(--range-thumb-size);
    margin-top: calc((var(--range-track-size) - var(--range-thumb-size)) / 2);
    border: 2px solid var(--input-label-surface);
    border-radius: var(--range-thumb-radius);
    background: var(--range-fill);
    box-shadow: var(--range-thumb-shadow);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.range-input:hover::-webkit-slider-thumb {
    transform: scale(1.06);
}

.range-input::-moz-range-track {
    height: var(--range-track-size);
    border: none;
    border-radius: 999px;
    background: var(--color-border);
}

.range-input::-moz-range-progress {
    height: var(--range-track-size);
    border-radius: 999px;
    background: var(--range-fill);
}

.range-input::-moz-range-thumb {
    width: var(--range-thumb-size);
    height: var(--range-thumb-size);
    border: 2px solid var(--input-label-surface);
    border-radius: var(--range-thumb-radius);
    background: var(--range-fill);
    box-shadow: var(--range-thumb-shadow);
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.range-input:hover::-moz-range-thumb {
    transform: scale(1.06);
}

.range-meta {
    display: contents;
}

.range-min,
.range-max {
    grid-row: 1;
    font-size: 0.74rem;
    font-family: 'SF Mono', 'Fira Code', monospace;
    color: var(--color-text-secondary);
    line-height: 1;
}

.range-min {
    grid-column: 1;
    justify-self: center;
    text-align: center;
}

.range-max {
    grid-column: 3;
    justify-self: center;
    text-align: center;
}

.range-value {
    color: var(--range-fill);
    font-weight: 600;
    font-size: 0.78rem;
    display: none;
}

.range-variant-purple {
    --range-fill: var(--color-brand-primary);
    --range-thumb-shadow: 0 0 0 3px var(--color-brand-primary-20);
}

.range-variant-teal {
    --range-fill: var(--color-brand-secondary);
    --range-thumb-shadow: 0 0 0 3px var(--color-brand-secondary-25);
}

.range-variant-green {
    --range-fill: var(--color-success);
    --range-thumb-shadow: 0 0 0 3px var(--color-success-25);
}

.range-variant-red {
    --range-fill: var(--color-error);
    --range-thumb-shadow: 0 0 0 3px var(--color-error-25);
}

.range-variant-yellow {
    --range-fill: var(--color-warning);
    --range-thumb-shadow: 0 0 0 3px var(--color-warning-25);
}

.range-variant-blue {
    --range-fill: var(--color-info);
    --range-thumb-shadow: 0 0 0 3px var(--color-info-25);
}

.range-variant-muted {
    --range-fill: var(--color-muted);
    --range-thumb-shadow: 0 0 0 3px var(--color-muted-25);
}

.range-variant-secondary {
    --range-fill: var(--color-text-secondary);
    --range-thumb-shadow: 0 0 0 3px var(--color-brand-primary-15);
}

.range-variant-square {
    --range-thumb-radius: var(--radius-sm);
    --range-thumb-size: 20px;
}

.range-variant-fat {
    --range-track-size: 12px;
    --range-thumb-size: 22px;
}

.range-variant-neon {
    --range-track-size: 10px;
    --range-thumb-size: 20px;
    --range-thumb-shadow: 0 0 0 3px var(--color-success-25), 0 0 14px var(--color-success-40);
}

.range-variant-neon .range-control {
    box-shadow: inset 0 0 0 1px var(--color-success-25), 0 0 20px var(--color-success-10);
}


/* ========================================
   6. VALIDATION
   ======================================== */

.form-control.is-valid {
    border-color: var(--color-success);
}

.form-control.is-warning {
    border-color: var(--color-warning);
}

.form-control.is-warning:focus,
.form-select.is-warning:focus {
    border-color: var(--color-warning);
}

.form-control.is-error {
    border-color: var(--color-error);
}

.form-control.is-error:focus,
.form-select.is-error:focus {
    border-color: var(--color-error);
}

.validation-message {
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

.validation-message.success {
    color: var(--color-success);
}

.validation-message.warning {
    color: var(--color-warning);
}

.validation-message.error {
    color: var(--color-error);
}

.validation-inline {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.validation-inline-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.validation-inline-item .input-label {
    margin: 0;
}

.validation-inline-item .validation-message {
    margin-top: 0;
    min-height: 1.25rem;
    text-align: center;
}

.validation-states-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
}

.validation-demo-divider-wide {
    width: 100%;
    margin: 0.5rem 0;
    border-top: 1px dashed var(--color-border);
    opacity: 0.85;
}

.validation-demo-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
}

.validation-demo-item {
    display: flex;
    flex-direction: column;
}

.validation-demo-form {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.validation-demo-form .input-label {
    width: 100%;
    margin-bottom: 0;
}

.validation-demo-submit {
    font-size: 0.85rem;
    padding: 0.4rem 0.8rem;
    margin-bottom: 0.5rem;
    align-self: center;
}

.validation-demo-code {
    margin-top: 0;
    align-self: center;
}

.validation-hover-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.validation-hover-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.validation-label-valid .input-label-text {
    color: var(--color-success);
}

.validation-label-warning .input-label-text {
    color: var(--color-warning);
}

.validation-label-error .input-label-text {
    color: var(--color-error);
}

/* ========================================
   7. INPUT GROUPS
   ======================================== */

.input-row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.input-row .input-label {
    flex: 1;
    margin: 0;
    min-width: 0;
}

.input-row .dropdown-floating {
    flex: 1;
    margin: 0;
}

.input-row .input-row-submit {
    height: var(--input-height);
    flex-shrink: 0;
    padding: 0 1.25rem;
    margin: 0;
    box-sizing: border-box;
    border-radius: var(--radius-md);
}

/* Input with icon button */
.input-icon-group {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.input-icon-group .input-label {
    flex: 1;
    margin: 0;
    min-width: 0;
}

.input-icon-group .input-icon-action {
    height: var(--input-height);
    width: 56px;
    flex-shrink: 0;
    border-radius: var(--radius-md);
}

.input-icon-group .input-icon-action svg {
    width: 22px;
    height: 22px;
}

/* Input group (addon style) */
.input-group {
    display: flex;
}

.input-group .form-control {
    border-radius: 0;
}

.input-group .form-control:first-child {
    border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.input-group .form-control:last-child {
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.input-group .btn {
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

@media (max-width: 1200px) {
    .input-label-inline {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .range-row-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .input-row {
        flex-wrap: wrap;
    }

    .input-row .input-label {
        flex: 1 1 100%;
    }

    .input-row .input-row-submit {
        width: 100%;
    }

    .input-label-inline {
        grid-template-columns: 1fr;
    }

    .range-row-4,
    .range-row-2 {
        grid-template-columns: 1fr;
    }

    .switch-row-title {
        font-size: 0.95rem;
        white-space: normal;
    }

    .validation-inline {
        grid-template-columns: 1fr;
    }
}


/* ========================================
   8. TOGGLE SWITCH (Compact)
   ======================================== */

/* Toggle switch for tables and compact UI */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    cursor: pointer;
}

.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: var(--color-border);
    transition: background-color var(--transition-fast), box-shadow var(--transition-fast);
    border-radius: 20px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: transform var(--transition-fast);
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--color-success);
}

.toggle-switch input:focus + .toggle-slider {
    box-shadow: 0 0 0 2px var(--color-success-25);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(16px);
}

/* Hover effect */
.toggle-switch:hover .toggle-slider {
    background-color: var(--color-border-light);
}

.toggle-switch:hover input:checked + .toggle-slider {
    background-color: var(--color-success-hover);
}

/* Disabled state */
.toggle-switch input:disabled + .toggle-slider {
    opacity: 0.5;
    cursor: not-allowed;
}


/* ========================================
   9. SPECIAL INPUTS
   ======================================== */

/* Pay ID / Copy input */
.pay-id-input {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--input-height);
    padding: 0 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--input-label-surface);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 400;
    color: var(--color-text);
}

.btn-copy {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-copy:hover {
    background-color: var(--color-bg-card-hover);
    color: var(--color-text);
}

.btn-copy svg {
    width: 18px;
    height: 18px;
}

.btn-copy.copied {
    color: var(--color-success);
}

/* Form helper text */
.form-text {
    color: var(--color-text-secondary);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}


/* ========================================
   LIGHT THEME OVERRIDES
   ======================================== */

/* Input labels - black and bold */
[data-theme="light"] .input-label-text {
    color: #000000;
    font-weight: 600;
}

[data-theme="light"] .dropdown-floating-label {
    color: #000000;
    font-weight: 600;
}

/* Input text - black */
[data-theme="light"] .form-control,
[data-theme="light"] .form-select {
    color: #000000;
    border-color: #e0e0e0;
    background: #ffffff;
}

[data-theme="light"] .form-control:focus,
[data-theme="light"] .form-select:focus {
    border-color: #000000;
    border-width: 2px;
}

[data-theme="light"] .form-control:hover,
[data-theme="light"] .form-select:hover,
[data-theme="light"] .input-label:hover .form-control,
[data-theme="light"] .input-label:hover .form-select {
    border-color: #000000;
    border-width: 2px;
}

/* Keep validation states in light theme (including focus/hover) */
[data-theme="light"] .form-control.is-warning,
[data-theme="light"] .form-select.is-warning,
[data-theme="light"] .form-control.is-warning:focus,
[data-theme="light"] .form-select.is-warning:focus,
[data-theme="light"] .input-label:hover .form-control.is-warning,
[data-theme="light"] .input-label:hover .form-select.is-warning {
    border-color: var(--color-warning);
    border-width: 2px;
    background: #fffdf0;
}

[data-theme="light"] .form-control.is-error,
[data-theme="light"] .form-select.is-error,
[data-theme="light"] .form-control.is-error:focus,
[data-theme="light"] .form-select.is-error:focus,
[data-theme="light"] .input-label:hover .form-control.is-error,
[data-theme="light"] .input-label:hover .form-select.is-error {
    border-color: var(--color-error);
    border-width: 2px;
    background: #fff6f7;
}

[data-theme="light"] .input-label:has(.form-control.is-warning) .input-label-text,
[data-theme="light"] .input-label:has(.form-select.is-warning) .input-label-text,
[data-theme="light"] .input-label.is-warning .input-label-text {
    background: #fff9d6;
    box-shadow: 0 0 0 1px rgba(228, 178, 0, 0.28);
    border-radius: 4px;
    z-index: 2;
}

[data-theme="light"] .input-label:has(.form-control.is-error) .input-label-text,
[data-theme="light"] .input-label:has(.form-select.is-error) .input-label-text,
[data-theme="light"] .input-label.is-error .input-label-text {
    background: #ffe9eb;
    box-shadow: 0 0 0 1px rgba(223, 78, 78, 0.2);
    border-radius: 4px;
    z-index: 2;
}

[data-theme="light"] .form-control::placeholder {
    color: #999999;
}

/* Dropdown toggle */
[data-theme="light"] .dropdown-custom-toggle {
    border-color: #e0e0e0;
    color: #000000;
}

[data-theme="light"] .dropdown-custom-toggle:hover,
[data-theme="light"] .dropdown-custom.open .dropdown-custom-toggle,
[data-theme="light"] .dropdown-custom-toggle:focus-visible {
    border-color: #000000;
    border-width: 2px;
}

[data-theme="light"] .dropdown-custom-toggle.is-warning,
[data-theme="light"] .dropdown-custom-toggle.is-warning:hover,
[data-theme="light"] .dropdown-custom.open .dropdown-custom-toggle.is-warning {
    border-color: var(--color-warning);
    border-width: 2px;
    background: #fffdf0;
}

[data-theme="light"] .dropdown-custom-toggle.is-error,
[data-theme="light"] .dropdown-custom-toggle.is-error:hover,
[data-theme="light"] .dropdown-custom.open .dropdown-custom-toggle.is-error {
    border-color: var(--color-error);
    border-width: 2px;
    background: #fff6f7;
}

[data-theme="light"] .dropdown-selected {
    border-color: #e0e0e0;
}

[data-theme="light"] .dropdown-selected:hover,
[data-theme="light"] .dropdown-select.open .dropdown-selected {
    border-color: #000000;
    border-width: 2px;
}

[data-theme="light"] .dropdown-floating-label.is-warning {
    color: var(--color-warning);
    background: #fff9d6;
    box-shadow: 0 0 0 1px rgba(228, 178, 0, 0.28);
    border-radius: 4px;
}

[data-theme="light"] .dropdown-floating-label.is-error {
    color: var(--color-error);
    background: #ffe9eb;
    box-shadow: 0 0 0 1px rgba(223, 78, 78, 0.2);
    border-radius: 4px;
}

/* Dropdown menu */
[data-theme="light"] .dropdown-custom-menu {
    background: #ffffff;
    border-color: #e0e0e0;
}

[data-theme="light"] .dropdown-custom-item {
    color: #000000;
}

[data-theme="light"] .dropdown-custom-item:hover,
[data-theme="light"] .dropdown-custom-item.selected {
    background: #f5f5f5;
}

[data-theme="light"] .dropdown-custom-item.selected::after {
    border-right-color: #000000;
    border-bottom-color: #000000;
}

/* Checkbox/Switch */
[data-theme="light"] .form-check-input:checked {
    background-color: #000000;
    border-color: #000000;
}

[data-theme="light"] .form-check-input:focus {
    border-color: #000000;
}

[data-theme="light"] .form-switch .form-check-input:checked {
    background-color: #000000;
}

/* Input label surface */
:root[data-theme="light"] {
    --input-label-surface: #ffffff;
}

[data-theme="light"] .input-label {
    --input-label-surface: #ffffff;
}

[data-theme="light"] .input-label.on-page {
    --input-label-surface: #ffffff;
}

/* All form element borders - light gray */
[data-theme="light"] .datetime-display,
[data-theme="light"] .pay-id-input,
[data-theme="light"] .color-input-preview,
[data-theme="light"] .color-picker-shell {
    border-color: #e0e0e0;
}

/* Dropdown-selected uses var(--input-label-surface) from base style */
[data-theme="light"] .dropdown-selected {
    border-color: #e0e0e0;
}

[data-theme="light"] .datetime-display:hover,
[data-theme="light"] .dropdown-selected:hover {
    border-color: #000000;
}

/* Checkbox/Switch boxes - white */
[data-theme="light"] .checkbox-setting-box,
[data-theme="light"] .switch-setting-box {
    background: #ffffff;
    border-color: #e0e0e0;
}

/* Dropdown with icons */
[data-theme="light"] .dropdown-select .dropdown-menu {
    background: #ffffff;
    border-color: #e0e0e0;
}

[data-theme="light"] .dropdown-select .dropdown-item {
    color: #000000;
}

[data-theme="light"] .dropdown-select .dropdown-item:hover,
[data-theme="light"] .dropdown-select .dropdown-item.active {
    background: #f5f5f5;
}

/* Range slider */
[data-theme="light"] .range-input-label {
    --input-label-surface: #ffffff;
}

[data-theme="light"] .range-control {
    background: #ffffff;
    border-color: #e0e0e0;
}
