/**
 * Fluent Forms Discount Code Validator
 * Frontend Styles
 */

/* Discount validation messages */
.discount-message {
    display: block;
    margin-top: 8px;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    transition: all 0.3s ease;
}

/* Loading message */
.discount-message-loading {
    background-color: #f8f9fa;
    color: #6c757d;
    border: 1px solid #dee2e6;
    animation: pulse 1.5s ease-in-out infinite;
}

/* Success message */
.discount-message-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

/* Error message */
.discount-message-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Pulse animation for loading */
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.6; }
    100% { opacity: 1; }
}

/* Valid discount field styling */
input.discount-valid {
    border-color: #28a745 !important;
    background-color: #f8fff9 !important;
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25) !important;
}

input.discount-valid:focus {
    border-color: #28a745 !important;
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25) !important;
}

/* Fluent Forms specific adjustments */
.fluentform .ff-el-group .discount-message {
    margin-top: 5px;
    font-size: 13px;
}

.fluentform .ff-el-input--content .discount-message {
    margin-top: 5px;
    font-size: 13px;
}

/* Message icons */
.discount-message-success::before {
    content: "✓ ";
    margin-right: 4px;
}

.discount-message-error::before {
    content: "✗ ";
    margin-right: 4px;
}

.discount-message-loading::before {
    content: "⟳ ";
    margin-right: 4px;
    animation: spin 1s linear infinite;
}

/* Auto-populated field animation */
.auto-populated,
.discount-populated,
.field-populated {
    background-color: #e8f5e8 !important;
    transition: background-color 0.3s ease;
    border-color: #28a745 !important;
}

.auto-populated:focus,
.discount-populated:focus,
.field-populated:focus {
    background-color: #ffffff !important;
}

/* Custom discount percentage field styling for development */
.ff-discount-percentage-wrapper {
    margin-bottom: 15px;
}

.ff-discount-dev-field {
    border: 2px solid #007cba !important;
    background-color: #f0f8ff !important;
}

.discount-percentage-field,
.ff-dev-field {
    opacity: 1 !important;
    font-weight: bold !important;
    color: #333 !important;
}

/* Development field label styling */
.ff-discount-dev-field .ff-el-input--label label {
    color: #007cba !important;
    font-weight: bold !important;
    font-size: 14px !important;
}

/* Field populated animation for visible field */
.ff-dev-field.field-populated {
    background-color: #d4edda !important;
    border-color: #28a745 !important;
    animation: fieldPulse 0.5s ease-in-out;
}

@keyframes fieldPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

/* Help message styling for dev field */
.ff-discount-dev-field .ff-el-help-message {
    background-color: #fff3cd;
    border: 1px solid #ffeeba;
    padding: 8px;
    border-radius: 4px;
    margin-top: 5px;
}

.ff-discount-dev-field .ff-el-help-message small {
    color: #856404;
    font-weight: 500;
}

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

/* Responsive adjustments */
@media (max-width: 768px) {
    .discount-message {
        font-size: 12px;
        padding: 6px 10px;
    }
}

/* Dark theme support */
@media (prefers-color-scheme: dark) {
    .discount-message-loading {
        background-color: #2d3748;
        color: #a0aec0;
        border-color: #4a5568;
    }
    
    .discount-message-success {
        background-color: #1a365d;
        color: #68d391;
        border-color: #2d5016;
    }
    
    .discount-message-error {
        background-color: #742a2a;
        color: #feb2b2;
        border-color: #9b2c2c;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .discount-message {
        border-width: 2px;
        font-weight: 600;
    }
    
    input.discount-valid {
        border-width: 2px !important;
    }
}

/* Accessibility improvements */
.discount-message {
    role: alert;
    aria-live: polite;
}

.discount-message-error {
    role: alert;
    aria-live: assertive;
}

/* Focus states for keyboard navigation */
.discount-message:focus-within {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .discount-message-loading {
        display: none;
    }
    
    .discount-message-success,
    .discount-message-error {
        background: none !important;
        color: black !important;
        border: 1px solid black !important;
    }
}