* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

body {
    overflow: hidden;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header h1 {
    font-size: 24px;
    margin-bottom: 5px;
}

.header p {
    font-size: 14px;
    opacity: 0.9;
}

.language-selector {
    display: flex;
    gap: 10px;
}

.lang-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid white;
    padding: 8px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.lang-btn:hover {
    background: white;
    color: #667eea;
}

.lang-btn.active {
    background: white;
    color: #667eea;
    border-color: white;
}

.admin-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid white;
    padding: 8px 15px;
    border-radius: 20px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    cursor: pointer;
    display: inline-block;
}

.admin-btn:hover {
    background: white;
    color: #667eea;
}

/* Content Area */
.content {
    display: flex;
    flex: 1;
    gap: 20px;
    padding: 20px;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 300px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow-y: auto;
}

.info-card {
    background: white;
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.info-card h3 {
    color: #667eea;
    margin-bottom: 10px;
    font-size: 16px;
}

.info-card p {
    font-size: 13px;
    color: #555;
    margin-bottom: 8px;
}

.info-card p:last-child {
    margin-bottom: 0;
}

.info-card.emergency {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.info-card.emergency h3,
.info-card.emergency p {
    color: white;
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.messages-container {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    display: flex;
    flex-direction: column;
    max-width: 70%;
    padding: 12px 15px;
    border-radius: 12px;
    word-wrap: break-word;
}

.bot-message {
    align-self: flex-start;
    background: #f0f0f0;
    color: #333;
}

.user-message {
    align-self: flex-end;
    background: #667eea;
    color: white;
}

.message small {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 5px;
}

.message p {
    margin: 0;
    line-height: 1.4;
    white-space: pre-wrap;
}

/* Quick Actions */
.quick-actions {
    display: flex;
    gap: 10px;
    padding: 15px 20px;
    flex-wrap: wrap;
    border-top: 1px solid #eee;
}

.action-btn {
    padding: 8px 15px;
    border: 1px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.action-btn:hover {
    background: #667eea;
    color: white;
}

.action-btn.emergency-btn {
    border-color: #f5576c;
    color: #f5576c;
}

.action-btn.emergency-btn:hover {
    background: #f5576c;
    color: white;
}

.input-area {
    display: flex;
    gap: 10px;
    padding: 15px 20px;
    border-top: 1px solid #eee;
    background: #f9f9f9;
    align-items: center;
}

.voice-btn {
    background: #764ba2;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.3s;
    white-space: nowrap;
}

.voice-btn:hover {
    background: #667eea;
}

.voice-btn.listening {
    background: #f5576c;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(245, 87, 108, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(245, 87, 108, 0); }
    100% { box-shadow: 0 0 0 0 rgba(245, 87, 108, 0); }
}

#messageInput {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 25px;
    padding: 10px 15px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s ease;
}

#messageInput:focus {
    border-color: #667eea;
}

.send-btn {
    background: #667eea;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-btn:hover {
    background: #764ba2;
    transform: scale(1.05);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: white;
    margin: 50px auto;
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease;
}

.close:hover {
    color: #000;
}

.modal-content h2 {
    color: #667eea;
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: #333;
    font-weight: 600;
    font-size: 14px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: #667eea;
    box-shadow: 0 0 5px rgba(102, 126, 234, 0.3);
}

.submit-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .content {
        gap: 15px;
        padding: 15px;
    }
    
    .sidebar {
        width: 250px;
    }
    
    .message {
        max-width: 85%;
    }
}

@media (max-width: 768px) {
    .content {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        flex-direction: row;
        max-height: 150px;
        overflow-x: auto;
    }
    
    .info-card {
        min-width: 200px;
        flex-shrink: 0;
    }
    
    .header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .header h1 {
        font-size: 20px;
    }
    
    .message {
        max-width: 90%;
    }
    
    .modal-content {
        width: 95%;
        margin: 20px auto;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 15px;
    }
    
    .header h1 {
        font-size: 18px;
    }
    
    .content {
        padding: 10px;
    }
    
    .sidebar {
        max-height: 120px;
    }
    
    .quick-actions {
        padding: 10px;
        gap: 5px;
    }
    
    .action-btn {
        padding: 6px 10px;
        font-size: 11px;
    }
    
    .message {
        max-width: 95%;
        padding: 10px 12px;
    }
    
    #messageInput {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .send-btn {
        width: 36px;
        height: 36px;
    }
}

/* Scrollbar Styling */
.messages-container::-webkit-scrollbar,
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.messages-container::-webkit-scrollbar-track,
.sidebar::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.messages-container::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb:hover,
.sidebar::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ═══════════════════════════════════════════════════════
   WHATSAPP-STYLE MOBILE CHATBOT  (≤ 768px)
   ═══════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    html, body { overflow: hidden; height: 100%; }

    .container {
        display: flex;
        flex-direction: column;
        height: 100dvh;          /* dynamic viewport height — avoids iOS bar */
        height: 100vh;           /* fallback */
        background: #ECE5DD;     /* WhatsApp chat bg */
    }

    /* ── SLIM MOBILE HEADER ── */
    .header {
        padding: 10px 14px;
        flex-shrink: 0;
        background: #075E54;     /* WhatsApp dark green */
        min-height: 56px;
    }

    .header .hospital-info h1 { font-size: 16px; margin: 0; }
    .header .hospital-info p  { font-size: 10px; opacity: 0.9; }

    .header-controls {
        gap: 8px;
    }
    .lang-btn {
        padding: 4px 8px;
        font-size: 10px;
        border-radius: 14px;
    }
    .admin-btn {
        padding: 4px 8px;
        font-size: 10px;
        border-radius: 14px;
    }

    /* ── HIDE SIDEBAR ON MOBILE ── */
    .sidebar { display: none !important; }

    /* ── CONTENT FILLS REMAINING HEIGHT ── */
    .content {
        flex: 1;
        padding: 0;
        gap: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    /* ── CHAT AREA ── */
    .chat-area {
        flex: 1;
        display: flex;
        flex-direction: column;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
        overflow: hidden;
    }

    /* ── MESSAGES SCROLL AREA ── */
    .messages-container {
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        padding: 12px 10px 8px;
        gap: 6px;
        -webkit-overflow-scrolling: touch;
    }

    /* ── BOT BUBBLE — left, white (WhatsApp incoming) ── */
    .bot-message {
        align-self: flex-start;
        background: #FFFFFF;
        color: #333;
        border-radius: 0 12px 12px 12px;
        padding: 10px 14px 6px;
        max-width: 82%;
        box-shadow: 0 1px 2px rgba(0,0,0,.15);
        font-size: 14px;
        line-height: 1.45;
        position: relative;
    }
    .bot-message::before {
        content: '';
        position: absolute;
        top: 0; left: -7px;
        width: 0; height: 0;
        border-style: solid;
        border-width: 0 8px 8px 0;
        border-color: transparent #fff transparent transparent;
    }

    /* ── USER BUBBLE — right, green (WhatsApp outgoing) ── */
    .user-message {
        align-self: flex-end;
        background: #DCF8C6;     /* WhatsApp sent green */
        color: #1a1a1a;
        border-radius: 12px 0 12px 12px;
        padding: 10px 14px 6px;
        max-width: 82%;
        box-shadow: 0 1px 2px rgba(0,0,0,.15);
        font-size: 14px;
        line-height: 1.45;
        position: relative;
    }
    .user-message::after {
        content: '';
        position: absolute;
        top: 0; right: -7px;
        width: 0; height: 0;
        border-style: solid;
        border-width: 8px 8px 0 0;
        border-color: #DCF8C6 transparent transparent transparent;
    }

    .message small {
        font-size: 10px;
        color: #8a8a8a;
        display: block;
        text-align: right;
        margin-top: 4px;
    }

    /* ── QUICK ACTIONS — horizontal scroll chips ── */
    .quick-actions {
        display: flex;
        flex-wrap: nowrap;
        gap: 8px;
        padding: 8px 10px;
        overflow-x: auto;
        background: rgba(236,229,221,0.95);
        border-top: 1px solid #d1cdc8;
        flex-shrink: 0;
        scrollbar-width: none;   /* hide scrollbar */
    }
    .quick-actions::-webkit-scrollbar { display: none; }
    .action-btn {
        flex-shrink: 0;
        padding: 8px 16px;
        font-size: 13px;
        border-radius: 20px;
        background: #fff;
        border: 1.5px solid #075E54;
        color: #075E54;
        white-space: nowrap;
        min-height: 36px;
    }
    .action-btn:hover, .action-btn:active {
        background: #075E54;
        color: #fff;
    }
    .action-btn.emergency-btn {
        border-color: #e53935;
        color: #e53935;
    }
    .action-btn.emergency-btn:hover, .action-btn.emergency-btn:active {
        background: #e53935;
        color: #fff;
    }

    /* ── BOTTOM INPUT BAR ── */
    .input-area {
        display: flex;
        gap: 8px;
        padding: 8px 10px;
        background: #F0F0F0;
        border-top: 1px solid #d1cdc8;
        align-items: center;
        flex-shrink: 0;
    }
    .voice-btn {
        flex-shrink: 0;
        width: 42px;
        height: 42px;
        border-radius: 50%;
        padding: 0;
        font-size: 20px;
        background: #128C7E;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .voice-btn::before { content: '🎤'; font-size: 18px; }
    /* hide text inside voice button on mobile */
    .voice-btn { font-size: 0; }
    .voice-btn::before { font-size: 18px; }

    #messageInput {
        flex: 1;
        background: #fff;
        border: none;
        border-radius: 22px;
        padding: 11px 16px;
        font-size: 15px;
        outline: none;
        box-shadow: 0 1px 3px rgba(0,0,0,.1);
        -webkit-appearance: none;
    }
    .send-btn {
        flex-shrink: 0;
        width: 42px;
        height: 42px;
        border-radius: 50%;
        padding: 0;
        font-size: 0;          /* hide "Send" text */
        background: #128C7E;
        color: transparent;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .send-btn::before { content: '➤'; font-size: 18px; color: #fff; }

    #voiceStatus { font-size: 10px; padding: 2px 10px; }

    /* ── MODAL — fullscreen on mobile ── */
    .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        height: 100dvh;
        height: 100vh;
        margin: 0 !important;
        border-radius: 0 !important;
        overflow-y: auto;
        padding: 16px !important;
    }
    .modal { align-items: flex-start !important; }
}

/* Extra-small phones (< 380px) */
@media (max-width: 380px) {
    .header .hospital-info h1 { font-size: 14px; }
    .lang-btn, .admin-btn { display: none; }
    .bot-message, .user-message { max-width: 90%; font-size: 13px; }
}

