/**
 * Advanced Contact Form Widget Styles
 *
 * Modern Material Design styling with responsive layouts
 *
 * @package Advanced_Widget_Kit
 * @since 2.0.1
 */

/* Base Form Styles */
.awke-contact-form-wrapper {
    --awke-form-spacing: 20px;
    --awke-input-height: 56px;
    --awke-border-radius: 8px;
    --awke-primary-color: #6366f1;
    --awke-error-color: #ef4444;
    --awke-success-color: #22c55e;
    --awke-label-color: #4b5563;
    --awke-input-bg: #ffffff;
    --awke-input-border: #e5e7eb;
    --awke-input-focus: #6366f1;
    --awke-shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --awke-shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

.awke-contact-form {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
}

/* Form Layouts */
.awke-layout-single-column .awke-contact-form {
    max-width: 600px;
}

.awke-layout-two-column .awke-contact-form {
    max-width: 800px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--awke-form-spacing);
}

.awke-layout-popup .awke-contact-form {
    max-width: 500px;
    padding: 30px;
    background: var(--awke-input-bg);
    border-radius: var(--awke-border-radius);
    box-shadow: var(--awke-shadow-md);
}

.awke-layout-floating {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 999;
}

/* Form Fields */
.awke-form-field {
    position: relative;
    margin-bottom: var(--awke-form-spacing);
    display: inline-block;
    vertical-align: top;
    width: 100%;
}

/* Clear fix for floated fields */
.awke-contact-form:after {
    content: '';
    display: table;
    clear: both;
}

/* Label Positioning - Base */
.awke-form-field {
    display: flex;
    flex-wrap: wrap;
}

/* Default Floating Label */
.awke-form-field.awke-label-floating {
    display: block;
    position: relative;
}

.awke-form-field.awke-label-floating label {
    display: block;
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--awke-label-color);
    font-size: 16px;
    transition: all 0.2s ease;
    pointer-events: none;
    padding: 0 4px;
    background: var(--awke-input-bg);
    width: auto;
    z-index: 1;
}

/* Above Label */
.awke-form-field.awke-label-above {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.awke-form-field.awke-label-above label {
    display: block;
    width: 100%;
    margin-bottom: 8px;
    color: var(--awke-label-color);
    font-size: 14px;
    flex-shrink: 0;
}

.awke-form-field.awke-label-above .awke-field-input {
    width: 100%;
}

/* Inline Left Label - Using CSS Grid with percentage widths */
.awke-form-field.awke-label-inline-left {
    display: grid;
    grid-template-columns: 30% 65%;
    gap: 5%;
    align-items: center;
}

.awke-form-field.awke-label-inline-left label {
    width: 100%;
    color: var(--awke-label-color);
    font-size: 14px;
    line-height: 1.4;
    display: flex;
    align-items: center;
    justify-self: start;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.awke-form-field.awke-label-inline-left .awke-field-input {
    width: 100%;
}

/* Inline Right Label - Using CSS Grid with percentage widths */
.awke-form-field.awke-label-inline-right {
    display: grid;
    grid-template-columns: 65% 30%;
    gap: 5%;
    align-items: center;
}

.awke-form-field.awke-label-inline-right label {
    width: 100%;
    color: var(--awke-label-color);
    font-size: 14px;
    line-height: 1.4;
    display: flex;
    align-items: center;
    justify-self: end;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.awke-form-field.awke-label-inline-right .awke-field-input {
    width: 100%;
}

/* Field Input Container */
.awke-field-input {
    flex: 1;
    min-width: 0;
    position: relative;
}

.awke-form-field input:not([type="checkbox"]):not([type="radio"]),
.awke-form-field textarea,
.awke-form-field select {
    width: 100%;
    height: var(--awke-input-height);
    padding: 0 16px;
    border: 1px solid var(--awke-input-border);
    border-radius: var(--awke-border-radius);
    background: var(--awke-input-bg);
    font-size: 16px;
    transition: all 0.2s ease;
}

.awke-form-field textarea {
    height: 120px;
    padding: 16px;
    resize: vertical;
}

/* Floating Label Animation */
.awke-form-field input:focus ~ label,
.awke-form-field input:not(:placeholder-shown) ~ label,
.awke-form-field textarea:focus ~ label,
.awke-form-field textarea:not(:placeholder-shown) ~ label,
.awke-form-field select:focus ~ label,
.awke-form-field select:not(:placeholder-shown) ~ label {
    top: 0;
    font-size: 12px;
    color: var(--awke-primary-color);
}

/* Focus States */
.awke-form-field input:focus,
.awke-form-field textarea:focus,
.awke-form-field select:focus {
    border-color: var(--awke-input-focus);
    box-shadow: 0 0 0 4px rgb(99 102 241 / 0.1);
    outline: none;
}

/* Checkbox and Radio */
.awke-form-field.checkbox,
.awke-form-field.radio {
    display: flex;
    align-items: center;
    gap: 8px;
}

.awke-form-field.checkbox label,
.awke-form-field.radio label {
    position: static;
    transform: none;
    padding: 0;
    pointer-events: auto;
}

/* Submit Button */
.awke-form-submit {
    margin-top: calc(var(--awke-form-spacing) * 1.5);
}

.awke-submit-button {
    width: 100%;
    height: var(--awke-input-height);
    background: var(--awke-primary-color);
    color: white;
    border: none;
    border-radius: var(--awke-border-radius);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.awke-submit-button:hover {
    filter: brightness(1.1);
}

.awke-submit-button:active {
    transform: translateY(1px);
}

/* Response Messages */
.awke-form-response {
    margin-top: var(--awke-form-spacing);
    padding: 12px;
    border-radius: var(--awke-border-radius);
    display: none;
}

.awke-form-response.success {
    background: rgb(34 197 94 / 0.1);
    color: var(--awke-success-color);
    display: block;
}

.awke-form-response.error {
    background: rgb(239 68 68 / 0.1);
    color: var(--awke-error-color);
    display: block;
}

/* Field Validation */
.awke-form-field.error input,
.awke-form-field.error textarea,
.awke-form-field.error select {
    border-color: var(--awke-error-color);
}

.awke-form-field.error label {
    color: var(--awke-error-color);
}

.awke-field-error {
    font-size: 12px;
    color: var(--awke-error-color);
    margin-top: 4px;
    display: none;
}

.awke-form-field.error .awke-field-error {
    display: block;
}

/* Loading State */
.awke-submit-button.loading {
    position: relative;
    color: transparent;
}

.awke-submit-button.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: awke-spin 0.6s linear infinite;
}

@keyframes awke-spin {
    to { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .awke-layout-two-column .awke-contact-form {
        grid-template-columns: 1fr;
    }

    .awke-layout-floating {
        position: fixed;
        bottom: 0;
        right: 0;
        left: 0;
        margin: 0;
        border-radius: var(--awke-border-radius) var(--awke-border-radius) 0 0;
    }

    /* Stack inline labels on mobile */
    .awke-form-field.awke-label-inline-left,
    .awke-form-field.awke-label-inline-right {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .awke-form-field.awke-label-inline-left label,
    .awke-form-field.awke-label-inline-right label {
        justify-self: start;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .awke-form-field label,
    .awke-form-field input,
    .awke-form-field textarea,
    .awke-form-field select,
    .awke-submit-button {
        transition: none;
    }
}

/* High Contrast Mode */
@media (forced-colors: active) {
    .awke-form-field input,
    .awke-form-field textarea,
    .awke-form-field select {
        border: 2px solid ButtonText;
    }

    .awke-submit-button {
        border: 2px solid ButtonText;
    }
}
