/**
 * Voice-to-Form Animations & Styling
 * Part of 0nida-advanced WordPress plugin
 */

/* =========================
   LLM Processing Overlay
   ========================= */
.voice-llm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.3s ease-out;
}

.voice-llm-overlay-content {
    background: white;
    border-radius: 24px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    animation: slideUp 0.4s ease-out;
}

.voice-llm-spinner {
    margin: 0 auto 20px;
    width: 50px;
    height: 50px;
}

@keyframes rotate {
    to { transform: rotate(360deg); }
}

@keyframes dash {
    0% {
        stroke-dasharray: 1, 150;
        stroke-dashoffset: 0;
    }
    50% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -35;
    }
    100% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -124;
    }
}

.voice-llm-status {
    font-size: 1.2rem;
    font-weight: 700;
    color: #6d2f8a;
    margin: 0 0 8px;
}

.voice-llm-substatus {
    font-size: 0.9rem;
    color: #6b7280;
    margin: 0;
}

/* =========================
   Edit Button Styling
   ========================= */
.voice-edit-btn {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: linear-gradient(135deg, #6d2f8a 0%, #8b5cf6 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(109, 47, 138, 0.2);
}

.voice-edit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(109, 47, 138, 0.3);
}

.voice-edit-btn:active {
    transform: translateY(0);
}

.voice-edit-btn svg {
    width: 16px;
    height: 16px;
}

/* =========================
   Field Fill Animation
   ========================= */
.field-filled {
    animation: fieldFill 1s ease-out;
}

@keyframes fieldFill {
    0% {
        transform: translateX(-10px);
        opacity: 0;
    }
    60% {
        transform: translateX(5px);
    }
    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Highlight animation for filled fields */
.voice-form-section.field-filled {
    animation: sectionHighlight 1.5s ease-out;
}

@keyframes sectionHighlight {
    0% {
        background: rgba(109, 47, 138, 0.05);
        transform: scale(1);
    }
    50% {
        background: rgba(109, 47, 138, 0.1);
        transform: scale(1.005);
    }
    100% {
        background: transparent;
        transform: scale(1);
    }
}

/* =========================
   Form Section Transitions
   ========================= */
.voice-form-section {
    opacity: 1;
    transform: translateY(0);
    /* Sections are visible by default */
}

/* Animation when LLM fills data */
.voice-form-section.llm-filling {
    animation: sectionHighlight 0.8s ease-out;
}

@keyframes sectionAppear {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =========================
   Input Field Animations
   ========================= */
input.field-filled,
textarea.field-filled,
select.field-filled {
    animation: inputPulse 0.6s ease-out;
}

@keyframes inputPulse {
    0% {
        background: rgba(34, 197, 94, 0.1);
        border-color: #22c55e;
    }
    100% {
        background: #fafafa;
        border-color: #f3f4f6;
    }
}

/* Success checkmark animation */
.field-success-check {
    display: inline-block;
    width: 16px;
    height: 16px;
    background: #22c55e;
    border-radius: 50%;
    position: relative;
    margin-left: 8px;
    animation: checkmarkPop 0.4s ease-out;
}

.field-success-check::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

@keyframes checkmarkPop {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* =========================
   Toast Enhancements
   ========================= */
#toast.success {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
}

#toast.error {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

/* =========================
   Loading States
   ========================= */
.voice-loading {
    position: relative;
    pointer-events: none;
}

.voice-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: inherit;
}

/* =========================
   Progressive Disclosure
   ========================= */
.disabled-field {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.disabled-field:not([style*="display: none"]) {
    opacity: 0.5;
    pointer-events: none;
    transform: scale(0.98);
}

/* When enabled */
.card:not(.disabled-field) {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* =========================
   Readonly Textarea Styling
   ========================= */
textarea[readonly] {
    background: #fafafa;
    cursor: default;
    user-select: text;
}

textarea:not([readonly]) {
    background: #fff;
    box-shadow: 0 0 0 3px rgba(109, 47, 138, 0.1);
}

/* =========================
   General Animations
   ========================= */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* =========================
   Mobile Responsiveness
   ========================= */
@media (max-width: 768px) {
    .voice-llm-overlay-content {
        padding: 30px 20px;
        max-width: 90%;
    }
    
    .voice-edit-btn {
        font-size: 0.8rem;
        padding: 6px 12px;
    }
}

/* =========================
   Accessibility
   ========================= */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus visible for keyboard navigation */
.voice-edit-btn:focus-visible {
    outline: 2px solid #6d2f8a;
    outline-offset: 2px;
}

