/* ========================================
   HAWA Chatbot Lafiya - Styles v2
   Modern, mobile-first design
   ======================================== */

:root {
    --primary: #0d9488;
    --primary-light: #14b8a6;
    --primary-dark: #0f766e;
    --primary-bg: #f0fdfa;
    --accent: #f59e0b;
    --accent-light: #fbbf24;
    --bg: #f0f4f3;
    --surface: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-light: #94a3b8;
    --border: #e2e8f0;
    --bot-bubble: #f1f5f9;
    --user-bubble: linear-gradient(135deg, #0d9488, #0f766e);
    --user-text: #ffffff;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.12);
    --radius: 16px;
    --radius-lg: 20px;
    --radius-xl: 24px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    max-width: 520px;
    margin: 0 auto;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    position: relative;
}

/* Header */
.header {
    background: linear-gradient(135deg, #0d9488 0%, #065f46 100%);
    color: white;
    padding: 0;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -30%;
    width: 200px;
    height: 200px;
    background: rgba(255,255,255,0.06);
    border-radius: 50%;
}

.header::after {
    content: '';
    position: absolute;
    bottom: -60%;
    left: -20%;
    width: 150px;
    height: 150px;
    background: rgba(255,255,255,0.04);
    border-radius: 50%;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    position: relative;
    z-index: 1;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 44px;
    height: 44px;
    background: rgba(255,255,255,0.2);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    backdrop-filter: blur(10px);
}

.logo-text h1 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.logo-text p {
    font-size: 11px;
    opacity: 0.8;
    margin-top: 1px;
    font-weight: 400;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.lang-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.2);
    border: 1.5px solid rgba(255,255,255,0.4);
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    backdrop-filter: blur(10px);
    transition: background 0.2s;
    letter-spacing: 0.5px;
}
.lang-toggle:hover { background: rgba(255,255,255,0.3); }
.lang-toggle:active { transform: scale(0.95); }

.status-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.15);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    backdrop-filter: blur(10px);
}

.status-dot {
    width: 7px;
    height: 7px;
    background: #4ade80;
    border-radius: 50%;
    animation: pulse 2s infinite;
    box-shadow: 0 0 6px rgba(74, 222, 128, 0.5);
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.9); }
}

/* Chat Messages */
.chat-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    background: var(--bg);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.message {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    animation: fadeInUp 0.35s ease;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    background: white;
    box-shadow: var(--shadow-sm);
}

.user-message .message-avatar {
    background: var(--primary);
    color: white;
    font-size: 14px;
    order: 1;
}

.message-content {
    max-width: 80%;
    display: flex;
    flex-direction: column;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    line-height: 1.65;
    box-shadow: var(--shadow-sm);
}

.bot-message .message-bubble {
    background: white;
    border-bottom-left-radius: 6px;
    color: var(--text);
}

.user-message {
    flex-direction: row-reverse;
}

.user-message .message-content {
    align-items: flex-end;
}

.user-message .message-bubble {
    background: var(--user-bubble);
    color: var(--user-text);
    border-bottom-right-radius: 6px;
}

.message-bubble p {
    margin-bottom: 6px;
}

.message-bubble p:last-child {
    margin-bottom: 0;
}

.message-bubble ul {
    margin: 6px 0;
    padding-left: 18px;
}

.message-bubble li {
    margin-bottom: 3px;
    font-size: 13px;
}

.message-bubble strong {
    font-weight: 600;
}

.message-time {
    font-size: 10px;
    color: var(--text-light);
    margin-top: 4px;
    padding: 0 4px;
}

/* Welcome message special styling */
.bot-message:first-child .message-bubble {
    background: linear-gradient(135deg, #f0fdfa, #ecfdf5);
    border: 1px solid rgba(13, 148, 136, 0.15);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 14px 18px;
    background: white;
    border-radius: var(--radius);
    border-bottom-left-radius: 6px;
    width: fit-content;
    box-shadow: var(--shadow-sm);
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--primary-light);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.3; }
    30% { transform: translateY(-8px); opacity: 1; }
}

/* Quick Questions */
.quick-questions {
    padding: 10px 16px 8px;
    background: var(--bg);
    flex-shrink: 0;
}

.quick-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.quick-buttons {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 6px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.quick-buttons::-webkit-scrollbar {
    display: none;
}

.quick-btn {
    background: white;
    border: 1px solid var(--border);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text);
    font-family: inherit;
    white-space: nowrap;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
    font-weight: 500;
}

.quick-btn:hover,
.quick-btn:active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    transform: scale(0.97);
    box-shadow: 0 2px 8px rgba(13, 148, 136, 0.3);
}

/* Chat Input */
.chat-input-area {
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    background: white;
    flex-shrink: 0;
    border-top: 1px solid var(--border);
}

.input-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
    background: var(--bg);
    border: 2px solid transparent;
    border-radius: var(--radius);
    padding: 4px 4px 4px 16px;
    transition: all 0.25s ease;
}

.input-wrapper:focus-within {
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px rgba(13, 148, 136, 0.08);
}

#messageInput {
    flex: 1;
    border: none;
    outline: none;
    font-size: 14px;
    font-family: inherit;
    background: transparent;
    color: var(--text);
    padding: 10px 0;
    min-width: 0;
}

#messageInput::placeholder {
    color: var(--text-light);
    font-size: 13px;
}

.btn-action {
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

#sendBtn {
    background: var(--primary);
    color: white;
}

#sendBtn:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

#sendBtn:active {
    transform: scale(0.95);
}

#voiceBtn {
    background: #818cf8;
    color: white;
}

#voiceBtn:hover {
    background: #6366f1;
}

#audioToggle {
    background: #a78bfa;
    color: white;
}

#audioToggle.active {
    background: #7c3aed;
    box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.25);
}

#voiceBtn.recording {
    background: #ef4444;
    animation: recordPulse 1.2s infinite;
}

@keyframes recordPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
}

.input-wrapper.recording {
    border-color: #ef4444;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.08);
}

/* Audio player in messages */
.audio-player {
    margin-top: 10px;
}

.audio-player audio {
    width: 100%;
    height: 36px;
    border-radius: 10px;
}

.voice-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    font-style: italic;
}

/* Footer */
.footer {
    padding: 8px 16px;
    text-align: center;
    background: white;
    flex-shrink: 0;
    border-top: 1px solid var(--border);
}

.footer p {
    font-size: 10px;
    color: var(--text-light);
}

.disclaimer {
    margin-top: 2px;
    color: #d97706 !important;
    font-weight: 500;
}

/* Language indicator in header */
.lang-switch {
    display: flex;
    gap: 4px;
    background: rgba(255,255,255,0.1);
    padding: 3px;
    border-radius: 10px;
    margin-top: 8px;
}

.lang-btn {
    padding: 4px 10px;
    border-radius: 8px;
    border: none;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    background: transparent;
    color: rgba(255,255,255,0.7);
    font-family: inherit;
}

.lang-btn.active {
    background: rgba(255,255,255,0.25);
    color: white;
}

/* Scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

/* Responsive */
@media (max-width: 640px) {
    .app { max-width: 100%; }
    .header-content { padding: 12px 16px; }
    .logo-icon { width: 38px; height: 38px; font-size: 20px; border-radius: 12px; }
    .logo-text h1 { font-size: 16px; }
    .logo-text p { font-size: 10px; }
    .status-badge { font-size: 10px; padding: 4px 10px; }
    .chat-messages { padding: 12px; }
    .message-content { max-width: 85%; }
    .message-bubble { padding: 10px 14px; font-size: 13px; }
    .message-avatar { width: 32px; height: 32px; font-size: 16px; border-radius: 10px; }
    .quick-questions { padding: 8px 12px; }
    .quick-btn { font-size: 11px; padding: 7px 12px; }
    .chat-input-area { padding: 10px 12px; }
    #messageInput { font-size: 14px; }
    .footer { padding: 6px 12px; }
    .footer p { font-size: 9px; }
}

/* Desktop wide screens */
@media (min-width: 641px) {
    body {
        display: flex;
        align-items: center;
        justify-content: center;
        background: linear-gradient(135deg, #f0fdfa 0%, #e0f2fe 50%, #f0fdf4 100%);
    }
    .app {
        height: 90vh;
        border-radius: 24px;
        overflow: hidden;
    }
}

/* Safe area for notched phones */
@supports (padding: max(0px)) {
    .header-content {
        padding-top: max(12px, env(safe-area-inset-top));
    }
    .chat-input-area {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
}

/* Broadcast Chat Message */
.broadcast-message {
    animation: fadeInUp 0.4s ease;
}
.broadcast-message .broadcast-avatar {
    background: linear-gradient(135deg, #0f766e, #14b8a6) !important;
}
.broadcast-bubble {
    border-left: 3px solid #0f766e !important;
    background: linear-gradient(135deg, #f0fdfa, #ccfbf1) !important;
}
.broadcast-label {
    font-size: 11px;
    font-weight: 600;
    color: #0f766e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.broadcast-label::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background: #0f766e;
    border-radius: 50%;
}
@keyframes fadeInUp {
    from { transform: translateY(10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
