/* Global Styles */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --accent-color: #e74c3c;
    --light-color: #ecf0f1;
    --dark-color: #2c3e50;
    --success-color: #2ecc71;
    --text-color: #333;
    --border-radius: 8px;
    --box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --doctor-color: #3498db;
    --patient-color: #e67e22;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: #f5f7fa;
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Container */
.container {
    max-width: 1000px;
    margin: 0 auto;
    height: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: white;
    box-shadow: var(--box-shadow);
}

/* Header */
.app-header {
    background-color: var(--primary-color);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #ddd;
    flex-wrap: wrap;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-img {
    height: 54px;  /* Increased from 42px */
    width: auto;
    border-radius: 8px;
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.logo-text h1 {
    font-size: clamp(1.2rem, 4vw, 1.5rem);
    margin: 0;
    line-height: 1.1;
}

.tagline {
    font-size: clamp(0.7rem, 2vw, 0.85rem);
    opacity: 0.8;
    margin: 0;
    font-weight: normal;
}

.logo i {
    font-size: 24px;
    color: var(--accent-color);
}

.header-controls {
    display: flex;
    gap: 10px;
}

.control-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.5);
    color: white;
    padding: 8px 12px;
    border-radius: var(--border-radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.3s ease;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Language Selection Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background-color: white;
    border-radius: var(--border-radius);
    padding: 30px;
    width: 400px;
    max-width: 90%;
    text-align: center;
    box-shadow: var(--box-shadow);
}

.language-options {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    gap: 20px;
}

.language-btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius);
    background-color: var(--secondary-color);
    color: white;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.language-btn:hover {
    background-color: #2980b9;
    transform: translateY(-2px);
}

/* Chat Area */
.chat-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding: 10px;
    background-color: #f5f7fa;
    overflow: hidden;
    height: 0; /* Force flex to calculate height correctly */
}

.messages-container {
    flex-grow: 1;
    overflow-y: auto;
    padding: 5px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Message Bubbles */
.message {
    display: flex;
    margin-bottom: 18px;
    max-width: 80%;
    position: relative;
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-bot {
    align-self: flex-start;
}

.message-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 12px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.avatar-bot {
    background: linear-gradient(135deg, var(--doctor-color), #2980b9);
    color: white;
}

.avatar-user {
    background: linear-gradient(135deg, var(--patient-color), #d35400);
    color: white;
}

.message-content {
    padding: 14px 18px;
    border-radius: var(--border-radius);
    position: relative;
    max-width: calc(100% - 70px);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.message-bot .message-content {
    background-color: white;
    border-left: 4px solid var(--doctor-color);
    border-radius: var(--border-radius) var(--border-radius) var(--border-radius) 0;
}

.message-bot .message-content:before {
    content: '';
    position: absolute;
    bottom: 0;
    left: -8px;
    width: 16px;
    height: 16px;
    background-color: white;
    border-left: 4px solid var(--doctor-color);
    border-bottom: 4px solid var(--doctor-color);
    transform: rotate(45deg);
    border-bottom-left-radius: 12px;
    box-shadow: -2px 2px 2px rgba(0, 0, 0, 0.05);
}

.message-user .message-content {
    background: linear-gradient(135deg, var(--patient-color), #d35400);
    color: white;
    border-radius: var(--border-radius) var(--border-radius) 0 var(--border-radius);
}

.message-user .message-content:before {
    content: '';
    position: absolute;
    bottom: 0;
    right: -8px;
    width: 16px;
    height: 16px;
    background: linear-gradient(135deg, var(--patient-color), #d35400);
    transform: rotate(45deg);
    border-bottom-right-radius: 12px;
    box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.05);
}

.timestamp {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 6px;
    text-align: right;
}

.message-bot .timestamp {
    color: #777;
}

.message-user .timestamp {
    color: rgba(255, 255, 255, 0.8);
}

/* Message Formatting Styles */
.message-bot .message-content h3 {
    font-size: 1.1em;
    margin: 12px 0;
    color: var(--doctor-color);
    border-bottom: 1px solid #eee;
    padding-bottom: 6px;
}

.message-bot .message-content p {
    margin: 10px 0;
    line-height: 1.5;
}

.message-bot .message-content strong {
    font-weight: 600;
    color: var (--dark-color);
    background-color: rgba(52, 152, 219, 0.1);
    padding: 1px 3px;
    border-radius: 3px;
}

.message-bot .message-content em {
    font-style: italic;
    color: var(--dark-color);
}

.message-bot .message-content .list-item {
    display: flex;
    margin: 10px 0;
    line-height: 1.4;
}

.message-bot .message-content .list-number,
.message-bot .message-content .bullet-point {
    min-width: 24px;
    font-weight: 600;
    color: var(--doctor-color);
}

.message-bot .message-content ul,
.message-bot .message-content ol {
    margin: 12px 0;
    padding-left: 20px;
}

/* File Upload Preview */
.file-preview-container {
    margin: 10px 0;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    padding: 10px;
    background-color: white;
}

.file-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-weight: bold;
}

#remove-file-btn {
    background: transparent;
    border: none;
    color: var(--accent-color);
    cursor: pointer;
    font-size: 16px;
}

.file-preview-content {
    max-height: 200px;
    overflow-y: auto;
    padding: 10px;
    background-color: #f9f9f9;
    border-radius: var(--border-radius);
}

/* Input Area */
.input-container {
    display: flex;
    align-items: center;
    padding: 12px;
    background-color: white;
    border-radius: var(--border-radius);
    margin-top: 15px;
    box-shadow: var(--box-shadow);
    border: 1px solid #e1e8ed;
    transition: all 0.3s ease;
}

.input-container:focus-within {
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

#user-input {
    flex-grow: 1;
    border: none;
    padding: 12px;
    resize: none;
    font-size: 16px;
    max-height: 120px;
    outline: none;
}

.upload-btn, .send-btn {
    background: none;
    border: none;
    font-size: 22px;
    color: var(--secondary-color);
    cursor: pointer;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    border-radius: 50%;
}

.send-btn:hover, .upload-btn:hover {
    color: white;
    background-color: var(--secondary-color);
    transform: scale(1.05);
}

/* Footer */
.app-footer {
    text-align: center;
    padding: 15px;
    background-color: var(--light-color);
    color: var(--text-color);
    font-size: 14px;
}

/* Loading Indicator */
.loading-indicator {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid white;
    border-top: 5px solid var(--secondary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    /* Container adjustments */
    .container {
        width: 100%;
        height: 100%;
        max-width: none;
        box-shadow: none;
    }
    
    /* Header adjustments */
    .app-header {
        padding: 8px 12px;
    }
    
    .logo-img {
        height: 40px;
    }
    
    .tagline {
        display: none; /* Hide tagline on small screens */
    }
    
    .header-controls {
        gap: 6px;
    }
    
    .control-btn {
        padding: 5px 8px;
        font-size: 0.9rem;
    }
    
    /* Text in buttons is hidden on mobile, showing only icons */
    .control-btn span {
        display: none;
    }
    
    .control-btn i {
        font-size: 1.2rem;
    }
    
    /* Chat area adjustments */
    .chat-area {
        padding: 8px;
    }
    
    .messages-container {
        padding: 3px;
    }
    
    /* Message bubble adjustments */
    .message {
        max-width: 90%;
        margin-bottom: 10px;
    }
    
    .avatar {
        width: 32px;
        height: 32px;
        margin: 0 6px;
    }
    
    .message-content {
        padding: 8px 12px;
        font-size: 15px;
        max-width: calc(100% - 44px);
    }
    
    /* Input area adjustments */
    .input-container {
        padding: 6px;
        margin-top: 10px;
    }
    
    #user-input {
        padding: 6px;
        font-size: 15px;
        min-height: 38px;
        max-height: 100px;
    }
    
    .upload-btn, .send-btn {
        width: 36px;
        height: 36px;
        min-width: 36px; /* Ensure minimum touch target size */
    }

    /* Footer adjustments */
    .app-footer {
        padding: 8px;
        font-size: 12px;
    }
}

/* Small Mobile Screens */
@media (max-width: 480px) {
    .app-header {
        flex-direction: column;
        align-items: center;
        gap: 10px;
        padding: 10px;
        text-align: center;
    }
    
    .logo {
        margin-bottom: 5px;
    }
    
    .logo-img {
        height: 40px;  /* Increased from 32px */
    }
    
    .header-controls {
        width: 100%;
        justify-content: center;
    }
    
    .logo h1 {
        font-size: 1.2rem;
    }
    
    .message {
        max-width: 95%;
    }
    
    /* Language modal adjustments for tiny screens */
    .modal-content {
        padding: 20px 15px;
    }
    
    .language-options {
        flex-direction: column;
    }
    
    .language-btn {
        width: 100%;
        margin-bottom: 10px;
    }
    
    /* Footer adjustments */
    .app-footer {
        padding: 8px;
        font-size: 12px;
    }
    
    /* File preview adjustments */
    .file-preview-container {
        padding: 8px;
    }
    
    .file-preview-content {
        max-height: 150px;
    }
}

/* Ensure better touch targets for mobile devices */
@media (pointer: coarse) {
    .control-btn, 
    .language-btn, 
    #remove-file-btn,
    .upload-btn, 
    .send-btn {
        min-height: 44px;
        min-width: 44px;
    }
}

/* Fix for iOS Safari viewport height issues */
@supports (-webkit-touch-callout: none) {
    .container {
        height: -webkit-fill-available;
    }
    
    body, html {
        height: -webkit-fill-available;
    }
}
