/* assets/css/frontend.css - ENHANCED VERSION with Gravity Forms Integration */

/* Main evaluation button styling - Enhanced to match Gravity Forms */
.operaton-evaluate-btn {
    /* Use Gravity Forms CSS variables when available, fallback to custom colors */
    background: var(--gf-ctrl-btn-bg-color, #204ce5) !important;
    color: var(--gf-ctrl-btn-text-color, #ffffff) !important;
    border: 1px solid var(--gf-ctrl-btn-border-color, #204ce5) !important;
    border-radius: var(--gf-ctrl-border-radius, 3px) !important;
    
    /* Improved sizing and spacing */
    padding: 12px 24px !important;
    margin-left: 10px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    line-height: 1.2 !important;
    
    /* Better positioning and display */
    cursor: pointer !important;
    display: inline-block !important;
    vertical-align: middle !important;
    text-decoration: none !important;
    
    /* Smooth transitions */
    transition: all 0.2s ease !important;
    
    /* Remove default button styles */
    outline: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    
    /* Ensure consistent height with other buttons */
    min-height: 44px !important;
    box-sizing: border-box !important;
}

.operaton-evaluate-btn:hover {
    background: var(--gf-ctrl-btn-bg-color-hover, #1a3bb8) !important;
    border-color: var(--gf-ctrl-btn-border-color-hover, #1a3bb8) !important;
    color: var(--gf-ctrl-btn-text-color-hover, #ffffff) !important;
    transform: translateY(-1px) !important;
}

.operaton-evaluate-btn:active,
.operaton-evaluate-btn:focus {
    background: var(--gf-ctrl-btn-bg-color-active, #15338a) !important;
    border-color: var(--gf-ctrl-btn-border-color-active, #15338a) !important;
    transform: translateY(0) !important;
    outline: 2px solid #005fcc !important;
    outline-offset: 2px !important;
}

.operaton-evaluate-btn:disabled {
    background: #cccccc !important;
    border-color: #cccccc !important;
    color: #666666 !important;
    cursor: not-allowed !important;
    opacity: 0.7 !important;
    transform: none !important;
}

/* 2. UPDATE the button container section */
.gform_footer .gform_button_wrapper {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    flex-wrap: wrap !important;
}

/* Result container styling */
.operaton-result {
    display: block;
    margin: 20px 0;
    padding: 16px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    animation: fadeIn 0.3s ease-in;
}

.operaton-result h4 {
    margin: 0 0 8px 0 !important;
    font-size: 1.1em !important;
    color: #495057 !important;
    font-weight: 600 !important;
}

.operaton-result .result-content {
    margin: 0 !important;
    font-weight: 600 !important;
    color: #28a745 !important;
    font-size: 1.05em !important;
    word-wrap: break-word;
}

/* Loading spinner */
.operaton-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--gf-ctrl-btn-bg-color, #204ce5);
    border-radius: 50%;
    animation: operaton-spin 1s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes operaton-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

/* Integration with Gravity Forms styling */
.gform_wrapper .operaton-evaluate-btn {
    font-family: inherit;
    line-height: normal;
}

.gform_wrapper .operaton-result {
    font-family: inherit;
}

/* Container for button and result */
.gfield_operaton_result {
    margin-top: 20px !important;
}

.gfield_operaton_result .ginput_container {
    margin-top: 0 !important;
}

/* Success state styling */
.operaton-result.success {
    background-color: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.operaton-result.success .result-content {
    color: #155724 !important;
}

/* Error state styling */
.operaton-result.error {
    background-color: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

.operaton-result.error .result-content {
    color: #721c24 !important;
}

/* Warning state styling */
.operaton-result.warning {
    background-color: #fff3cd;
    border-color: #ffeaa7;
    color: #856404;
}

.operaton-result.warning .result-content {
    color: #856404 !important;
}

/* Button loading state */
.operaton-evaluate-btn.loading {
    position: relative;
    color: transparent !important;
}

.operaton-evaluate-btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid transparent;
    border-top: 2px solid white;
    border-radius: 50%;
    animation: operaton-spin 1s linear infinite;
}

/* Loading state for the entire result area */
.operaton-result.loading {
    background-color: #f8f9fa;
    color: #6c757d;
}

.operaton-result.loading .result-content {
    color: #6c757d !important;
}

/* Responsive design */
@media (max-width: 768px) {
    .gform_footer .gform_button_wrapper {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    
    .operaton-evaluate-btn {
        display: block !important;
        width: 100% !important;
        margin: 10px 0 !important;
        text-align: center !important;
    }
    
    .operaton-result {
        margin: 10px 0;
        padding: 12px;
    }
    
    .operaton-result h4 {
        font-size: 1em !important;
    }
    
    .operaton-result .result-content {
        font-size: 1em !important;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .operaton-result {
        background-color: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .operaton-result h4 {
        color: #e2e8f0 !important;
    }
    
    .operaton-result .result-content {
        color: #68d391 !important;
    }
    
    .operaton-result.error {
        background-color: #742a2a;
        border-color: #9b2c2c;
        color: #fed7d7;
    }
    
    .operaton-result.error .result-content {
        color: #fed7d7 !important;
    }
    
    .operaton-result.warning {
        background-color: #744210;
        border-color: #975a16;
        color: #faf089;
    }
    
    .operaton-result.warning .result-content {
        color: #faf089 !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .operaton-evaluate-btn {
        border-width: 2px !important;
    }
    
    .operaton-result {
        border-width: 2px !important;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .operaton-spinner {
        animation: none;
    }
    
    .operaton-result {
        animation: none;
    }
    
    .operaton-evaluate-btn {
        transition: none !important;
    }
    
    .operaton-evaluate-btn:hover {
        transform: none !important;
    }
    
    .operaton-evaluate-btn:active {
        transform: none !important;
    }
}

/* Print styles */
@media print {
    .operaton-evaluate-btn {
        display: none !important;
    }
    
    .operaton-result {
        border: 1px solid #000 !important;
        background: white !important;
        color: black !important;
        box-shadow: none !important;
    }
    
    .operaton-result .result-content {
        color: black !important;
    }
}

/* Responsive design - maintain consistent heights */
@media (max-width: 768px) {
    .gform_footer .gform_button_wrapper {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    
    .operaton-evaluate-btn {
        display: block !important;
        width: 100% !important;
        margin: 10px 0 !important;
        text-align: center !important;
    }
    
    /* KEEP consistent heights even on mobile */
    .gform_wrapper .gform_footer input[type="submit"],
    .gform_wrapper .gform_footer input[type="button"],
    .gform_wrapper .gform_footer .operaton-evaluate-btn {
        height: 44px !important;
        min-height: 44px !important;
        max-height: 44px !important;
    }
}

/* Better integration with common themes */
.operaton-result p {
    margin: 0 !important;
}

.operaton-result * {
    box-sizing: border-box;
}

/* Compatibility with Gravity Forms conditional logic */
.gform_wrapper .gfield.gfield_operaton_result {
    display: block !important;
}

.gform_wrapper .gfield.gfield_operaton_result.gfield_hidden {
    display: none !important;
}

/* Force consistent button heights with more specific selectors */
.gform_wrapper .gform_footer input[type="submit"],
.gform_wrapper .gform_footer input[type="button"],
.gform_wrapper .gform_footer .operaton-evaluate-btn,
.gform_wrapper .gform_previous_button input,
.gform_wrapper .gform_next_button input,
.gform_wrapper .gform_footer .gform_previous_button input[type="button"],
.gform_wrapper .gform_footer .gform_next_button input[type="button"],
.gform_wrapper .gform_footer .gform_previous_button input[type="submit"],
.gform_wrapper .gform_footer .gform_next_button input[type="submit"] {
    min-height: 44px !important;
    max-height: 44px !important;
    height: 44px !important;
    padding: 12px 24px !important;
    line-height: 1.2 !important;
    box-sizing: border-box !important;
    font-size: 14px !important;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
    vertical-align: middle !important;
}

/* Override any flex height expansion */
.gform_wrapper .gform_footer .gform_button_wrapper {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    flex-wrap: wrap !important;
}

/* Ensure button containers don't expand */
.gform_wrapper .gform_footer .gform_button_wrapper > * {
    height: 44px !important;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
}

/* More specific targeting for Previous/Next buttons */
.gform_wrapper .gform_footer .gform_previous_button,
.gform_wrapper .gform_footer .gform_next_button {
    height: 44px !important;
    display: inline-block !important;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
}

/* Target the specific button containers */
.gform_wrapper .gform_previous_button input[type="button"],
.gform_wrapper .gform_next_button input[type="button"] {
    height: 44px !important;
    min-height: 44px !important;
    max-height: 44px !important;
    vertical-align: top !important;
}

/* Additional specificity for stubborn Previous buttons */
.gform_wrapper form .gform_footer .gform_previous_button input,
.gform_wrapper form .gform_footer .gform_previous_button input[type="button"],
.gform_wrapper form .gform_footer .gform_previous_button input[type="submit"],
body .gform_wrapper .gform_footer .gform_previous_button input {
    height: 44px !important;
    min-height: 44px !important;
    max-height: 44px !important;
    padding: 12px 24px !important;
    box-sizing: border-box !important;
    line-height: 1.2 !important;
    font-size: 14px !important;
}

/* Theme compatibility - works with most Gravity Forms themes */
.gform_wrapper.gravity-theme .operaton-evaluate-btn,
.gform_wrapper.gf_browser_chrome .operaton-evaluate-btn,
.gform_wrapper.gf_browser_safari .operaton-evaluate-btn {
    font-family: inherit !important;
}

/* Orbital theme specific adjustments */
.gform_wrapper.gf-orbital-theme .operaton-evaluate-btn {
    background: var(--gf-color-primary, #204ce5) !important;
    border-color: var(--gf-color-primary, #204ce5) !important;
}

.gform_wrapper.gf-orbital-theme .operaton-evaluate-btn:hover {
    background: var(--gf-color-primary-darker, #1a3bb8) !important;
    border-color: var(--gf-color-primary-darker, #1a3bb8) !important;
}

/* Legacy theme support */
.gform_wrapper.gf_browser_unknown .operaton-evaluate-btn {
    background: #0073aa !important;
    border-color: #0073aa !important;
}

.gform_wrapper.gf_browser_unknown .operaton-evaluate-btn:hover {
    background: #005a87 !important;
    border-color: #005a87 !important;
}

@keyframes operaton-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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