/* assets/style.css */
@import url('https://fonts.googleapis.css2?family=Outfit:wght@300;400;600;800&display=swap');

:root {
    --bg-color: #14110f;
    --text-primary: #fdfaf6;
    --text-secondary: #a8a29e;
    --accent-color: #d97706;
    --accent-glow: rgba(217, 119, 6, 0.3);
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(217, 119, 6, 0.15);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    height: 100%;
    height: -webkit-fill-available;
}

body {
    font-family: 'Outfit', sans-serif;
    color: var(--text-primary);
    background-color: var(--bg-color);
    background-image:
        radial-gradient(circle at 15% 50%, rgba(217, 119, 6, 0.12), transparent 30%),
        radial-gradient(circle at 85% 30%, rgba(245, 158, 11, 0.1), transparent 30%);
    background-attachment: fixed;
    height: 100dvh;
    min-height: -webkit-fill-available;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.assistant-container {
    width: 100%;
    max-width: 700px;
    height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 2rem 2.5rem;
    position: relative;
    z-index: 10;
    animation: slideUpFade 0.8s ease-out;
}

@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.header {
    text-align: center;
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.header h1 {
    font-weight: 800;
    font-size: 1.75rem;
    background: linear-gradient(to right, #f59e0b, #fbbf24);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.25rem;
}

.header p {
    color: var(--text-secondary);
    font-weight: 300;
    font-size: 0.9rem;
}

/* Avatar Section */
.avatar-wrapper {
    position: relative;
    width: 160px;
    height: 160px;
    margin: 1rem auto;
    animation: float 6s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes float {
    0% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-12px);
    }

    100% {
        transform: translateY(0px);
    }
}

.avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--glass-border);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    z-index: 2;
}

/* Speaking Animation */
.avatar-wrapper.speaking .avatar {
    box-shadow: 0 0 50px var(--accent-color);
    transform: scale(1.05);
    border-color: var(--accent-color);
}

.avatar-wrapper.speaking::before,
.avatar-wrapper.speaking::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--accent-glow);
    transform: translate(-50%, -50%);
    z-index: 1;
    animation: pulse-ring 1.5s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

.avatar-wrapper.speaking::after {
    animation-delay: 0.5s;
}

@keyframes pulse-ring {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.8;
    }

    100% {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 0;
    }
}

/* Chat/Transcript Area */
.chat-window {
    width: 100%;
    flex: 1 1 0;
    min-height: 120px;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 24px;
    padding: 1.25rem;
    overflow-y: auto;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    scroll-behavior: smooth;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* Hide scrollbar */
.chat-window::-webkit-scrollbar {
    display: none;
}

.chat-window {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.message {
    padding: 0.85rem 1.1rem;
    border-radius: 18px;
    max-width: 85%;
    line-height: 1.45;
    font-size: 0.95rem;
    animation: fadeIn 0.3s ease forwards;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.ai {
    background: rgba(217, 119, 6, 0.15);
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    color: #e2e8f0;
}

.message.user {
    background: rgba(168, 162, 158, 0.2);
    border-bottom-right-radius: 4px;
    align-self: flex-end;
    color: white;
}

/* Payment Link Button inside chat */
.payment-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
    text-decoration: none;
    border-radius: 30px;
    font-weight: 600;
    font-size: 1rem;
    font-family: 'Outfit', sans-serif;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(34, 197, 94, 0.4);
    transition: transform 0.2s, box-shadow 0.3s;
    animation: pulseGreen 2s infinite;
}

.payment-link-btn:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 6px 20px rgba(34, 197, 94, 0.5);
}

@keyframes pulseGreen {
    0% {
        box-shadow: 0 4px 15px rgba(34, 197, 94, 0.4);
    }

    50% {
        box-shadow: 0 4px 25px rgba(34, 197, 94, 0.7);
    }

    100% {
        box-shadow: 0 4px 15px rgba(34, 197, 94, 0.4);
    }
}

/* Browser compatibility notice */
.browser-notice {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(234, 179, 8, 0.15);
    border: 1px solid rgba(234, 179, 8, 0.3);
    border-radius: 12px;
    color: #fbbf24;
    font-size: 0.8rem;
    text-align: center;
    margin-top: 5px;
}

/* Controls */
.controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    flex-shrink: 0;
}

.status-indicator {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    height: 20px;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #64748b;
    transition: background 0.3s;
}

.status-indicator.listening .dot {
    background: #ef4444;
    box-shadow: 0 0 10px #ef4444;
    animation: blink 1s infinite;
}

.status-indicator.processing .dot {
    background: #eab308;
    box-shadow: 0 0 10px #eab308;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

.mic-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #d97706, #f59e0b);
    color: white;
    font-size: 1.4rem;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(59, 130, 246, 0.3);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mic-btn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 15px 25px rgba(59, 130, 246, 0.4);
}

.mic-btn.active {
    background: linear-gradient(135deg, #ef4444, #f43f5e);
    box-shadow: 0 10px 20px rgba(239, 68, 68, 0.4);
    animation: mic-pulse 2s infinite;
}

@keyframes mic-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5);
    }

    70% {
        box-shadow: 0 0 0 20px rgba(239, 68, 68, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

.mic-hint-text {
    font-size: 0.78rem;
    color: var(--text-secondary);
    text-align: center;
    margin-top: -6px;
}

/* Fixed Text Input */
.fixed-text-input-container {
    width: 100%;
    max-width: 440px;
    display: flex;
    gap: 8px;
    margin-top: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 30px;
    padding: 5px;
    backdrop-filter: blur(10px);
    transition: border-color 0.3s;
}

.fixed-text-input-container:focus-within {
    border-color: rgba(217, 119, 6, 0.5);
}

#mainTextInput {
    flex-grow: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 10px 15px;
    font-size: 16px;
    /* 16px prevents iOS zoom */
    font-family: 'Outfit', sans-serif;
}

#mainTextInput:focus {
    outline: none;
}

#mainTextInput::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

#mainTextSubmit {
    background: var(--accent-color);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    transition: transform 0.2s, background 0.3s;
    flex-shrink: 0;
}

#mainTextSubmit:hover {
    transform: scale(1.05);
    background: #b45309;
}

#mainTextSubmit:active {
    transform: scale(0.95);
}

/* Audio Visualizer */
.visualizer {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 30px;
    opacity: 0;
    transition: opacity 0.3s;
}

.visualizer.active {
    opacity: 1;
}

.bar {
    width: 4px;
    height: 10px;
    background: var(--accent-color);
    border-radius: 4px;
}

.visualizer.active .bar {
    animation: wave linear infinite;
}

.visualizer .bar:nth-child(1) {
    animation-duration: 0.6s;
}

.visualizer .bar:nth-child(2) {
    animation-duration: 0.4s;
}

.visualizer .bar:nth-child(3) {
    animation-duration: 0.7s;
}

.visualizer .bar:nth-child(4) {
    animation-duration: 0.5s;
}

.visualizer .bar:nth-child(5) {
    animation-duration: 0.6s;
}

@keyframes wave {
    0% {
        height: 10px;
    }

    50% {
        height: 30px;
    }

    100% {
        height: 10px;
    }
}

/* Admin Login Button */
.admin-login-btn {
    position: absolute;
    right: 1rem;
    top: 1rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 1.3rem;
    transition: all 0.3s ease;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.admin-login-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
    box-shadow: 0 0 15px var(--glass-border);
}

/* Checkout Overlay Iframe */
.checkout-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: none;
    background: var(--bg-color);
    flex-direction: column;
}

.checkout-overlay.active {
    display: flex;
}

.checkout-iframe {
    width: 100%;
    flex-grow: 1;
    border: none;
    background: #fff;
}

.close-checkout-btn {
    position: absolute;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    background: linear-gradient(135deg, #ef4444, #f43f5e);
    color: white;
    border: none;
    border-radius: 30px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10000;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
    font-size: 1rem;
    transition: transform 0.2s;
}

.close-checkout-btn:hover {
    transform: translateX(-50%) scale(1.05);
}

/* ========================================
   RESPONSIVE: Mobile (Small phones ≤ 480px)
   ======================================== */
@media (max-width: 480px) {
    body {
        justify-content: flex-start;
    }

    .assistant-container {
        height: 100dvh;
        height: -webkit-fill-available;
        padding: 0.75rem 0.75rem;
        padding-top: max(0.75rem, env(safe-area-inset-top));
        padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
        border-radius: 0;
        justify-content: flex-start;
    }

    .header {
        margin-bottom: 0.5rem;
    }

    .header h1 {
        font-size: 1.3rem;
    }

    .header p {
        font-size: 0.8rem;
    }

    .avatar-wrapper {
        width: 90px;
        height: 90px;
        margin: 0.5rem auto;
    }

    .chat-window {
        border-radius: 18px;
        padding: 0.85rem;
        margin-bottom: 0.6rem;
        gap: 0.5rem;
    }

    .message {
        padding: 0.7rem 0.9rem;
        font-size: 0.88rem;
        max-width: 90%;
        border-radius: 16px;
    }

    .controls {
        gap: 0.5rem;
    }

    .mic-btn {
        width: 52px;
        height: 52px;
        font-size: 1.2rem;
    }

    .mic-hint-text {
        font-size: 0.72rem;
    }

    .fixed-text-input-container {
        max-width: 100%;
        margin-top: 4px;
    }

    .status-indicator {
        font-size: 0.78rem;
    }

    .admin-login-btn {
        width: 34px;
        height: 34px;
        font-size: 1.1rem;
        right: 0.5rem;
        top: 0.5rem;
    }

    .payment-link-btn {
        padding: 10px 18px;
        font-size: 0.9rem;
    }
}

/* ============================================
   RESPONSIVE: Mobile landscape / mid (481-640px)
   ============================================ */
@media (min-width: 481px) and (max-width: 640px) {
    .assistant-container {
        height: 100dvh;
        height: -webkit-fill-available;
        padding: 1rem;
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }

    .avatar-wrapper {
        width: 110px;
        height: 110px;
        margin: 0.7rem auto;
    }

    .header h1 {
        font-size: 1.45rem;
    }

    .chat-window {
        border-radius: 20px;
        padding: 1rem;
    }

    .mic-btn {
        width: 56px;
        height: 56px;
    }
}

/* ============================================
   RESPONSIVE: Tablet (641px - 1024px)
   ============================================ */
@media (min-width: 641px) and (max-width: 1024px) {
    .assistant-container {
        height: 92vh;
        padding: 1.5rem 2rem;
        max-width: 650px;
    }

    .avatar-wrapper {
        width: 140px;
        height: 140px;
        margin: 1rem auto;
    }

    .header h1 {
        font-size: 1.6rem;
    }
}

/* ============================================
   RESPONSIVE: Desktop (> 1024px)
   ============================================ */
@media (min-width: 1025px) {
    .assistant-container {
        max-width: 700px;
        height: 88vh;
        padding: 2rem 2.5rem;
        background: rgba(15, 23, 42, 0.2);
        border: 1px solid rgba(255, 255, 255, 0.06);
        border-radius: 32px;
        box-shadow: 0 30px 60px -15px rgba(0, 0, 0, 0.4);
    }

    .chat-window {
        min-height: 200px;
    }
}