/**
 * Forms - Forme i input elementi
 */

/* ==========================================
   FORM INPUT BASE
   ========================================== */
.form-input {
    width: 100%;
    padding: 14px 18px;
    font-family: var(--font-body);
    font-size: 1rem;
    font-size: 16px; /* iOS Safari - prevents zoom on focus */
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    -webkit-border-radius: var(--radius-md);
    border-radius: var(--radius-md);
    outline: none;
    transition: all var(--transition-normal);
    /* iOS Safari fixes */
    -webkit-appearance: none;
    appearance: none;
}

.form-input:focus {
    border-color: var(--primary);
    background: rgba(255, 107, 53, 0.05);
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Error state */
.form-input--error {
    border-color: var(--danger);
}

.form-input--error:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Success state */
.form-input--success {
    border-color: var(--success);
}

/* ==========================================
   TEXTAREA
   ========================================== */
textarea.form-input {
    min-height: 120px;
    resize: vertical;
    line-height: 1.6;
}

/* ==========================================
   SELECT
   ========================================== */
select.form-input {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    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='%23ff6b35' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 16px center !important;
    background-size: 16px 16px !important;
    padding-right: 48px !important;
    cursor: pointer;
}

select.form-input:focus {
    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='%23ff8c00' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
}

/* Remove default dropdown arrow in IE/Edge */
select.form-input::-ms-expand {
    display: none;
}

/* Style select dropdown options - limited browser support */
select.form-input option {
    background: #1a1a1a !important;
    background-image: none !important;
    color: #ffffff;
    padding: 12px;
}

/* Remove arrow from options in Firefox */
select.form-input option:checked,
select.form-input option:hover {
    background-image: none !important;
}

/* ==========================================
   CASH AMOUNT SECTION
   ========================================== */
.cash-only-notice {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: rgba(255, 107, 53, 0.1);
    border: 1px solid rgba(255, 107, 53, 0.3);
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    color: var(--primary);
    font-size: 0.95rem;
}

.cash-only-notice i {
    font-size: 1.2rem;
}

.cash-amount-section {
    margin-top: 20px;
}

.cash-amount-section .form-label {
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cash-amount-options {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

.cash-amount-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s ease;
}

.cash-amount-option:hover {
    border-color: var(--primary);
}

.cash-amount-option:has(input:checked) {
    background: rgba(255, 107, 53, 0.1);
    border-color: var(--primary);
}

.cash-amount-option input {
    accent-color: var(--primary);
    width: 18px;
    height: 18px;
}

.cash-amount-option span {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.cash-amount-option:has(input:checked) span {
    color: var(--text-primary);
}

.custom-amount-input {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 250px;
}

.custom-amount-input .form-input {
    flex: 1;
}

.input-suffix {
    color: var(--text-muted);
    font-weight: 600;
}

/* ==========================================
   INPUT WITH ICON
   ========================================== */
.input-icon-wrapper {
    position: relative;
}

.input-icon-wrapper .form-input {
    padding-left: 48px;
}

.input-icon-wrapper i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    transition: color 0.3s ease;
    pointer-events: none;
}

.input-icon-wrapper:has(.form-input:focus) i {
    color: var(--primary);
}

/* ==========================================
   FORM GROUP
   ========================================== */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-label--required::after {
    content: ' *';
    color: var(--danger);
}

.form-hint {
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.form-error {
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--danger);
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-error::before {
    content: '!';
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    background: var(--danger);
    color: white;
    border-radius: 50%;
    font-size: 10px;
    font-weight: 700;
}

/* ==========================================
   CHECKBOX & RADIO
   ========================================== */
.form-check {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}

.form-check input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.form-check__box {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    margin-top: 2px;
}

.form-check input:checked + .form-check__box {
    background: var(--primary-gradient);
    border-color: transparent;
}

.form-check input:checked + .form-check__box::after {
    content: '✓';
    color: white;
    font-size: 14px;
    font-weight: 700;
}

.form-check input:focus + .form-check__box {
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.2);
}

/* Radio */
.form-check--radio .form-check__box {
    border-radius: 50%;
}

.form-check--radio input:checked + .form-check__box::after {
    content: '';
    width: 10px;
    height: 10px;
    background: white;
    border-radius: 50%;
}

.form-check__label {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.form-check__label a {
    color: var(--primary);
}

/* ==========================================
   SWITCH TOGGLE
   ========================================== */
.form-switch {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.form-switch input {
    position: absolute;
    opacity: 0;
}

.form-switch__track {
    width: 50px;
    height: 28px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    position: relative;
    transition: all 0.3s ease;
}

.form-switch__track::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: all 0.3s ease;
}

.form-switch input:checked + .form-switch__track {
    background: var(--primary);
    border-color: var(--primary);
}

.form-switch input:checked + .form-switch__track::after {
    left: calc(100% - 23px);
    background: white;
}

.form-switch__label {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

/* ==========================================
   SEARCH INPUT
   ========================================== */
.search-input {
    position: relative;
}

.search-input .form-input {
    padding-left: 48px;
    padding-right: 48px;
    border-radius: var(--radius-full);
}

.search-input__icon {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.search-input__clear {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.3s ease;
}

.search-input:has(.form-input:not(:placeholder-shown)) .search-input__clear {
    opacity: 1;
}

.search-input__clear:hover {
    background: var(--danger);
    color: white;
}

/* ==========================================
   RESPONSIVE FORMS
   ========================================== */
@media (max-width: 768px) {
    .form-input {
        padding: 12px 14px;
        font-size: 16px; /* Prevents zoom on iOS */
        border-radius: 10px;
    }
    
    textarea.form-input {
        min-height: 100px;
    }
    
    select.form-input {
        padding-right: 42px !important;
        background-position: right 12px center !important;
    }
    
    .form-group {
        margin-bottom: 16px;
    }
    
    .form-label {
        font-size: 0.85rem;
        margin-bottom: 6px;
    }
    
    .form-row {
        flex-direction: column;
        gap: 16px;
    }
    
    .input-icon-wrapper .form-input {
        padding-left: 42px;
    }
    
    .input-icon-wrapper i {
        left: 14px;
    }
    
    /* Cash amount options */
    .cash-amount-options {
        gap: 10px;
    }
    
    .cash-amount-option {
        padding: 10px 16px;
        flex: 1;
        min-width: calc(50% - 10px);
        justify-content: center;
    }
    
    .custom-amount-input {
        max-width: 100%;
    }
    
    /* Checkbox and radio */
    .checkbox-wrapper,
    .radio-wrapper {
        gap: 10px;
    }
    
    .checkbox-wrapper input,
    .radio-wrapper input {
        width: 20px;
        height: 20px;
    }
}

@media (max-width: 480px) {
    .form-input {
        padding: 10px 12px;
    }
    
    .cash-amount-option {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
}
