/* ============================================
   WREN DESIGN SYSTEM - FORMS
   Mobile-first form components with consistent sizing
   ============================================ */

/* ========================================
   FORM CONTROLS - BASE
   ======================================== */

.form-control {
    width: 100%;
    height: var(--input-height);
    min-height: var(--touch-target-min);
    padding: 0 var(--space-4);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    font-weight: 500;
    color: var(--black);
    background: var(--white);
    border: var(--border-width) solid var(--gray-300);
    border-radius: var(--radius-lg);
    transition: all var(--transition);
    -webkit-appearance: none;
    appearance: none;
}

.form-control:hover {
    border-color: var(--gray-400);
}

.form-control:focus {
    outline: none;
    border-color: var(--wren-terracotta);
    box-shadow: var(--shadow-focus);
}

.form-control::placeholder {
    color: var(--gray-400);
    font-family: inherit;
}

.form-control:disabled {
    background: var(--gray-100);
    color: var(--gray-500);
    cursor: not-allowed;
    opacity: 0.7;
}

/* Form control sizes */
.form-control-sm {
    height: var(--input-height-sm);
    min-height: var(--touch-target-sm);
    padding: 0 var(--space-3);
    font-size: var(--text-sm);
}

.form-control-lg {
    height: var(--input-height-lg);
    min-height: var(--touch-target-lg);
    padding: 0 var(--space-5);
    font-size: var(--text-lg);
}

/* Textarea */
textarea.form-control {
    height: auto;
    min-height: 120px;
    padding: var(--space-4);
    resize: vertical;
    line-height: 1.5;
}

/* Date inputs */
input[type="date"].form-control {
    padding-right: var(--space-3) !important;
    color-scheme: light !important;
    accent-color: var(--wren-terracotta) !important;
    font-family: var(--font-sans) !important;
    font-size: var(--text-base) !important;
    font-weight: 500 !important;
    color: var(--black) !important;
}

input[type="date"].form-control::-webkit-calendar-picker-indicator {
    cursor: pointer !important;
    opacity: 0.5;
    transition: all 0.15s ease;
    padding: 4px;
    border-radius: 4px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'%3E%3C/rect%3E%3Cline x1='16' y1='2' x2='16' y2='6'%3E%3C/line%3E%3Cline x1='8' y1='2' x2='8' y2='6'%3E%3C/line%3E%3Cline x1='3' y1='10' x2='21' y2='10'%3E%3C/line%3E%3C/svg%3E") !important;
    background-repeat: no-repeat;
    background-position: center;
    width: 20px;
    height: 20px;
}

input[type="date"].form-control::-webkit-calendar-picker-indicator:hover {
    opacity: 0.8;
}

input[type="date"].form-control::-webkit-datetime-edit {
    font-family: var(--font-sans) !important;
    font-weight: 500 !important;
    color: var(--black) !important;
}

input[type="date"].form-control::-webkit-datetime-edit-fields-wrapper {
    padding: 0 !important;
    font-family: var(--font-sans) !important;
}

input[type="date"].form-control::-webkit-datetime-edit-text {
    color: var(--gray-400) !important;
    padding: 0 3px !important;
}

input[type="date"].form-control::-webkit-datetime-edit-day-field,
input[type="date"].form-control::-webkit-datetime-edit-month-field,
input[type="date"].form-control::-webkit-datetime-edit-year-field {
    color: var(--black) !important;
    font-family: var(--font-sans) !important;
    font-weight: 500 !important;
    padding: 2px !important;
}

input[type="date"].form-control::-webkit-datetime-edit-day-field:focus,
input[type="date"].form-control::-webkit-datetime-edit-month-field:focus,
input[type="date"].form-control::-webkit-datetime-edit-year-field:focus {
    background-color: var(--wren-terracotta-light) !important;
    color: var(--wren-terracotta) !important;
    outline: none !important;
    border-radius: 3px !important;
}

/* Firefox date input */
input[type="date"].form-control::-moz-focus-inner {
    border: 0 !important;
}

/* FORM LABELS */
.form-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--black);
    margin-bottom: var(--space-2);
}

.form-group {
    margin-bottom: var(--space-6);
}

/* INPUT GROUPS */
.input-group {
    display: flex;
    width: 100%;
}

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

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

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

.input-group-text {
    display: flex;
    align-items: center;
    padding: 0 var(--space-4);
    font-size: var(--text-base);
    font-weight: 500;
    color: var(--gray-600);
    background: var(--gray-50);
    border: var(--border-width) solid var(--gray-300);
    border-radius: 0;
}

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

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

.input-group .form-control:not(:first-child) {
    border-left: none;
}

.input-group .form-control:not(:last-child) {
    border-right: none;
}

/* Input group with select */
.input-group .form-select {
    border-radius: 0;
    flex-shrink: 0;
}

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

.input-group .form-select:not(:first-child) {
    border-left: none;
}

.input-group .form-control:not(:first-child) + .form-control,
.input-group .form-select:not(:first-child) + .form-control {
    border-left: none;
}

/* Compact select in input group (for country codes, etc.) */
.input-group .form-select.form-select-compact {
    width: 90px;
    min-width: 90px;
    max-width: 120px;
    padding-right: var(--space-8);
    font-size: var(--text-sm);
    font-family: var(--font-sans); /* Inter */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.form-select {
    width: 100%;
    height: var(--input-height);
    min-height: var(--touch-target-min);
    padding: 0 var(--space-12) 0 var(--space-4);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    font-weight: 500;
    color: var(--black);
    background: var(--white) url("data:image/svg+xml,%3Csvg width='14' height='8' viewBox='0 0 14 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L7 7L13 1' stroke='%231D1D1F' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 16px center;
    border: var(--border-width) solid var(--gray-300);
    border-radius: var(--radius-lg);
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    transition: all var(--transition);
}

.form-select:hover {
    border-color: var(--gray-400);
}

.form-select:focus {
    outline: none;
    border-color: var(--wren-terracotta);
    box-shadow: var(--shadow-focus);
}

.form-select:disabled {
    background-color: var(--gray-100);
    color: var(--gray-500);
    cursor: not-allowed;
    opacity: 0.7;
}

/* Select sizes */
.form-select-sm {
    height: var(--input-height-sm);
    min-height: var(--touch-target-sm);
    padding: 0 var(--space-10) 0 var(--space-3);
    font-size: var(--text-sm);
}

.form-select-lg {
    height: var(--input-height-lg);
    min-height: var(--touch-target-lg);
    padding: 0 var(--space-14) 0 var(--space-5);
    font-size: var(--text-lg);
}

/* CHECKBOXES */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    cursor: pointer;
    user-select: none;
}

.checkbox-input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.checkbox-custom {
    position: relative;
    width: 20px;
    height: 20px;
    background: var(--white);
    border: var(--border-width) solid var(--gray-300);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    flex-shrink: 0;
}

.checkbox-input:hover + .checkbox-custom {
    border-color: var(--gray-400);
}

.checkbox-input:checked + .checkbox-custom {
    background: var(--wren-terracotta);
    border-color: var(--wren-terracotta);
}

.checkbox-input:checked + .checkbox-custom::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid var(--white);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checkbox-input:focus + .checkbox-custom {
    box-shadow: 0 0 0 3px var(--wren-terracotta-light);
}

.checkbox-input:disabled + .checkbox-custom {
    background: var(--gray-100);
    border-color: var(--gray-300);
    cursor: not-allowed;
}

.checkbox-text {
    font-size: var(--text-base);
    font-weight: 500;
    color: var(--gray-900);
}

.checkbox-input:disabled ~ .checkbox-text {
    color: var(--gray-500);
}

/* RADIO BUTTONS */
.radio-label {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    cursor: pointer;
    user-select: none;
}

.radio-input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.radio-custom {
    position: relative;
    width: 20px;
    height: 20px;
    background: var(--white);
    border: var(--border-width) solid var(--gray-300);
    border-radius: var(--radius-full);
    transition: all var(--transition);
    flex-shrink: 0;
}

.radio-input:hover + .radio-custom {
    border-color: var(--gray-400);
}

.radio-input:checked + .radio-custom {
    border-color: var(--wren-terracotta);
}

.radio-input:checked + .radio-custom::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    background: var(--wren-terracotta);
    border-radius: var(--radius-full);
}

.radio-input:focus + .radio-custom {
    box-shadow: 0 0 0 3px var(--wren-terracotta-light);
}

.radio-text {
    font-size: var(--text-base);
    font-weight: 500;
    color: var(--gray-900);
}

/* TOGGLE SWITCHES */
.switch-label {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    cursor: pointer;
    user-select: none;
}

.switch-input {
    position: absolute;
    opacity: 0;
}

.switch-slider {
    position: relative;
    width: 48px;
    height: 26px;
    background: var(--gray-300);
    border-radius: var(--radius-full);
    transition: all var(--transition);
    flex-shrink: 0;
}

.switch-slider::before {
    content: '';
    position: absolute;
    left: 3px;
    top: 3px;
    width: 20px;
    height: 20px;
    background: var(--white);
    border-radius: var(--radius-full);
    transition: all var(--transition);
}

.switch-input:checked + .switch-slider {
    background: var(--wren-terracotta);
}

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

.switch-input:focus + .switch-slider {
    box-shadow: 0 0 0 3px var(--wren-terracotta-light);
}

.switch-input:disabled + .switch-slider {
    opacity: 0.4;
    cursor: not-allowed;
}

.switch-text {
    font-size: var(--text-base);
    font-weight: 500;
    color: var(--gray-900);
}

.switch-input:disabled ~ .switch-text {
    color: var(--gray-500);
}

/* OTP INPUT */
.otp-input-group {
    display: flex;
    gap: var(--space-3);
    justify-content: center;
    margin: var(--space-8) 0;
}

.otp-input {
    width: 56px;
    height: 64px;
    text-align: center;
    font-size: var(--text-3xl);
    font-weight: 800;
    font-family: var(--font-display);
    color: var(--black);
    background: var(--white);
    border: var(--border-width) solid var(--black);
    border-radius: var(--radius-lg);
    transition: all var(--transition);
}

.otp-input:hover {
    border-color: var(--gray-700);
}

.otp-input:focus {
    outline: none;
    border-color: var(--wren-terracotta);
    box-shadow: 0 0 0 4px var(--wren-terracotta-light);
}

/* OTP DEMO CARD */
.otp-demo-card {
    max-width: 500px;
    margin: 0 auto;
    padding: var(--space-12) var(--space-8);
    background: var(--white);
    border: var(--border-width) solid var(--gray-200);
    border-radius: var(--radius-xl);
    text-align: center;
}

.otp-demo-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto var(--space-6);
    background: var(--gray-900);
    border: var(--border-width) solid var(--black);
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    color: var(--white);
}

.otp-demo-title {
    font-size: var(--text-3xl);
    font-weight: 800;
    margin-bottom: var(--space-2);
}

.otp-demo-description {
    color: var(--gray-600);
    margin-bottom: var(--space-8);
}

.otp-demo-actions {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    align-items: center;
}

.otp-verify-btn {
    width: 100%;
    max-width: 300px;
}

/* LOGIN CARD */
.login-card {
    max-width: 440px;
    margin: 0 auto;
    padding: var(--space-12);
    background: var(--white);
    border: var(--border-width) solid var(--gray-200);
    border-radius: var(--radius-xl);
}

.login-header {
    text-align: center;
    margin-bottom: var(--space-10);
}

.login-logo {
    width: 64px;
    height: 64px;
    margin-bottom: var(--space-6);
}

.login-title {
    font-size: var(--text-3xl);
    font-weight: 800;
    margin-bottom: var(--space-2);
}

.login-subtitle {
    color: var(--gray-600);
}

.login-form {
    margin-bottom: var(--space-6);
}

.login-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-6);
}

.login-link {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--wren-terracotta);
    text-decoration: none;
    transition: color var(--transition);
}

.login-link:hover {
    color: var(--wren-terracotta-hover);
}

.login-footer {
    text-align: center;
    margin-top: var(--space-6);
    padding-top: var(--space-6);
    border-top: var(--border-width) solid var(--gray-200);
}

.login-footer-text {
    font-size: var(--text-sm);
    color: var(--gray-600);
}

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

.form-control-success,
.form-select-success {
    border-color: var(--success);
}

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

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

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

/* Form shake animation for errors */
@keyframes formShake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-8px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(8px);
    }
}

.form-shake {
    animation: formShake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

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

.form-control-warning:focus {
    border-color: var(--warning);
    box-shadow: 0 0 0 3px var(--warning-light);
}

.form-feedback {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    font-weight: 600;
    margin-top: var(--space-2);
    animation: fadeIn 0.2s ease;
}

.form-feedback i {
    font-size: 14px;
    flex-shrink: 0;
}

.form-feedback-text {
    flex: 1;
}

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

.form-feedback-success {
    color: var(--success);
}

.form-feedback-error {
    color: var(--error);
}

.form-feedback-warning {
    color: var(--warning);
}

/* DEMO LAYOUT */
.demo-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-12) var(--space-8);
}

.demo-header {
    display: flex;
    align-items: flex-start;
    gap: var(--space-6);
    margin-bottom: var(--space-16);
    padding-bottom: var(--space-8);
    border-bottom: var(--border-width) solid var(--gray-200);
}

.demo-header-icon {
    width: 80px;
    height: 80px;
    background: var(--gray-900);
    border: var(--border-width) solid var(--black);
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    color: var(--white);
    flex-shrink: 0;
}

.demo-title {
    margin-bottom: var(--space-2);
}

.demo-description {
    font-size: var(--text-lg);
    color: var(--gray-600);
    max-width: 700px;
}

.demo-section {
    margin-bottom: var(--space-20);
}

.section-title {
    margin-bottom: var(--space-3);
}

.section-description {
    color: var(--gray-600);
    margin-bottom: var(--space-8);
}

/* FORM DEMO GRID */
.form-demo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--space-6);
}

.form-demo-card {
    background: var(--white);
    border: var(--border-width) solid var(--gray-200);
    border-radius: var(--radius-xl);
    padding: var(--space-8);
    transition: all var(--transition);
}

.form-demo-card:hover {
    border-color: var(--gray-400);
    box-shadow: var(--shadow-sm);
}

.form-demo-title {
    font-size: var(--text-lg);
    font-weight: 700;
    margin-bottom: var(--space-6);
    color: var(--gray-900);
}

.form-demo-full {
    margin-top: var(--space-8);
}

/* UTILITY */
.w-full {
    width: 100%;
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .demo-container {
        padding: var(--space-8) var(--space-4);
    }
    
    .demo-header {
        flex-direction: column;
        gap: var(--space-4);
    }
    
    .demo-header-icon {
        width: 64px;
        height: 64px;
        font-size: 32px;
    }
    
    .form-demo-grid {
        grid-template-columns: 1fr;
    }
    
    .otp-input {
        width: 48px;
        height: 56px;
        font-size: var(--text-2xl);
    }
    
    .login-card {
        padding: var(--space-8);
    }
}