/* --------------  MOBILE-FIRST RESET  -------------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;   /* remove grey flash on tap */
}
html, body {
    height: 100%;
}
body {
    font-family: 'Georgia', 'Times New Roman', serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    display: flex;
    flex-direction: column;
    overflow: hidden;              /* kill bounce scroll */
    -webkit-user-select: none;     /* disable text-selection zoom */
    user-select: none;
}

/* --------------  VISITOR-COUNTER BANNER  -------------- */
.ad-banner {
    flex: 0 0 auto;
    padding: 8px 0;
    font-size: 11px;
    text-align: center;
    color: #ccc;
}

/* --------------  CHAT CONTAINER  -------------- */
.chat-container {
    flex: 1 1 auto;                /* fill remaining height */
    width: 100%;
    max-width: 100%;
    height: auto;                  /* override fixed 90vh */
    border-radius: 0;              /* edge-to-edge on phones */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: none;              /* native feel */
}
@media (min-width: 600px) {
    .chat-container {
        width: 90vw;
        max-width: 800px;
        height: 90vh;
        border-radius: 20px;
        box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
    }
}

/* --------------  HEADER  -------------- */
.chat-header {
    flex: 0 0 auto;
    background: linear-gradient(135deg, #0f3460 0%, #16213e 100%);
    color: #d4af37;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #d4af37;
}
.chat-header h1 {
    font-size: clamp(16px, 4.5vw, 24px);
    letter-spacing: .5px;
}
.chat-header p {
    font-size: clamp(9px, 2.2vw, 12px);
    opacity: .9;
}
.chat-header select,
.chat-header button {
    font-size: clamp(10px, 2.5vw, 12px);
    padding: 6px 10px;
}

/* --------------  MESSAGES AREA  -------------- */
.chat-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* smooth iOS scroll */
    padding: 12px;
    background: #f8f5f0;
    scroll-behavior: smooth;
}
.message {
    margin-bottom: 12px;
    display: flex;
    animation: slideIn .3s ease;
}
@keyframes slideIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
.message-content {
    max-width: 85%;                /* more space on small screens */
    padding: 10px 14px;
    border-radius: 18px;
    word-wrap: break-word;
    white-space: pre-wrap;
    font-size: clamp(14px, 4vw, 16px);
    line-height: 1.45;
}
.message.user { justify-content: flex-end; }
.message.user .message-content {
    border-bottom-right-radius: 4px;
    border-left: 3px solid #d4af37;
}
.message.bot .message-content {
    border-bottom-left-radius: 4px;
    border-left: 3px solid #0f3460;
}
.message.error .message-content { background: #fee; color: #c33; }

/* --------------  INPUT ROW  -------------- */
.chat-input-container {
    flex: 0 0 auto;
    background: #fff;
    border-top: 1px solid #e0e0e0;
    padding: 12px;
}
.chat-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}
#messageInput {
    flex: 1 1 auto;
    padding: 10px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 24px;
    font-size: clamp(14px, 4vw, 16px);
    outline: none;
    transition: border-color .3s;
}
#messageInput:focus { border-color: #d4af37; }

/* --------------  ROUND BUTTONS  -------------- */
.voice-btn,
#sendBtn {
    flex: 0 0 auto;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #d4af37;
    background: rgba(212, 175, 55, .15);
    color: #d4af37;
    transition: transform .2s, background .3s;
}
.voice-btn:hover:not(:disabled),
#sendBtn:hover:not(:disabled) {
    transform: scale(1.08);
    background: #d4af37;
    color: #16213e;
}
.voice-btn:disabled,
#sendBtn:disabled { opacity: .5; }

/* --------------  LOADING DOTS  -------------- */
.loading-dots { display: flex; gap: 4px; }
.loading-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #0f3460;
    animation: bounce 1.4s infinite ease-in-out;
}
.loading-dot:nth-child(1) { animation-delay: -.32s; }
.loading-dot:nth-child(2) { animation-delay: -.16s; }
@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40%           { transform: scale(1); }
}

/* --------------  SPEAKER, STOP & COPY ICONS INSIDE BUBBLE  -------------- */
.speaker-btn,
.stop-btn,
.copy-btn {
    background: transparent;
    border: none;
    color: #0f3460;
    cursor: pointer;
    padding: 4px;
    margin-left: 8px;
    transition: color .3s, transform .3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.speaker-btn:hover,
.stop-btn:hover,
.copy-btn:hover { color: #d4af37; transform: scale(1.1); }
.speaker-btn.speaking { color: #4caf50; animation: pulse 1.5s infinite; }
.stop-btn { color: #c33; }
.stop-btn:hover { color: #e74c3c; transform: scale(1.1); }
.copy-btn { color: #0f3460; }
.copy-btn:hover { color: #2196f3; transform: scale(1.1); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.6; }
}

/* --------------  EMPTY STATE  -------------- */
.empty-state {
    text-align: center;
    color: #999;
    margin-top: 30vh;
}
.empty-state h2 { font-size: clamp(36px, 12vw, 48px); margin-bottom: 8px; }
.empty-state p  { font-size: clamp(13px, 3.5vw, 16px); }

/* --------------  SAFARI 100 vh FIX  -------------- */
@supports (-webkit-touch-callout: none) {
    .chat-container { height: -webkit-fill-available; }
