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

html {
    height: 100%;
    height: 100dvh; /* Dynamic viewport height for mobile browsers */
}

html, body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #6c7f93;
    color: white;
    line-height: 1.6;
}

/* Index page body - flexbox for centering */
.index-body {
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height for mobile browsers */
    min-height: -webkit-fill-available; /* iOS Safari fallback */
    display: flex;
    flex-direction: column;
}

/* Index page main - flexbox for centering */
.index-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Header */
header {
    padding: 8px 40px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo {
    font-family: sans-serif;
    font-size: 28px;
    font-weight: 600;
    color: white;
    text-decoration: none;
    letter-spacing: 1px;
}

/* Main Content */
main {
    padding: 40px;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

/* Typography */
h1 {
    font-size: 2.4rem;
    font-weight: 420;
    color: white;
    margin-top: -12px;
    margin-bottom: 15px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Index page - centered h1 */
.index-main h1 {
    text-align: center;
}

h2 {
    font-size: 1.8rem;
    font-weight: 400;
    color: white;
    margin: 40px 0 20px 0;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

h3 {
    font-size: 1.29rem;
    font-weight: 400;
    color: white;
    margin: 30px 0 15px 0;
}

p {
    margin-bottom: 20px;
    color: rgba(255, 255, 255, 0.9);
}

ul {
    margin: 20px 0;
    padding-left: 20px;
}

li {
    margin-bottom: 10px;
    color: rgba(255, 255, 255, 0.9);
}

/* Index page - Chat Container */
.chat-container {
    width: 100%;
    max-width: 700px;
    display: flex;
    flex-direction: column;
    height: 390px;
    padding: 3px;
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.25), rgba(255, 255, 255, 0.05));
    box-shadow: 0 18px 45px rgba(16, 22, 30, 0.25);
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 17px 17px 0 0;
    display: flex;
    flex-direction: column;
}

.chat-input-container {
    display: flex;
    padding: 10px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 0 0 17px 17px;
    gap: 8px;
    align-items: center;
}

.chat-input {
    flex: 1;
    min-width: 0;
    padding: 12px 16px;
    font-size: 16px;
    border: none;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.95);
    outline: none;
    transition: box-shadow 0.3s ease;
}

.send-button {
    flex-shrink: 0;
    padding: 12px 16px;
    font-size: 14px;
    border: none;
    border-radius: 20px;
    background: #007bff;
    color: white;
    cursor: pointer;
    transition: background 0.3s ease;
    white-space: nowrap;
}

.send-button:hover:not(:disabled) {
    background: #0056b3;
}

.chat-input:disabled,
.send-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.chat-input:focus {
    box-shadow: 0 6px 30px rgba(0, 0, 0, 0.15);
}

.chat-input::placeholder {
    color: #999;
    font-size: 18px;
}

/* Messages */
.message {
    margin-bottom: 10px;
    padding: 8px 12px;
    border-radius: 10px;
    line-height: 1.7;
    max-width: 72ch;
    width: auto;
    word-break: break-word;
    font-size: 1.1em;
}

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

.message.bot {
    align-self: flex-start;
    background: #f1f1f1;
    color: #333;
    width: 100%;
    max-width: none;
}

.typing-indicator {
    align-self: flex-start;
    background: #f1f1f1;
    color: #666;
    font-style: italic;
    padding: 8px 12px;
    border-radius: 10px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.typing-dots {
    display: inline-flex;
    gap: 2px;
}

.typing-dot {
    width: 4px;
    height: 4px;
    background: #666;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Index page - User Info Form */
.user-info-container {
    width: 100%;
    max-width: 700px;
    margin-top: 20px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.user-info-row {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: nowrap;
    justify-content: center;
}

.user-info-label {
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    min-width: 80px;
}

.user-info-field {
    flex: 1;
    min-width: 120px;
}

.user-info-field select,
.user-info-field input {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.95);
    color: #333;
    outline: none;
    font-family: inherit;
}

.user-info-field input[type="text"] {
    font-size: 14px;
}

.user-info-field select:focus,
.user-info-field input:focus {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

/* Content page - Highlight boxes */
.highlight {
    background: rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 10px;
    margin: 20px 0;
    border-left: 4px solid rgba(255, 255, 255, 0.3);
}

.warning {
    background: rgba(255, 215, 0, 0.1);
    border-left-color: #ffd700;
    border: 1px solid rgba(255, 215, 0, 0.2);
}

.emergency {
    background: rgba(255, 0, 0, 0.1);
    border-left-color: #ff4444;
    border: 1px solid rgba(255, 0, 0, 0.2);
}

/* Footer */
footer {
    padding: 20px 40px;
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .index-body {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        overflow-y: auto;
    }

    header {
        padding: 6px 20px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    main {
        padding: 20px;
    }

    h1 {
        font-size: 1.5rem;
        font-weight: 420;
        margin-top: -8px;
        margin-bottom: 10px;
    }

    h2 {
        font-size: 1.5rem;
    }

    footer {
        padding: 15px 20px;
    }

    /* Index page mobile */
    .chat-container {
        height: 340px;
        max-width: 100%;
    }

    .chat-input-container {
        padding: 8px;
        gap: 6px;
    }

    .chat-input {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 10px 14px;
    }

    .send-button {
        padding: 10px 14px;
        font-size: 14px;
        min-width: 60px;
    }

    .user-info-container {
        padding: 15px;
        gap: 12px;
    }

    .user-info-row {
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 8px;
    }

    .user-info-label {
        display: none;
    }

    .user-info-field {
        flex: 1;
        min-width: 0;
    }

    /* Full-width rows for single-field inputs (like preexisting conditions) */
    .user-info-row-full {
        flex-direction: column;
        align-items: stretch;
    }

    .user-info-row-full .user-info-field {
        min-width: 100%;
    }
}

/* Disclaimer Styles */
.disclaimer {
    margin-top: 4px;
    text-align: center;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.disclaimer-text {
    font-weight: 400;
}

.disclaimer-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.3s ease;
}

.disclaimer-icon:hover {
    background: rgba(255, 255, 255, 0.3);
}

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

.modal-content {
    background-color: white;
    margin: 10% auto;
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    color: #333;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    font-size: 1.1em;
}

.close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #666;
}

.close:hover {
    color: #333;
}

.modal-content h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.5rem;
    border-bottom: 2px solid #007bff;
    padding-bottom: 10px;
}

.modal-content p {
    margin-bottom: 15px;
    line-height: 1.6;
    color: #555;
}

.modal-content p strong {
    color: #333;
}

.modal-content a {
    color: #007bff;
    text-decoration: none;
}

.modal-content a:hover {
    text-decoration: underline;
}

/* Mobile modal adjustments */
@media (max-width: 768px) {
    .modal-content {
        margin: 5% auto;
        padding: 20px;
        width: 95%;
    }

    .modal-content h2 {
        font-size: 1.3rem;
    }

    .disclaimer {
        font-size: 13px;
    }

    .disclaimer-icon {
        width: 16px;
        height: 16px;
        font-size: 11px;
    }
}

/* Accordion Styles */
.accordion {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    padding: 18px;
    width: 100%;
    border: none;
    text-align: left;
    outline: none;
    font-size: 1.2rem;
    transition: 0.4s;
    border-radius: 10px;
    margin-bottom: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
}

.accordion:hover, .accordion.active {
    background-color: rgba(255, 255, 255, 0.2);
}

.accordion:after {
    content: '\002B';
    font-weight: bold;
    float: right;
    margin-left: 5px;
}

.accordion.active:after {
    content: "\2212";
}

.panel {
    padding: 0 18px;
    background-color: rgba(0, 0, 0, 0.1);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.2s ease-out;
    border-radius: 0 0 10px 10px;
    margin-bottom: 10px;
}

/* Nested Accordion for Symptoms */
.symptom-accordion {
    background-color: transparent;
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    padding: 12px 0;
    width: 100%;
    border: none;
    text-align: left;
    outline: none;
    font-size: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.symptom-accordion:after {
    content: '\002B';
    font-size: 0.8em;
}

.symptom-accordion.active:after {
    content: "\2212";
}

.symptom-panel {
    padding: 0 10px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.2s ease-out;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.95rem;
}

.symptom-panel p {
    margin: 10px 0;
}
