/**
 * Ice Arena Design System - Forms v2
 * Modern form controls with polish and accessibility
 *
 * Features:
 * - Floating labels
 * - Smooth focus states
 * - Validation styling
 * - Custom select/checkbox/radio
 *
 * Version: 2.0
 * Date: November 2025
 */

/* =========================================
   FORM LAYOUT
   ========================================= */

.form-v2 {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
}

.form-row {
    display: flex;
    gap: var(--space-4);
}

.form-row > * {
    flex: 1;
}

.form-group {
    position: relative;
}

/* =========================================
   FORM LABELS
   ========================================= */

.form-label {
    display: block;
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--rink-700);
    margin-bottom: var(--space-2);
}

.form-label-required::after {
    content: ' *';
    color: var(--goal-red);
}

.form-label-optional::after {
    content: ' (optional)';
    font-weight: var(--font-normal);
    color: var(--text-muted);
    font-size: var(--text-xs);
}

/* =========================================
   BASE INPUT STYLES
   ========================================= */

.form-input,
.form-select,
.form-textarea,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
select,
textarea {
    display: block;
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-family: var(--font-body);
    font-size: var(--text-base);
    font-weight: var(--font-normal);
    line-height: var(--leading-normal);
    color: var(--text-primary);
    background-color: var(--surface-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    transition:
        border-color var(--duration-fast) var(--ease-out),
        box-shadow var(--duration-fast) var(--ease-out),
        background-color var(--duration-fast) var(--ease-out);
    appearance: none;
    -webkit-appearance: none;
}

.form-input::placeholder,
.form-textarea::placeholder,
input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
    opacity: 1;
}

/* Focus state */
.form-input:focus,
.form-select:focus,
.form-textarea:focus,
input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--ice-500);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
    background-color: var(--surface-primary);
}

/* Hover state */
.form-input:hover:not(:focus):not(:disabled),
.form-select:hover:not(:focus):not(:disabled),
.form-textarea:hover:not(:focus):not(:disabled) {
    border-color: var(--border-hover);
}

/* Disabled state */
.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled,
input:disabled,
select:disabled,
textarea:disabled {
    background-color: var(--surface-disabled);
    color: var(--text-disabled);
    cursor: not-allowed;
    opacity: 0.7;
}

/* Read-only state */
.form-input:read-only,
input:read-only,
textarea:read-only {
    background-color: var(--surface-secondary);
    cursor: default;
}

/* =========================================
   INPUT SIZES
   ========================================= */

.form-input-sm,
.input-sm {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
    border-radius: var(--radius-md);
}

.form-input-lg,
.input-lg {
    padding: var(--space-4) var(--space-5);
    font-size: var(--text-lg);
    border-radius: var(--radius-xl);
}

/* =========================================
   TEXTAREA
   ========================================= */

.form-textarea,
textarea {
    min-height: 120px;
    resize: vertical;
    line-height: var(--leading-relaxed);
}

.form-textarea-autosize {
    resize: none;
    overflow: hidden;
}

/* =========================================
   SELECT
   ========================================= */

.form-select,
select {
    padding-right: var(--space-10);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='%2364748b'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--space-3) center;
    background-size: 20px;
    cursor: pointer;
}

.form-select:focus,
select:focus {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='%2338bdf8'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'/%3E%3C/svg%3E");
}

/* Multiple select */
.form-select[multiple],
select[multiple] {
    padding-right: var(--space-4);
    background-image: none;
    height: auto;
}

/* =========================================
   FLOATING LABELS
   ========================================= */

.form-floating {
    position: relative;
}

.form-floating .form-input,
.form-floating .form-select,
.form-floating .form-textarea {
    padding-top: var(--space-6);
    padding-bottom: var(--space-2);
}

.form-floating .form-label {
    position: absolute;
    top: 0;
    left: 0;
    padding: var(--space-4);
    pointer-events: none;
    transform-origin: left top;
    transition:
        transform var(--duration-fast) var(--ease-out),
        color var(--duration-fast) var(--ease-out);
    margin-bottom: 0;
    color: var(--text-muted);
    font-weight: var(--font-normal);
}

.form-floating .form-input:focus ~ .form-label,
.form-floating .form-input:not(:placeholder-shown) ~ .form-label,
.form-floating .form-select:focus ~ .form-label,
.form-floating .form-select:not([value=""]) ~ .form-label,
.form-floating .form-textarea:focus ~ .form-label,
.form-floating .form-textarea:not(:placeholder-shown) ~ .form-label {
    transform: translateY(-8px) scale(0.75);
    color: var(--ice-600);
    font-weight: var(--font-semibold);
}

/* =========================================
   INPUT WITH ICON
   ========================================= */

.input-group {
    position: relative;
    display: flex;
    align-items: stretch;
}

.input-group .form-input {
    flex: 1;
}

.input-icon {
    position: relative;
}

.input-icon .form-input {
    padding-left: var(--space-10);
}

.input-icon-right .form-input {
    padding-left: var(--space-4);
    padding-right: var(--space-10);
}

.input-icon .icon,
.input-icon-right .icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    transition: color var(--duration-fast) var(--ease-out);
}

.input-icon .icon {
    left: var(--space-3);
}

.input-icon-right .icon {
    right: var(--space-3);
}

.input-icon:focus-within .icon,
.input-icon-right:focus-within .icon {
    color: var(--ice-500);
}

/* Input addon */
.input-addon {
    display: flex;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-secondary);
    background: var(--surface-secondary);
    border: 2px solid var(--border-color);
    white-space: nowrap;
}

.input-addon:first-child {
    border-right: none;
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}

.input-addon:last-child {
    border-left: none;
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}

.input-group .form-input:not(:first-child) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.input-group .form-input:not(:last-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

/* =========================================
   CHECKBOX & RADIO
   ========================================= */

.form-check {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    cursor: pointer;
}

.form-check-input {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-top: 2px;
    background-color: var(--surface-primary);
    border: 2px solid var(--border-color);
    cursor: pointer;
    transition:
        background-color var(--duration-fast) var(--ease-out),
        border-color var(--duration-fast) var(--ease-out),
        box-shadow var(--duration-fast) var(--ease-out);
    appearance: none;
    -webkit-appearance: none;
}

.form-check-input[type="checkbox"] {
    border-radius: var(--radius-md);
}

.form-check-input[type="radio"] {
    border-radius: var(--radius-full);
}

.form-check-input:hover:not(:disabled) {
    border-color: var(--ice-400);
}

.form-check-input:focus {
    outline: none;
    border-color: var(--ice-500);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

.form-check-input:checked {
    background-color: var(--ice-500);
    border-color: var(--ice-500);
}

.form-check-input[type="checkbox"]:checked {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='white'%3E%3Cpath fill-rule='evenodd' d='M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z' clip-rule='evenodd'/%3E%3C/svg%3E");
    background-size: 14px;
    background-position: center;
    background-repeat: no-repeat;
}

.form-check-input[type="radio"]:checked {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Ccircle cx='10' cy='10' r='5' fill='white'/%3E%3C/svg%3E");
    background-size: 10px;
    background-position: center;
    background-repeat: no-repeat;
}

.form-check-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.form-check-label {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

.form-check-input:disabled ~ .form-check-label {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Checkbox/Radio inline */
.form-check-inline {
    display: inline-flex;
    margin-right: var(--space-4);
}

/* =========================================
   TOGGLE SWITCH
   ========================================= */

.form-switch {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    cursor: pointer;
}

.form-switch-input {
    position: relative;
    width: 44px;
    height: 24px;
    background-color: var(--rink-300);
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition:
        background-color var(--duration-fast) var(--ease-out),
        box-shadow var(--duration-fast) var(--ease-out);
    appearance: none;
    -webkit-appearance: none;
}

.form-switch-input::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background-color: white;
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-sm);
    transition: transform var(--duration-fast) var(--ease-spring);
}

.form-switch-input:hover:not(:disabled) {
    background-color: var(--rink-400);
}

.form-switch-input:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

.form-switch-input:checked {
    background-color: var(--ice-500);
}

.form-switch-input:checked::before {
    transform: translateX(20px);
}

.form-switch-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.form-switch-label {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

/* =========================================
   RANGE SLIDER
   ========================================= */

.form-range {
    width: 100%;
    height: 24px;
    padding: 0;
    background: transparent;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}

.form-range:focus {
    outline: none;
}

/* Track */
.form-range::-webkit-slider-runnable-track {
    width: 100%;
    height: 8px;
    background: var(--rink-200);
    border-radius: var(--radius-full);
    transition: background-color var(--duration-fast) var(--ease-out);
}

.form-range::-moz-range-track {
    width: 100%;
    height: 8px;
    background: var(--rink-200);
    border-radius: var(--radius-full);
}

/* Thumb */
.form-range::-webkit-slider-thumb {
    width: 20px;
    height: 20px;
    margin-top: -6px;
    background: var(--ice-500);
    border: none;
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-md);
    cursor: pointer;
    transition:
        transform var(--duration-fast) var(--ease-spring),
        box-shadow var(--duration-fast) var(--ease-out);
    appearance: none;
    -webkit-appearance: none;
}

.form-range::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--ice-500);
    border: none;
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-md);
    cursor: pointer;
}

.form-range:hover::-webkit-slider-thumb {
    transform: scale(1.1);
    box-shadow: var(--shadow-lg), var(--shadow-glow-blue-sm);
}

.form-range:focus::-webkit-slider-thumb {
    box-shadow: var(--shadow-lg), 0 0 0 3px rgba(56, 189, 248, 0.2);
}

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

/* =========================================
   FILE INPUT
   ========================================= */

.form-file {
    position: relative;
}

.form-file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.form-file-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-4) var(--space-6);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-secondary);
    background: var(--surface-secondary);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-xl);
    cursor: pointer;
    transition:
        border-color var(--duration-fast) var(--ease-out),
        background-color var(--duration-fast) var(--ease-out),
        color var(--duration-fast) var(--ease-out);
}

.form-file-label:hover {
    border-color: var(--ice-400);
    background: var(--ice-50);
    color: var(--ice-600);
}

.form-file-input:focus + .form-file-label {
    border-color: var(--ice-500);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

.form-file-input:disabled + .form-file-label {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Drag and drop zone */
.form-file-dropzone {
    padding: var(--space-8) var(--space-6);
    text-align: center;
}

.form-file-dropzone.dragging {
    border-color: var(--ice-500);
    background: var(--ice-100);
}

/* =========================================
   VALIDATION STATES
   ========================================= */

/* Valid state */
.form-input.is-valid,
.form-select.is-valid,
.form-textarea.is-valid,
.is-valid .form-input,
.is-valid .form-select,
.is-valid .form-textarea {
    border-color: var(--save-green);
}

.form-input.is-valid:focus,
.form-select.is-valid:focus,
.form-textarea.is-valid:focus,
.is-valid .form-input:focus,
.is-valid .form-select:focus,
.is-valid .form-textarea:focus {
    border-color: var(--save-green);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
}

/* Invalid state */
.form-input.is-invalid,
.form-select.is-invalid,
.form-textarea.is-invalid,
.is-invalid .form-input,
.is-invalid .form-select,
.is-invalid .form-textarea {
    border-color: var(--goal-red);
}

.form-input.is-invalid:focus,
.form-select.is-invalid:focus,
.form-textarea.is-invalid:focus,
.is-invalid .form-input:focus,
.is-invalid .form-select:focus,
.is-invalid .form-textarea:focus {
    border-color: var(--goal-red);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2);
}

/* Feedback messages */
.form-feedback {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    margin-top: var(--space-2);
    font-size: var(--text-sm);
}

.form-feedback-valid {
    color: var(--save-green);
}

.form-feedback-invalid {
    color: var(--goal-red);
}

.form-hint {
    display: block;
    margin-top: var(--space-2);
    font-size: var(--text-sm);
    color: var(--text-muted);
}

/* =========================================
   SEARCH INPUT
   ========================================= */

.form-search {
    position: relative;
}

.form-search .form-input {
    padding-left: var(--space-10);
    padding-right: var(--space-10);
    border-radius: var(--radius-full);
}

.form-search .search-icon {
    position: absolute;
    left: var(--space-4);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.form-search .search-clear {
    position: absolute;
    right: var(--space-2);
    top: 50%;
    transform: translateY(-50%);
    padding: var(--space-2);
    color: var(--text-muted);
    background: none;
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    opacity: 0;
    transition: opacity var(--duration-fast) var(--ease-out);
}

.form-search .form-input:not(:placeholder-shown) ~ .search-clear {
    opacity: 1;
}

.form-search .search-clear:hover {
    color: var(--text-primary);
    background: var(--surface-hover);
}

/* =========================================
   COLOR INPUT
   ========================================= */

.form-color {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.form-color-input {
    width: 48px;
    height: 48px;
    padding: var(--space-1);
    background: var(--surface-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition:
        border-color var(--duration-fast) var(--ease-out),
        box-shadow var(--duration-fast) var(--ease-out);
}

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

.form-color-input::-webkit-color-swatch {
    border: none;
    border-radius: var(--radius-md);
}

.form-color-input::-moz-color-swatch {
    border: none;
    border-radius: var(--radius-md);
}

.form-color-input:hover {
    border-color: var(--border-hover);
}

.form-color-input:focus {
    outline: none;
    border-color: var(--ice-500);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

/* =========================================
   FIELDSET & LEGEND
   ========================================= */

.form-fieldset {
    margin: 0;
    padding: var(--space-5);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
}

.form-legend {
    padding: 0 var(--space-2);
    font-family: var(--font-display);
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wider);
    color: var(--text-muted);
}

/* =========================================
   MOBILE-FIRST RESPONSIVE DESIGN
   ========================================= */

/*
 * Mobile Base (< 640px)
 * - Touch-friendly targets (min 44px)
 * - 16px font to prevent iOS zoom
 * - Full-width inputs and stacked layouts
 * - Larger checkboxes/radios for touch
 */

/* Form layout - Mobile base: stacked */
.form-row {
    flex-direction: column;
}

/* Inputs - Mobile: Touch-friendly sizing */
.form-input,
.form-select,
.form-textarea,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
select,
textarea {
    min-height: var(--touch-target-min, 44px);
    font-size: 16px; /* Prevents iOS zoom on focus */
}

/* Checkboxes & Radios - Mobile: Larger touch targets */
.form-check {
    min-height: var(--touch-target-min, 44px);
    padding: var(--space-2) 0;
}

.form-check-input {
    width: 24px;
    height: 24px;
}

.form-check-input[type="checkbox"]:checked {
    background-size: 16px;
}

.form-check-input[type="radio"]:checked {
    background-size: 12px;
}

.form-check-label {
    font-size: var(--text-base);
    padding-top: var(--space-1);
}

.form-check-inline {
    display: flex;
    margin-right: 0;
    margin-bottom: var(--space-2);
}

/* Toggle switch - Mobile: Comfortable sizing */
.form-switch {
    min-height: var(--touch-target-min, 44px);
    padding: var(--space-2) 0;
}

.form-switch-input {
    width: 52px;
    height: 28px;
}

.form-switch-input::before {
    width: 24px;
    height: 24px;
}

.form-switch-input:checked::before {
    transform: translateX(24px);
}

.form-switch-label {
    font-size: var(--text-base);
}

/* Range slider - Mobile: Larger thumb for touch */
.form-range::-webkit-slider-thumb {
    width: 28px;
    height: 28px;
    margin-top: -10px;
}

.form-range::-moz-range-thumb {
    width: 28px;
    height: 28px;
}

/* File input - Mobile: Taller drop zone */
.form-file-label {
    padding: var(--space-5) var(--space-4);
    min-height: var(--touch-target-min, 44px);
}

.form-file-dropzone {
    padding: var(--space-6) var(--space-4);
}

/* Search input - Mobile: Comfortable clear button */
.form-search .search-clear {
    padding: var(--space-3);
    min-width: var(--touch-target-min, 44px);
    min-height: var(--touch-target-min, 44px);
}

/* Color input - Mobile: Larger swatch */
.form-color-input {
    width: 52px;
    height: 52px;
}

/* Fieldset - Mobile: Compact padding */
.form-fieldset {
    padding: var(--space-4);
}

/* Input groups - Mobile: Stack addons */
.input-group {
    flex-direction: column;
}

.input-addon:first-child {
    border-right: 2px solid var(--border-color);
    border-bottom: none;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.input-addon:last-child {
    border-left: 2px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.input-group .form-input:not(:first-child) {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
}

.input-group .form-input:not(:last-child) {
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

/* Floating labels - Mobile: Adjusted positioning */
.form-floating .form-input,
.form-floating .form-select,
.form-floating .form-textarea {
    padding-top: var(--space-7);
}

/*
 * Small screens and up (640px+)
 * - Side-by-side form rows allowed
 * - Slightly refined sizing
 */
@media (min-width: 640px) {
    .form-row {
        flex-direction: row;
    }

    .form-check-inline {
        display: inline-flex;
        margin-right: var(--space-4);
        margin-bottom: 0;
    }

    /* Input groups - Tablet+: Horizontal layout */
    .input-group {
        flex-direction: row;
    }

    .input-addon:first-child {
        border-right: none;
        border-bottom: 2px solid var(--border-color);
        border-radius: var(--radius-lg) 0 0 var(--radius-lg);
    }

    .input-addon:last-child {
        border-left: none;
        border-top: 2px solid var(--border-color);
        border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    }

    .input-group .form-input:not(:first-child) {
        border-top-left-radius: 0;
        border-top-right-radius: var(--radius-lg);
        border-bottom-left-radius: 0;
        border-bottom-right-radius: var(--radius-lg);
    }

    .input-group .form-input:not(:last-child) {
        border-top-left-radius: var(--radius-lg);
        border-top-right-radius: 0;
        border-bottom-left-radius: var(--radius-lg);
        border-bottom-right-radius: 0;
    }

    /* File dropzone - Tablet+: More padding */
    .form-file-dropzone {
        padding: var(--space-8) var(--space-6);
    }
}

/*
 * Tablet and up (768px+)
 * - Standard desktop sizing options
 */
@media (min-width: 768px) {
    /* Checkboxes can return to smaller size */
    .form-check-input {
        width: 20px;
        height: 20px;
    }

    .form-check-input[type="checkbox"]:checked {
        background-size: 14px;
    }

    .form-check-input[type="radio"]:checked {
        background-size: 10px;
    }

    .form-check-label {
        font-size: var(--text-sm);
        padding-top: 0;
    }

    /* Toggle switch - Standard size */
    .form-switch-input {
        width: 44px;
        height: 24px;
    }

    .form-switch-input::before {
        width: 20px;
        height: 20px;
    }

    .form-switch-input:checked::before {
        transform: translateX(20px);
    }

    .form-switch-label {
        font-size: var(--text-sm);
    }

    /* Range slider - Standard thumb */
    .form-range::-webkit-slider-thumb {
        width: 20px;
        height: 20px;
        margin-top: -6px;
    }

    .form-range::-moz-range-thumb {
        width: 20px;
        height: 20px;
    }

    /* Color input - Standard size */
    .form-color-input {
        width: 48px;
        height: 48px;
    }

    /* Fieldset - Standard padding */
    .form-fieldset {
        padding: var(--space-5);
    }
}

/*
 * Desktop and up (1024px+)
 * - Font sizes can be more refined
 */
@media (min-width: 1024px) {
    /* Inputs can use standard text-base */
    .form-input,
    .form-select,
    .form-textarea,
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="url"],
    input[type="search"],
    input[type="date"],
    input[type="time"],
    input[type="datetime-local"],
    select,
    textarea {
        font-size: var(--text-base);
    }
}

/* =========================================
   RESPONSIVE UTILITY CLASSES
   ========================================= */

/* Full-width inputs on mobile only */
.form-input-block-mobile,
.form-select-block-mobile {
    width: 100%;
}

@media (min-width: 640px) {
    .form-input-block-mobile,
    .form-select-block-mobile {
        width: auto;
    }
}

/* Stack form elements on mobile */
.form-stack-mobile {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

@media (min-width: 640px) {
    .form-stack-mobile {
        flex-direction: row;
        align-items: flex-end;
    }
}

/* Hide labels visually but keep for screen readers on mobile */
.form-label-sr-mobile {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (min-width: 640px) {
    .form-label-sr-mobile {
        position: static;
        width: auto;
        height: auto;
        padding: 0;
        margin: 0 0 var(--space-2) 0;
        overflow: visible;
        clip: auto;
        white-space: normal;
    }
}

/* =========================================
   REDUCED MOTION
   ========================================= */

@media (prefers-reduced-motion: reduce) {
    .form-input,
    .form-select,
    .form-textarea,
    .form-check-input,
    .form-switch-input,
    .form-switch-input::before,
    .form-range::-webkit-slider-thumb,
    .form-floating .form-label {
        transition: none;
    }
}

/* =========================================
   DARK MODE ADJUSTMENTS
   ========================================= */

@media (prefers-color-scheme: dark) {
    .form-select,
    select {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='%2394a3b8'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'/%3E%3C/svg%3E");
    }

    .form-file-label:hover {
        background: var(--rink-800);
    }

    .form-switch-input {
        background-color: var(--rink-600);
    }

    .form-switch-input:hover:not(:disabled) {
        background-color: var(--rink-500);
    }
}
