/**
 * UI Feedback Styles
 * Loading states, animations, and visual feedback
 */

/* ==========================================
   BUTTON LOADING STATES
   ========================================== */

.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.8;
}

.btn-loading .fa-spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Disabled button styling */
button:disabled,
.btn:disabled,
input[type="submit"]:disabled {
    cursor: not-allowed;
    opacity: 0.65;
}

/* ==========================================
   SHAKE ANIMATION (for validation errors)
   ========================================== */

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

.shake-animation {
    animation: shake 0.5s ease-in-out;
}

/* ==========================================
   PULSE ANIMATION (for attention)
   ========================================== */

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(107, 143, 170, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(107, 143, 170, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(107, 143, 170, 0);
    }
}

.pulse-animation {
    animation: pulse 1.5s ease-in-out infinite;
}

/* ==========================================
   FADE IN/OUT ANIMATIONS
   ========================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-out forwards;
}

.fade-out {
    animation: fadeOut 0.3s ease-out forwards;
}

/* ==========================================
   FORM VALIDATION STATES
   ========================================== */

/* Enhanced valid state - using site color palette */
.is-valid {
    border-color: #7FA574 !important;
}

.is-valid:focus {
    border-color: #7FA574 !important;
    box-shadow: 0 0 0 0.2rem rgba(127, 165, 116, 0.25) !important;
}

.valid-feedback {
    color: #7FA574;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Enhanced invalid state */
.is-invalid {
    border-color: #B37168 !important;
}

.is-invalid:focus {
    border-color: #B37168 !important;
    box-shadow: 0 0 0 0.2rem rgba(179, 113, 104, 0.25) !important;
}

.invalid-feedback {
    color: #B37168;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Validation icon indicators */
.form-control.is-valid {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%237FA574' d='M2.3 6.73L.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
    padding-right: calc(1.5em + 0.75rem);
}

.form-control.is-invalid {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23B37168'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23B37168' stroke='none'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
    padding-right: calc(1.5em + 0.75rem);
}

/* ==========================================
   LOADING OVERLAY
   ========================================== */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    backdrop-filter: blur(2px);
}

.loading-overlay .spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #6B8FAA;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-overlay .loading-text {
    margin-top: 15px;
    color: #5A5147;
    font-size: 1.1rem;
}

/* ==========================================
   SKELETON LOADING PLACEHOLDERS
   ========================================== */

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

.skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
}

.skeleton-text:last-child {
    width: 70%;
}

.skeleton-circle {
    border-radius: 50%;
}

.skeleton-button {
    height: 38px;
    width: 100px;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ==========================================
   SUCCESS CHECKMARK ANIMATION
   ========================================== */

.checkmark-circle {
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    stroke-width: 2;
    stroke-miterlimit: 10;
    stroke: #7FA574;
    fill: none;
    animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.checkmark {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: block;
    stroke-width: 2;
    stroke: #fff;
    stroke-miterlimit: 10;
    margin: 10% auto;
    box-shadow: inset 0px 0px 0px #7FA574;
    animation: fill 0.4s ease-in-out 0.4s forwards, scale 0.3s ease-in-out 0.9s both;
}

.checkmark-check {
    transform-origin: 50% 50%;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
}

@keyframes stroke {
    100% {
        stroke-dashoffset: 0;
    }
}

@keyframes scale {
    0%, 100% {
        transform: none;
    }
    50% {
        transform: scale3d(1.1, 1.1, 1);
    }
}

@keyframes fill {
    100% {
        box-shadow: inset 0px 0px 0px 30px #7FA574;
    }
}

/* ==========================================
   CONFIRM BUTTON STYLES
   ========================================== */

.btn-confirm-delete {
    background-color: #B37168;
    border-color: #B37168;
    color: #fff;
}

.btn-confirm-delete:hover {
    background-color: #9a5f57;
    border-color: #9a5f57;
    color: #fff;
}

.btn-confirm-cancel {
    background-color: #6c757d;
    border-color: #6c757d;
    color: #fff;
}

/* ==========================================
   SWEETALERT2 THEME CUSTOMIZATION
   ========================================== */

/* Custom SweetAlert2 styling to match site theme */
.swal2-popup {
    font-family: inherit;
    border-radius: 0.5rem;
}

.swal2-title {
    color: #5A5147;
}

.swal2-html-container {
    color: #666;
}

.swal2-confirm {
    background-color: #6B8FAA !important;
    border-radius: 0.375rem !important;
}

.swal2-cancel {
    background-color: #B37168 !important;
    border-radius: 0.375rem !important;
}

.swal2-deny {
    background-color: #D4A574 !important;
    border-radius: 0.375rem !important;
}

/* Success icon color */
.swal2-icon.swal2-success {
    border-color: #7FA574;
    color: #7FA574;
}

.swal2-icon.swal2-success [class^='swal2-success-line'] {
    background-color: #7FA574;
}

.swal2-icon.swal2-success .swal2-success-ring {
    border-color: rgba(127, 165, 116, 0.3);
}

/* Warning icon color */
.swal2-icon.swal2-warning {
    border-color: #D4A574;
    color: #D4A574;
}

/* Error icon color */
.swal2-icon.swal2-error {
    border-color: #B37168;
    color: #B37168;
}

.swal2-icon.swal2-error [class^='swal2-x-mark-line'] {
    background-color: #B37168;
}

/* Info icon color */
.swal2-icon.swal2-info {
    border-color: #6B8FAA;
    color: #6B8FAA;
}

/* Question icon color */
.swal2-icon.swal2-question {
    border-color: #6B8FAA;
    color: #6B8FAA;
}

/* Timer progress bar */
.swal2-timer-progress-bar {
    background: #6B8FAA;
}

/* ==========================================
   RESPONSIVE ADJUSTMENTS
   ========================================== */

@media (max-width: 576px) {
    .swal2-popup {
        padding: 1rem;
        font-size: 0.9rem;
    }

    .swal2-title {
        font-size: 1.25rem;
    }

    .swal2-actions {
        flex-direction: column;
        gap: 0.5rem;
    }

    .swal2-actions button {
        width: 100%;
        margin: 0 !important;
    }
}

/* ==========================================
   TRANSITION HELPERS
   ========================================== */

.transition-all {
    transition: all 0.3s ease;
}

.transition-opacity {
    transition: opacity 0.3s ease;
}

.transition-transform {
    transition: transform 0.3s ease;
}

/* Hover lift effect */
.hover-lift {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hover-lift:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Focus ring for accessibility */
.focus-ring:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(107, 143, 170, 0.3);
}
