/**
 * Frontend styles for Form Builder - Modern White Design with Animations.
 *
 * @package DNestFormBuilder
 */

/* ============================================
   FORM CONTAINER - Modern White Design
   ============================================ */
.dnest-fb-form {
    width: 100%;
    max-width: 100%;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    padding: 40px;
    animation: fadeInUp 0.6s ease-out;
    position: relative;
    overflow: hidden;
}

.dnest-fb-form::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    animation: slideInLeft 0.8s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}

.dnest-fb-form.dnest-fb-layout-boxed {
    max-width: 700px;
    margin: 0 auto;
}

.dnest-fb-form.dnest-fb-layout-full {
    width: 100%;
}

.dnest-fb-form.dnest-fb-layout-inline .dnest-fb-fields-wrapper {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 15px;
}

.dnest-fb-form.dnest-fb-layout-inline .dnest-fb-submit-wrapper {
    display: inline-block;
}

/* ============================================
   FIELDS WRAPPER - Grid Layout
   ============================================ */
.dnest-fb-fields-wrapper {
    display: grid;
    gap: 28px;
    margin-bottom: 32px;
}

.dnest-fb-form.dnest-fb-columns-1 .dnest-fb-fields-wrapper {
    grid-template-columns: 1fr;
}

.dnest-fb-form.dnest-fb-columns-2 .dnest-fb-fields-wrapper {
    grid-template-columns: repeat(2, 1fr);
}

.dnest-fb-form.dnest-fb-columns-3 .dnest-fb-fields-wrapper {
    grid-template-columns: repeat(3, 1fr);
}

.dnest-fb-form.dnest-fb-columns-4 .dnest-fb-fields-wrapper {
    grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 768px) {
    .dnest-fb-form {
        padding: 30px 20px;
    }
    
    .dnest-fb-form.dnest-fb-columns-2 .dnest-fb-fields-wrapper,
    .dnest-fb-form.dnest-fb-columns-3 .dnest-fb-fields-wrapper,
    .dnest-fb-form.dnest-fb-columns-4 .dnest-fb-fields-wrapper {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   FIELD WRAPPER - Animated Container
   ============================================ */
.dnest-fb-field-wrapper {
    position: relative;
    animation: fadeIn 0.5s ease-out;
    animation-fill-mode: both;
}

.dnest-fb-field-wrapper:nth-child(1) { animation-delay: 0.1s; }
.dnest-fb-field-wrapper:nth-child(2) { animation-delay: 0.2s; }
.dnest-fb-field-wrapper:nth-child(3) { animation-delay: 0.3s; }
.dnest-fb-field-wrapper:nth-child(4) { animation-delay: 0.4s; }
.dnest-fb-field-wrapper:nth-child(5) { animation-delay: 0.5s; }
.dnest-fb-field-wrapper:nth-child(6) { animation-delay: 0.6s; }

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

.dnest-fb-field-wrapper.dnest-fb-field-width-full {
    grid-column: 1 / -1;
}

.dnest-fb-field-wrapper.dnest-fb-field-width-half {
    grid-column: span 1;
}

/* ============================================
   LABEL - Modern Typography
   ============================================ */
.dnest-fb-label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    font-size: 14px;
    color: #2d3748;
    letter-spacing: 0.3px;
    transition: color 0.3s ease;
}

.dnest-fb-field-wrapper:focus-within .dnest-fb-label {
    color: #667eea;
}

.dnest-fb-required {
    color: #f56565;
    margin-left: 4px;
    font-weight: 700;
}

/* ============================================
   INPUT FIELDS - Modern White Design
   ============================================ */
.dnest-fb-field {
    width: 100%;
    padding: 16px 20px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 15px;
    line-height: 1.5;
    color: #2d3748;
    background: #ffffff;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    outline: none;
    position: relative;
}

.dnest-fb-field::placeholder {
    color: #a0aec0;
    opacity: 1;
}

.dnest-fb-field:hover {
    border-color: #cbd5e0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.dnest-fb-field:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1), 0 4px 12px rgba(102, 126, 234, 0.15);
    transform: translateY(-1px);
}

.dnest-fb-field:focus::placeholder {
    color: #cbd5e0;
}

.dnest-fb-field[type="file"] {
    padding: 12px;
    cursor: pointer;
}

.dnest-fb-field[type="file"]:hover {
    background: #f7fafc;
}

.dnest-fb-field[type="checkbox"],
.dnest-fb-field[type="radio"] {
    width: auto;
    margin-right: 10px;
    cursor: pointer;
    width: 20px;
    height: 20px;
    accent-color: #667eea;
}

/* ============================================
   TEXTAREA - Enhanced Styling
   ============================================ */
.dnest-fb-field[type="textarea"],
textarea.dnest-fb-field {
    min-height: 140px;
    resize: vertical;
    font-family: inherit;
}

/* ============================================
   SELECT - Custom Styled Dropdown
   ============================================ */
select.dnest-fb-field {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='%23667eea' d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 16px;
    padding-right: 48px;
    appearance: none;
    cursor: pointer;
}

select.dnest-fb-field:hover {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='%234c51bf' d='M8 11L3 6h10z'/%3E%3C/svg%3E");
}

/* ============================================
   CHECKBOX & RADIO GROUPS
   ============================================ */
.dnest-fb-checkbox-group,
.dnest-fb-radio-group {
    margin-bottom: 0;
}

.dnest-fb-checkbox-options,
.dnest-fb-radio-options {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 16px;
    background: #f7fafc;
    border-radius: 12px;
    border: 2px solid #e2e8f0;
    transition: all 0.3s ease;
}

.dnest-fb-field-wrapper:focus-within .dnest-fb-checkbox-options,
.dnest-fb-field-wrapper:focus-within .dnest-fb-radio-options {
    border-color: #667eea;
    background: #ffffff;
}

.dnest-fb-checkbox-option,
.dnest-fb-radio-option {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.dnest-fb-checkbox-option:hover,
.dnest-fb-radio-option:hover {
    background: rgba(102, 126, 234, 0.05);
}

.dnest-fb-checkbox-option label,
.dnest-fb-radio-option label {
    margin-bottom: 0;
    font-weight: 500;
    color: #2d3748;
    cursor: pointer;
    margin-left: 8px;
}

/* ============================================
   DESCRIPTION - Subtle Text
   ============================================ */
.dnest-fb-description {
    margin-top: 8px;
    font-size: 13px;
    color: #718096;
    line-height: 1.5;
    font-style: italic;
}

/* ============================================
   ERROR MESSAGES - Animated Alerts
   ============================================ */
.dnest-fb-error {
    margin-top: 8px;
    min-height: 20px;
    animation: shake 0.4s ease-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    75% { transform: translateX(8px); }
}

.dnest-fb-field-error {
    display: block;
    color: #f56565;
    font-size: 13px;
    font-weight: 500;
    padding: 8px 12px;
    background: #fed7d7;
    border-left: 3px solid #f56565;
    border-radius: 6px;
    animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.dnest-fb-field:invalid:not(:focus):not(:placeholder-shown) {
    border-color: #f56565;
    background: #fff5f5;
}

/* ============================================
   SUBMIT BUTTON - Modern Animated Button
   ============================================ */
.dnest-fb-submit-wrapper {
    margin-top: 32px;
    text-align: center;
}

.dnest-fb-submit-button {
    padding: 16px 48px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    min-width: 180px;
}

.dnest-fb-submit-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s ease;
}

.dnest-fb-submit-button:hover::before {
    left: 100%;
}

.dnest-fb-submit-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

.dnest-fb-submit-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.4);
}

.dnest-fb-submit-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.dnest-fb-submit-button:disabled:hover {
    transform: none;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.dnest-fb-submit-button:not(:disabled) {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    }
    50% {
        box-shadow: 0 4px 20px rgba(102, 126, 234, 0.6);
    }
}

/* ============================================
   MESSAGES - Success/Error States
   ============================================ */
.dnest-fb-messages {
    margin-top: 24px;
    padding: 0;
    animation: fadeIn 0.4s ease-out;
}

.dnest-fb-messages.dnest-fb-success {
    animation: slideInDown 0.5s ease-out;
}

.dnest-fb-messages.dnest-fb-error {
    animation: shake 0.5s ease-out;
}

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

.dnest-fb-message {
    padding: 16px 20px;
    border-radius: 12px;
    font-weight: 500;
    font-size: 15px;
    line-height: 1.5;
    margin: 0;
    animation: fadeIn 0.3s ease-out;
}

.dnest-fb-message-success {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(72, 187, 120, 0.3);
}

.dnest-fb-message-error {
    background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(245, 101, 101, 0.3);
}

/* ============================================
   HTML BLOCK - Content Sections
   ============================================ */
.dnest-fb-html-block {
    margin: 24px 0;
    padding: 20px;
    background: #f7fafc;
    border-radius: 12px;
    border-left: 4px solid #667eea;
    animation: fadeIn 0.5s ease-out;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 768px) {
    .dnest-fb-form {
        padding: 24px 16px;
        border-radius: 12px;
    }
    
    .dnest-fb-field {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 14px 18px;
    }
    
    .dnest-fb-submit-button {
        width: 100%;
        padding: 18px 32px;
    }
    
    .dnest-fb-fields-wrapper {
        gap: 20px;
    }
}

/* ============================================
   LOADING STATE - Button Animation
   ============================================ */
.dnest-fb-submit-button.loading {
    position: relative;
    color: transparent;
}

.dnest-fb-submit-button.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   FOCUS VISIBLE - Accessibility
   ============================================ */
.dnest-fb-field:focus-visible,
.dnest-fb-submit-button:focus-visible {
    outline: 3px solid rgba(102, 126, 234, 0.5);
    outline-offset: 2px;
}

/* ============================================
   SMOOTH SCROLL TO MESSAGE
   ============================================ */
.dnest-fb-messages:target {
    scroll-margin-top: 20px;
}
