/*
    TechDwar Solutions — Advanced Features CSS
    Page Loader, AI Chatbot, Voice Search, Smart Form, 
    Scroll Animations, Sticky Navbar Enhancements
*/

/* ================================================================
   1. PAGE LOADING ANIMATION
   ================================================================ */
.loader-wrapper {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: linear-gradient(135deg, #0A1F44 0%, #050E22 50%, #0A1F44 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.6s ease, visibility 0.6s ease;
}

.loader-wrapper.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loader {
    position: relative;
    width: 80px;
    height: 80px;
}

.loader::before {
    content: 'T';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Poppins', sans-serif;
    font-weight: 800;
    font-size: 1.8rem;
    color: #D4AF37;
    animation: loader-pulse 1.2s ease-in-out infinite;
}

.loader::after {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    border: 3px solid transparent;
    border-top-color: #D4AF37;
    border-right-color: rgba(212, 175, 55, 0.3);
    animation: loader-spin 1s linear infinite;
}

/* Loader progress bar */
.loader-wrapper .loader-bar {
    width: 200px;
    height: 3px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    margin-top: 2rem;
    overflow: hidden;
}

.loader-wrapper .loader-bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #D4AF37, #E8C84A);
    border-radius: 10px;
    animation: loader-fill 1.5s ease-out forwards;
}

.loader-wrapper .loader-text {
    margin-top: 1rem;
    font-family: 'Poppins', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.3);
    animation: loader-text-pulse 1.5s ease-in-out infinite;
}

@keyframes loader-spin {
    to { transform: rotate(360deg); }
}

@keyframes loader-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.95); }
}

@keyframes loader-fill {
    0% { width: 0%; }
    50% { width: 65%; }
    80% { width: 88%; }
    100% { width: 100%; }
}

@keyframes loader-text-pulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.6; }
}


/* ================================================================
   2. AI CHATBOT WIDGET
   ================================================================ */
.chatbot-fab {
    position: fixed;
    bottom: 110px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0A1F44, #132D5E);
    border: 2px solid rgba(212, 175, 55, 0.25);
    color: #D4AF37;
    cursor: pointer;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 24px rgba(10, 31, 68, 0.35), 0 0 40px rgba(212, 175, 55, 0.08);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    animation: chatbot-breathe 3s ease-in-out infinite;
}

.chatbot-fab:hover {
    transform: scale(1.1) translateY(-3px);
    box-shadow: 0 10px 32px rgba(10, 31, 68, 0.45), 0 0 60px rgba(212, 175, 55, 0.15);
    border-color: rgba(212, 175, 55, 0.5);
}

.chatbot-fab .chatbot-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #34D399;
    border: 2px solid #0A1F44;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes chatbot-breathe {
    0%, 100% { box-shadow: 0 6px 24px rgba(10, 31, 68, 0.35), 0 0 40px rgba(212, 175, 55, 0.08); }
    50% { box-shadow: 0 8px 28px rgba(10, 31, 68, 0.4), 0 0 50px rgba(212, 175, 55, 0.12); }
}

/* Chatbot Panel */
.chatbot-panel {
    position: fixed;
    bottom: 170px;
    right: 24px;
    width: 380px;
    max-height: 520px;
    border-radius: 20px;
    background: #0E1726;
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5), 0 0 80px rgba(212, 175, 55, 0.05);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.85) translateY(20px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
}

.chatbot-panel.active {
    transform: scale(1) translateY(0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.chatbot-header {
    display: flex;
    align-items: center;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, #0A1F44, #132D5E);
    border-bottom: 1px solid rgba(212, 175, 55, 0.15);
    gap: 0.75rem;
}

.chatbot-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #D4AF37, #E8C84A);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Poppins', sans-serif;
    font-weight: 800;
    font-size: 0.9rem;
    color: #0A1F44;
    flex-shrink: 0;
}

.chatbot-header-info {
    flex: 1;
}

.chatbot-header-info h4 {
    font-size: 0.85rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
    line-height: 1.2;
}

.chatbot-header-info span {
    font-size: 0.7rem;
    color: #34D399;
    display: flex;
    align-items: center;
    gap: 4px;
}

.chatbot-header-info span::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #34D399;
}

.chatbot-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.chatbot-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* Messages Area */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 300px;
    scroll-behavior: smooth;
}

.chatbot-messages::-webkit-scrollbar { width: 4px; }
.chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(212, 175, 55, 0.2);
    border-radius: 4px;
}

.chatbot-msg {
    display: flex;
    gap: 0.5rem;
    animation: msg-slide-in 0.4s ease-out;
}

.chatbot-msg.bot { align-self: flex-start; }
.chatbot-msg.user { align-self: flex-end; flex-direction: row-reverse; }

.chatbot-msg-avatar {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    flex-shrink: 0;
}

.chatbot-msg.bot .chatbot-msg-avatar {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.15), rgba(212, 175, 55, 0.05));
    color: #D4AF37;
}

.chatbot-msg.user .chatbot-msg-avatar {
    background: rgba(99, 138, 201, 0.15);
    color: #60A5FA;
}

.chatbot-msg-bubble {
    padding: 0.75rem 1rem;
    border-radius: 14px;
    font-size: 0.82rem;
    line-height: 1.55;
    max-width: 260px;
}

.chatbot-msg.bot .chatbot-msg-bubble {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: #CBD5E1;
    border-bottom-left-radius: 4px;
}

.chatbot-msg.user .chatbot-msg-bubble {
    background: linear-gradient(135deg, #0A1F44, #132D5E);
    border: 1px solid rgba(212, 175, 55, 0.15);
    color: #E2E8F0;
    border-bottom-right-radius: 4px;
}

/* Typing Indicator */
.chatbot-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}

.chatbot-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #D4AF37;
    animation: typing-dot 1.4s ease-in-out infinite;
}
.chatbot-typing span:nth-child(2) { animation-delay: 0.2s; }
.chatbot-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-dot {
    0%, 60%, 100% { opacity: 0.2; transform: scale(0.8); }
    30% { opacity: 1; transform: scale(1.1); }
}

/* Quick Replies */
.chatbot-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0 1.25rem 0.75rem;
}

.chatbot-quick-btn {
    padding: 0.4rem 0.85rem;
    border-radius: 20px;
    border: 1px solid rgba(212, 175, 55, 0.2);
    background: rgba(212, 175, 55, 0.06);
    color: #D4AF37;
    font-size: 0.72rem;
    font-weight: 600;
    font-family: 'Poppins', sans-serif;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}

.chatbot-quick-btn:hover {
    background: rgba(212, 175, 55, 0.15);
    border-color: rgba(212, 175, 55, 0.4);
    transform: translateY(-1px);
}

/* Input Area */
.chatbot-input-area {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(0, 0, 0, 0.15);
}

.chatbot-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 0.6rem 1rem;
    color: #E2E8F0;
    font-family: 'Inter', sans-serif;
    font-size: 0.82rem;
    transition: all 0.3s;
    outline: none;
}

.chatbot-input:focus {
    border-color: rgba(212, 175, 55, 0.3);
    background: rgba(255, 255, 255, 0.06);
}

.chatbot-input::placeholder { color: #4B5563; }

.chatbot-send {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, #D4AF37, #E8C84A);
    color: #0A1F44;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    flex-shrink: 0;
}

.chatbot-send:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(212, 175, 55, 0.3);
}

@keyframes msg-slide-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Mobile chatbot */
@media (max-width: 480px) {
    .chatbot-panel {
        width: calc(100vw - 32px);
        right: 16px;
        bottom: 160px;
        max-height: 450px;
    }
}


/* ================================================================
   3. VOICE SEARCH
   ================================================================ */
.voice-search-btn {
    position: relative;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: 1px solid rgba(10, 31, 68, 0.08);
    background: var(--bg-light, #F8FAFC);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    z-index: 10;
    color: var(--text-body, #475569);
}

.voice-search-btn:hover {
    background: var(--bg-blue-subtle, #EEF2FF);
    border-color: var(--accent, #D4AF37);
    color: var(--accent, #D4AF37);
    transform: scale(1.05);
}

[data-theme='dark'] .voice-search-btn {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
    color: #94A3B8;
}

[data-theme='dark'] .voice-search-btn:hover {
    background: rgba(240, 208, 96, 0.1);
    border-color: #F0D060;
    color: #F0D060;
}

/* Voice Search Overlay */
.voice-overlay {
    position: fixed;
    inset: 0;
    z-index: 99998;
    background: rgba(10, 31, 68, 0.92);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s ease;
}

.voice-overlay.active {
    opacity: 1;
    visibility: visible;
}

.voice-overlay-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    font-size: 1.5rem;
}

.voice-overlay-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.voice-mic-ring {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(212, 175, 55, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.voice-mic-ring.listening {
    animation: voice-ring-pulse 1.5s ease-in-out infinite;
}

.voice-mic-ring::before {
    content: '';
    position: absolute;
    inset: -15px;
    border-radius: 50%;
    border: 2px solid rgba(212, 175, 55, 0.1);
}

.voice-mic-ring.listening::before {
    animation: voice-ring-expand 1.5s ease-in-out infinite;
}

.voice-mic-ring::after {
    content: '';
    position: absolute;
    inset: -30px;
    border-radius: 50%;
    border: 1px solid rgba(212, 175, 55, 0.05);
}

.voice-mic-ring.listening::after {
    animation: voice-ring-expand 1.5s ease-in-out infinite 0.3s;
}

.voice-mic-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #D4AF37, #E8C84A);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0A1F44;
    box-shadow: 0 0 40px rgba(212, 175, 55, 0.3);
    transition: all 0.3s;
}

.voice-mic-ring.listening .voice-mic-icon {
    box-shadow: 0 0 60px rgba(212, 175, 55, 0.5);
    animation: voice-mic-pulse 1s ease-in-out infinite;
}

.voice-status {
    font-family: 'Poppins', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    letter-spacing: 0.5px;
}

.voice-transcript {
    font-family: 'Inter', sans-serif;
    font-size: 1.5rem;
    font-weight: 300;
    color: #D4AF37;
    max-width: 500px;
    text-align: center;
    min-height: 2rem;
    line-height: 1.4;
}

.voice-hint {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.3);
    text-align: center;
    max-width: 300px;
    line-height: 1.6;
}

@keyframes voice-ring-pulse {
    0%, 100% { background: rgba(212, 175, 55, 0.08); }
    50% { background: rgba(212, 175, 55, 0.15); }
}

@keyframes voice-ring-expand {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.15); opacity: 0.2; }
}

@keyframes voice-mic-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}


/* ================================================================
   4. SMART CONTACT FORM ENHANCEMENTS
   ================================================================ */
/* Floating Labels */
.smart-form-group {
    position: relative;
}

.smart-form-group .form-input.has-value + .form-label,
.smart-form-group .form-input:focus + .form-label {
    transform: translateY(-28px) scale(0.85);
    color: var(--accent, #D4AF37);
}

/* Validation States */
.form-input.valid {
    border-color: #34D399 !important;
}

.form-input.invalid {
    border-color: #EF4444 !important;
}

.form-validation-icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    opacity: 0;
    transition: all 0.3s;
}

.form-validation-icon.show { opacity: 1; }

.form-validation-icon.valid { color: #34D399; }
.form-validation-icon.invalid { color: #EF4444; }

/* Character Counter */
.char-counter {
    text-align: right;
    font-size: 0.72rem;
    color: var(--text-muted, #94A3B8);
    margin-top: 0.25rem;
    transition: color 0.3s;
}

.char-counter.warning { color: #F59E0B; }
.char-counter.danger { color: #EF4444; }

/* Auto-save indicator */
.form-autosave {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.72rem;
    color: var(--text-muted, #94A3B8);
    padding: 0.5rem 0;
    opacity: 0;
    transition: opacity 0.3s;
}

.form-autosave.visible { opacity: 1; }

.form-autosave svg {
    width: 14px;
    height: 14px;
    color: #34D399;
}


/* ================================================================
   5. ENHANCED SCROLL ANIMATIONS
   ================================================================ */
/* Fade in up (default) */
.reveal {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), 
                transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal.animate-fade {
    opacity: 1;
    transform: translateY(0);
}

/* Slide from left */
.reveal-left {
    opacity: 0;
    transform: translateX(-60px);
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal-left.animate-fade {
    opacity: 1;
    transform: translateX(0);
}

/* Slide from right */
.reveal-right {
    opacity: 0;
    transform: translateX(60px);
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal-right.animate-fade {
    opacity: 1;
    transform: translateX(0);
}

/* Scale up */
.reveal-scale {
    opacity: 0;
    transform: scale(0.85);
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal-scale.animate-fade {
    opacity: 1;
    transform: scale(1);
}

/* Stagger delays */
.delay-100 { transition-delay: 0.1s !important; }
.delay-200 { transition-delay: 0.2s !important; }
.delay-300 { transition-delay: 0.3s !important; }
.delay-400 { transition-delay: 0.4s !important; }
.delay-500 { transition-delay: 0.5s !important; }
.delay-600 { transition-delay: 0.6s !important; }
.delay-700 { transition-delay: 0.7s !important; }


/* ================================================================
   6. STICKY NAVBAR ENHANCEMENTS
   ================================================================ */
/* Scroll progress bar */
.nav-progress-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    width: 0%;
    background: linear-gradient(90deg, #D4AF37, #E8C84A, #F7DC6F);
    transition: width 0.05s linear;
    z-index: 9999;
}

[data-theme='dark'] .nav-progress-bar {
    background: linear-gradient(90deg, #F0D060, #FDE68A);
}

/* Auto-hide navbar */
#main-nav {
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                background 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.4s ease !important;
}

#main-nav.nav-hidden {
    transform: translateY(-100%);
}

#main-nav.nav-visible {
    transform: translateY(0);
}


/* ================================================================
   UTILITY: hide on mobile / show on desktop
   ================================================================ */
.desktop-only {
    display: none;
}

@media (min-width: 1024px) {
    .desktop-only {
        display: block;
    }
}
