/* ============================================================================
   SIGNALDESK - FORMS COMPONENT
   Beautiful, interactive forms with creative animations and validation states
   ============================================================================ */

/* Base Form Styles */
form {
    width: 100%;
}

/* ============================================================================
   FORM GROUPS & LAYOUT
   ============================================================================ */

.form-group {
    margin-bottom: 1.5rem;
    position: relative;
}

.form-row {
    display: flex;
    gap: 1rem;
}

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

@media (max-width: 768px) {
    .form-row {
        flex-direction: column;
    }
}

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

.form-label,
label {
    display: block;
    font-size: var(--font-sm);
    font-weight: 600;
    color: var(--grey-dark);
    margin-bottom: 0.5rem;
    transition: all var(--transition-base);
}

.form-label.required::after,
label.required::after {
    content: '*';
    color: var(--error);
    margin-left: 0.25rem;
}

/* Floating Label Effect */
.form-floating {
    position: relative;
}

.form-floating label {
    position: absolute;
    top: 50%;
    left: 1rem;
    transform: translateY(-50%);
    pointer-events: none;
    transition: all var(--transition-base);
    color: var(--grey-medium);
    font-weight: 400;
}

.form-floating input:focus ~ label,
.form-floating input:not(:placeholder-shown) ~ label,
.form-floating textarea:focus ~ label,
.form-floating textarea:not(:placeholder-shown) ~ label {
    top: -0.5rem;
    left: 0.75rem;
    font-size: var(--font-xs);
    background: var(--white);
    padding: 0 0.5rem;
    color: var(--primary-blue);
    font-weight: 600;
}

/* ============================================================================
   INPUT FIELDS - Text, Email, Password, etc.
   ============================================================================ */

.form-control,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="url"],
input[type="number"],
input[type="search"],
input[type="date"] {
    width: 100%;
    padding: 0.875rem 1.25rem;
    font-size: var(--font-base);
    font-family: var(--font-primary);
    color: var(--grey-dark);
    background-color: var(--white);
    border: 2px solid var(--grey-light);
    border-radius: var(--radius-lg);
    transition: all var(--transition-base);
    outline: none;
}

/* Focus State - Animated Border */
.form-control:focus,
input:focus {
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
    background-color: var(--white);
}

/* Hover State */
.form-control:hover:not(:focus):not(:disabled),
input:hover:not(:focus):not(:disabled) {
    border-color: var(--grey-medium);
}

/* Placeholder Styles */
.form-control::placeholder,
input::placeholder {
    color: var(--grey-medium);
    opacity: 0.7;
    transition: opacity var(--transition-base);
}

.form-control:focus::placeholder,
input:focus::placeholder {
    opacity: 0.5;
}

/* Disabled State */
.form-control:disabled,
input:disabled {
    background-color: var(--grey-light);
    color: var(--grey-medium);
    cursor: not-allowed;
    opacity: 0.7;
}

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

textarea.form-control,
textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.6;
}

/* Character Counter for Textarea */
.textarea-wrapper {
    position: relative;
}

.char-counter {
    position: absolute;
    bottom: 0.5rem;
    right: 1rem;
    font-size: var(--font-xs);
    color: var(--grey-medium);
    background: var(--white);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
}

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

.form-select,
select {
    width: 100%;
    padding: 0.875rem 3rem 0.875rem 1.25rem;
    font-size: var(--font-base);
    font-family: var(--font-primary);
    color: var(--grey-dark);
    background-color: var(--white);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B7280' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 12px;
    border: 2px solid var(--grey-light);
    border-radius: var(--radius-lg);
    transition: all var(--transition-base);
    outline: none;
    cursor: pointer;
    appearance: none;
}

.form-select:focus,
select:focus {
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.form-select:hover:not(:focus):not(:disabled),
select:hover:not(:focus):not(:disabled) {
    border-color: var(--grey-medium);
}

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

/* Hide Default */
input[type="checkbox"],
input[type="radio"] {
    appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid var(--grey-light);
    border-radius: var(--radius-sm);
    background-color: var(--white);
    cursor: pointer;
    position: relative;
    transition: all var(--transition-base);
    margin-right: 0.75rem;
    flex-shrink: 0;
}

input[type="radio"] {
    border-radius: 50%;
}

/* Hover State */
input[type="checkbox"]:hover,
input[type="radio"]:hover {
    border-color: var(--primary-blue);
}

/* Focus State */
input[type="checkbox"]:focus,
input[type="radio"]:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

/* Checked State - Checkbox */
input[type="checkbox"]:checked {
    background: var(--gradient-primary);
    border-color: var(--primary-blue);
}

input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 6px;
    width: 4px;
    height: 9px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Checked State - Radio */
input[type="radio"]:checked {
    border-color: var(--primary-blue);
    border-width: 6px;
}

/* Custom Checkbox/Radio Labels */
.form-check {
    display: flex;
    align-items: center;
    margin-bottom: 0.75rem;
    cursor: pointer;
    user-select: none;
}

.form-check label {
    cursor: pointer;
    margin-bottom: 0;
    font-weight: 400;
}

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

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

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

.form-switch {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
}

.form-switch input[type="checkbox"] {
    width: 50px;
    height: 26px;
    background-color: var(--grey-light);
    border-radius: var(--radius-full);
    border: none;
    position: relative;
    cursor: pointer;
    transition: background-color var(--transition-base);
}

.form-switch input[type="checkbox"]::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: var(--white);
    border-radius: 50%;
    transition: transform var(--transition-base);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.form-switch input[type="checkbox"]:checked {
    background: var(--gradient-primary);
}

.form-switch input[type="checkbox"]:checked::after {
    transform: translateX(24px);
}

.form-switch label {
    cursor: pointer;
    margin: 0;
}

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

.form-file-wrapper {
    position: relative;
}

input[type="file"] {
    display: none;
}

.form-file-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2rem;
    border: 2px dashed var(--grey-light);
    border-radius: var(--radius-lg);
    background-color: var(--grey-lighter);
    cursor: pointer;
    transition: all var(--transition-base);
    text-align: center;
}

.form-file-label:hover {
    border-color: var(--primary-blue);
    background-color: rgba(59, 130, 246, 0.05);
}

.form-file-label.drag-over {
    border-color: var(--primary-blue);
    background-color: rgba(59, 130, 246, 0.1);
    transform: scale(1.02);
}

.file-upload-icon {
    font-size: var(--font-3xl);
    color: var(--primary-blue);
}

.file-upload-text {
    color: var(--grey-medium);
    font-size: var(--font-sm);
}

.file-upload-text strong {
    color: var(--primary-blue);
    font-weight: 600;
}

/* File Name Display */
.file-name-display {
    margin-top: 0.75rem;
    padding: 0.75rem 1rem;
    background: rgba(59, 130, 246, 0.05);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.file-name-display i {
    color: var(--success);
}

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

/* Valid/Success State */
.form-control.is-valid,
input.is-valid,
select.is-valid,
textarea.is-valid {
    border-color: var(--success);
    padding-right: 3rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2310B981' viewBox='0 0 16 16'%3E%3Cpath d='M13.854 3.646a.5.5 0 0 1 0 .708l-7 7a.5.5 0 0 1-.708 0l-3.5-3.5a.5.5 0 1 1 .708-.708L6.5 10.293l6.646-6.647a.5.5 0 0 1 .708 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
}

.form-control.is-valid:focus,
input.is-valid:focus {
    border-color: var(--success);
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1);
}

/* Invalid/Error State */
.form-control.is-invalid,
input.is-invalid,
select.is-invalid,
textarea.is-invalid {
    border-color: var(--error);
    padding-right: 3rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23EF4444' viewBox='0 0 16 16'%3E%3Cpath d='M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z'/%3E%3Cpath d='M7.002 11a1 1 0 1 1 2 0 1 1 0 0 1-2 0zM7.1 4.995a.905.905 0 1 1 1.8 0l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 4.995z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
}

.form-control.is-invalid:focus,
input.is-invalid:focus {
    border-color: var(--error);
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.1);
}

/* Feedback Messages */
.valid-feedback,
.invalid-feedback {
    font-size: var(--font-sm);
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: slideInLeft 0.3s ease-out;
}

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

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

.valid-feedback i,
.invalid-feedback i {
    font-size: var(--font-base);
}

/* ============================================================================
   INPUT GROUPS - With Icons/Buttons
   ============================================================================ */

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

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

.input-group-prepend,
.input-group-append {
    display: flex;
}

.input-group-text {
    padding: 0.875rem 1.25rem;
    background-color: var(--grey-light);
    border: 2px solid var(--grey-light);
    color: var(--grey-medium);
    font-size: var(--font-base);
    display: flex;
    align-items: center;
    transition: all var(--transition-base);
}

.input-group-prepend .input-group-text {
    border-right: none;
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}

.input-group-append .input-group-text {
    border-left: none;
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}

.input-group .form-control:focus ~ .input-group-text,
.input-group:focus-within .input-group-text {
    border-color: var(--primary-blue);
    background-color: rgba(59, 130, 246, 0.05);
    color: var(--primary-blue);
}

/* Icon Inside Input */
.input-icon-wrapper {
    position: relative;
}

.input-icon-left {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--grey-medium);
    font-size: var(--font-lg);
    transition: color var(--transition-base);
    pointer-events: none;
}

.input-icon-left ~ .form-control {
    padding-left: 3rem;
}

.input-icon-right {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--grey-medium);
    font-size: var(--font-lg);
    transition: color var(--transition-base);
    cursor: pointer;
}

.input-icon-right ~ .form-control {
    padding-right: 3rem;
}

.form-control:focus ~ .input-icon-left,
.form-control:focus ~ .input-icon-right {
    color: var(--primary-blue);
}

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

.search-input-wrapper {
    position: relative;
}

.search-input {
    padding-left: 3rem;
    border-radius: var(--radius-full);
}

.search-icon {
    position: absolute;
    left: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--grey-medium);
    font-size: var(--font-lg);
    pointer-events: none;
}

.search-clear {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: var(--grey-light);
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: all var(--transition-base);
}

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

.search-clear:hover {
    background: var(--grey-medium);
    color: var(--white);
}

/* ============================================================================
   PASSWORD TOGGLE
   ============================================================================ */

.password-toggle-wrapper {
    position: relative;
}

.password-toggle {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--grey-medium);
    cursor: pointer;
    padding: 0.5rem;
    transition: all var(--transition-base);
}

.password-toggle:hover {
    color: var(--primary-blue);
}

/* Password Strength Indicator */
.password-strength {
    display: flex;
    gap: 0.25rem;
    margin-top: 0.5rem;
}

.password-strength span {
    flex: 1;
    height: 4px;
    background: var(--grey-light);
    border-radius: var(--radius-full);
    transition: all var(--transition-base);
}

.password-strength.weak span:nth-child(1) {
    background: var(--error);
}

.password-strength.medium span:nth-child(1),
.password-strength.medium span:nth-child(2) {
    background: var(--warning);
}

.password-strength.strong span {
    background: var(--success);
}

/* ============================================================================
   HONEYPOT FIELD - Hidden for Bot Detection
   ============================================================================ */

input[name="honeypot"],
.honeypot {
    display: none !important;
    visibility: hidden !important;
    position: absolute !important;
    left: -9999px !important;
    width: 0 !important;
    height: 0 !important;
    opacity: 0 !important;
}

/* ============================================================================
   FORM HELPERS & TEXT
   ============================================================================ */

.form-text,
.form-help {
    display: block;
    margin-top: 0.5rem;
    font-size: var(--font-sm);
    color: var(--grey-medium);
    line-height: var(--leading-relaxed);
}

.form-text i {
    margin-right: 0.5rem;
}

/* ============================================================================
   FORM LOADING STATE
   ============================================================================ */

form.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

form.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin-top: -20px;
    margin-left: -20px;
    border: 4px solid var(--grey-light);
    border-top-color: var(--primary-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ============================================================================
   RESPONSIVE STYLES
   ============================================================================ */

@media (max-width: 768px) {
    .form-control,
    input,
    select,
    textarea {
        font-size: var(--font-base);
    }
    
    .input-group {
        flex-direction: column;
    }
    
    .input-group-prepend .input-group-text,
    .input-group-append .input-group-text {
        border-radius: var(--radius-lg);
        border: 2px solid var(--grey-light);
    }
    
    .input-group .form-control {
        border-radius: var(--radius-lg);
    }
}

/* ============================================================================
   ACCESSIBILITY
   ============================================================================ */

/* Focus Visible */
.form-control:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--primary-blue);
    outline-offset: 2px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .form-control,
    input,
    select,
    textarea {
        border-width: 3px;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .form-control,
    input,
    select,
    textarea,
    .form-check,
    .form-switch,
    .password-toggle,
    .valid-feedback,
    .invalid-feedback {
        transition: none !important;
        animation: none !important;
    }
}