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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    max-width: 700px;
    width: 100%;
}

.header {
    text-align: center;
    color: white;
    margin-bottom: 20px;
}

.header h1 {
    font-size: 32px;
    margin-bottom: 8px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.header-logo {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: #ffffff;
    padding: 5px;
    box-sizing: border-box;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

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

.chatbot-container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    height: 550px;
    display: flex;
    flex-direction: column;
}

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

.message {
    display: flex;
    gap: 12px;
    animation: fadeIn 0.3s ease-in;
}

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

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.bot-message .avatar {
    background-color: #ffffff;
    background-image: url('jbch-symbol.png');
    background-size: 80%;
    background-position: center;
    background-repeat: no-repeat;
    border: 1px solid #e6e8f0;
}

.user-message {
    justify-content: flex-end;
}

.user-message .message-content {
    order: 1;
}

.user-message .avatar {
    order: 2;
    background: #34c759;
}

.message-content {
    max-width: 72%;
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.45;
    font-size: 15px;
}

/* Inline links (doctor profiles, website, phone) */
.message-content a {
    color: #5a3fb8;
    font-weight: 600;
    text-decoration: none;
    border-bottom: 1px solid rgba(90, 63, 184, 0.35);
    transition: border-color 0.15s ease;
}

.message-content a:hover {
    border-bottom-color: #5a3fb8;
}

.user-message .message-content a {
    color: #fff;
    border-bottom-color: rgba(255, 255, 255, 0.6);
}

.user-message .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 6px;
}

.bot-message .message-content {
    background: #f1f3f5;
    color: #333;
    border-bottom-left-radius: 6px;
}

.typing-indicator {
    display: flex;
    gap: 6px;
    padding: 14px 18px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

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

.chat-input-container {
    padding: 20px;
    border-top: 2px solid #f1f3f5;
    display: flex;
    gap: 12px;
    background: white;
}

#user-input {
    flex: 1;
    padding: 14px 18px;
    border: 2px solid #e9ecef;
    border-radius: 25px;
    font-size: 15px;
    outline: none;
    transition: all 0.3s;
    font-family: inherit;
}

#user-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#send-button {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#send-button:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

#send-button:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

.status {
    text-align: center;
    padding: 8px;
    font-size: 12px;
    color: #666;
    background: #f8f9fa;
}

.quick-questions {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin-top: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.quick-questions h3 {
    color: #333;
    font-size: 16px;
    margin-bottom: 12px;
}

.quick-btn {
    background: #f1f3f5;
    border: 2px solid #e9ecef;
    padding: 10px 16px;
    border-radius: 20px;
    margin: 5px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.3s;
    color: #495057;
}

.quick-btn:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: transparent;
    transform: translateY(-2px);
}

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

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #5568d3;
}

/* Loading animation */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading #send-icon {
    animation: spin 1s linear infinite;
}

/* Appointment Buttons */
.appointment-buttons {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.appointment-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.appointment-btn.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.appointment-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.appointment-btn.secondary {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
}

.appointment-btn.secondary:hover {
    background: #f8f9fa;
    transform: translateY(-2px);
}

/* Modal Styles */
.modal {
    display: block;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s ease-in;
}

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

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

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 20px;
}

.close:hover,
.close:focus {
    color: #000;
}

.modal-content h2 {
    color: #333;
    margin-bottom: 25px;
    font-size: 24px;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #495057;
    font-weight: 500;
    font-size: 14px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: all 0.3s;
}

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

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 25px;
    justify-content: flex-end;
}

.btn-primary,
.btn-secondary {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #f1f3f5;
    color: #495057;
}

.btn-secondary:hover {
    background: #e9ecef;
}

/* Modal scrollbar styling */
.modal-content::-webkit-scrollbar {
    width: 8px;
}

.modal-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.modal-content::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
}

/* Find Nearest JBCH button (header) */
.locate-btn {
    margin-top: 14px;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    border: 1.5px solid rgba(255, 255, 255, 0.55);
    padding: 9px 18px;
    border-radius: 22px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: all 0.2s ease;
}

.locate-btn:hover {
    background: #fff;
    color: #5a3fb8;
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}

/* Location finder modal */
.loc-intro {
    color: #555;
    font-size: 14px;
    margin-bottom: 18px;
    line-height: 1.5;
}

.loc-options {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.loc-gps-btn {
    width: 100%;
    padding: 13px;
    font-size: 15px;
}

.loc-or {
    display: flex;
    align-items: center;
    text-align: center;
    color: #aaa;
    font-size: 13px;
}

.loc-or::before,
.loc-or::after {
    content: "";
    flex: 1;
    border-bottom: 1px solid #e9ecef;
}

.loc-or span {
    padding: 0 12px;
}

.loc-pin {
    display: flex;
    gap: 10px;
}

.loc-pin input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: all 0.2s;
}

.loc-pin input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.loc-results {
    margin-top: 18px;
}

.loc-status {
    font-size: 14px;
    color: #333;
    margin-bottom: 12px;
}

.loc-error {
    font-size: 14px;
    color: #c81e1e;
    background: #fdecec;
    padding: 12px 14px;
    border-radius: 10px;
}

.loc-card {
    border: 2px solid #e9ecef;
    border-radius: 14px;
    padding: 14px 16px;
    margin-bottom: 12px;
    transition: all 0.2s;
}

.loc-card.nearest {
    border-color: #667eea;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.07), rgba(118, 75, 162, 0.07));
}

.loc-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.loc-name {
    font-weight: 700;
    color: #2b2150;
    font-size: 15px;
}

.loc-dist {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 12px;
}

.loc-addr {
    font-size: 13px;
    color: #666;
    line-height: 1.45;
    margin-bottom: 10px;
}

.loc-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.loc-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    color: #5a3fb8;
    background: #f1f3f5;
    padding: 8px 13px;
    border-radius: 18px;
    transition: all 0.2s;
}

.loc-link:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.loc-link.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.loc-note {
    font-size: 12px;
    color: #999;
    margin-top: 6px;
    line-height: 1.45;
}

.loc-eta {
    font-size: 13px;
    color: #c81e1e;
    font-weight: 600;
    margin-bottom: 8px;
}

.loc-link.amb {
    background: #fdecec;
    color: #c81e1e;
}

.loc-link.amb:hover {
    background: #fbd5d5;
}

/* Structured message layout: avatar + a vertical body (bubble + actions) */
.message-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 78%;
    min-width: 0;
}

.user-message .message-body {
    order: 1;
    align-items: flex-end;
}

.user-message .avatar {
    order: 2;
}

.message-content {
    max-width: 100%;
}

/* Rich text inside message bubbles */
.message-content p {
    margin: 0 0 8px;
}

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

.msg-heading {
    font-size: 15px;
    font-weight: 700;
    margin: 4px 0 6px;
    color: #2b2150;
}

.message-content .msg-list {
    margin: 4px 0 8px;
    padding-left: 22px;
}

.message-content .msg-list:last-child {
    margin-bottom: 0;
}

.message-content .msg-list li {
    margin: 4px 0;
    line-height: 1.5;
}

.message-content ol.msg-list {
    list-style: decimal;
}

.message-content ul.msg-list {
    list-style: none;
    padding-left: 4px;
}

.message-content ul.msg-list li {
    position: relative;
    padding-left: 18px;
}

.message-content ul.msg-list li::before {
    content: "•";
    position: absolute;
    left: 2px;
    color: #667eea;
    font-weight: 700;
}

/* Prominent emergency call-to-action */
.emergency-action {
    display: flex;
}

.emergency-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #ff5a5f 0%, #c81e1e 100%);
    color: #fff !important;
    font-weight: 700;
    font-size: 15px;
    padding: 13px 22px;
    border-radius: 14px;
    text-decoration: none;
    border: none !important;
    box-shadow: 0 6px 18px rgba(200, 30, 30, 0.35);
    animation: emergencyPulse 1.8s ease-in-out infinite;
    transition: transform 0.15s ease;
}

.emergency-btn:hover {
    transform: translateY(-2px) scale(1.02);
}

@keyframes emergencyPulse {
    0%, 100% { box-shadow: 0 6px 18px rgba(200, 30, 30, 0.35); }
    50% { box-shadow: 0 8px 28px rgba(255, 90, 95, 0.7); }
}

/* Responsive design */
@media (max-width: 600px) {
    .modal-content {
        margin: 10% auto;
        width: 95%;
        padding: 20px;
    }

    .message-body {
        max-width: 88%;
    }

    .appointment-buttons {
        flex-direction: column;
    }

    .appointment-btn {
        width: 100%;
        justify-content: center;
    }

    .emergency-btn {
        width: 100%;
        justify-content: center;
    }
}
