/* Root Variables - Mental Health Green Theme */
:root {
    --primary-color: #2F7A5F;  /* Calming forest green */
    --secondary-color: #3A8F6F;  /* Lighter green */
    --accent-color: #4CAF86;  /* Soft mint green */
    --success-color: #48BB78;
    --warning-color: #ECC94B;
    --danger-color: #F56565;
    --text-primary: #1A202C;
    --text-secondary: #4A5568;
    --bg-primary: #F0F9F6;  /* Very light mint background */
    --bg-secondary: #FFFFFF;
    --bg-user: #4CAF86;  /* Soft green for user messages */
    --bg-assistant: #F7FDFB;  /* Almost white with green tint */
    --border-color: #D5E8E1;  /* Light green border */
    --shadow: 0 2px 8px rgba(47, 122, 95, 0.1);
    --shadow-hover: 0 4px 12px rgba(47, 122, 95, 0.15);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: linear-gradient(135deg, #1A4D3E 0%, #2F7A5F 100%);  /* Dark to light green gradient */
    color: var(--text-primary);
    line-height: 1.5;
    font-size: 14px;  /* Smaller base font size */
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* RTL Support for Arabic */
body[dir="rtl"] {
    direction: rtl;
}

.container {
    width: 100%;
    max-width: 900px;
    height: 90vh;
    max-height: 800px;
    background: var(--bg-secondary);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.header {
    background: linear-gradient(135deg, #2F7A5F, #4CAF86);  /* Green gradient */
    color: white;
    padding: 18px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo h1 {
    font-size: 22px;  /* Smaller heading */
    font-weight: 600;
    margin-bottom: 4px;
}

.tagline {
    font-size: 12px;  /* Smaller tagline */
    opacity: 0.9;
}

.language-selector select {
    padding: 8px 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.language-selector select:hover {
    background: rgba(255, 255, 255, 0.3);
}

.language-selector select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Agent Indicator */
.agent-indicator {
    padding: 12px 30px;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.95), rgba(248, 250, 252, 0.95));
    border-bottom: 1px solid var(--border-color);
    animation: slideDown 0.3s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.agent-badge {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: linear-gradient(135deg, #4A90E215, #4A90E225);
    border: 1px solid #4A90E240;
    border-radius: 20px;
    transition: all 0.3s ease;
}

.agent-badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.agent-icon {
    font-size: 20px;
    line-height: 1;
}

.agent-label {
    font-size: 13px;  /* Smaller label */
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.3px;
}

body[dir="rtl"] .agent-badge {
    flex-direction: row-reverse;
}

/* Welcome Message */
.welcome-message {
    padding: 30px;
    text-align: center;
}

.welcome-content {
    max-width: 600px;
    margin: 0 auto;
}

.welcome-content h2 {
    color: var(--primary-color);
    margin-bottom: 16px;
    font-size: 20px;  /* Smaller heading */
}

.welcome-content ul {
    text-align: left;
    margin: 20px auto;
    max-width: 400px;
    list-style: none;
}

.welcome-content li {
    padding: 10px 0;
    font-size: 14px;  /* Smaller list items */
}

.privacy-note {
    font-size: 12px;  /* Smaller privacy note */
    color: var(--text-secondary);
    margin-top: 20px;
    font-style: italic;
}

/* Chat Container */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--bg-primary);
    scroll-behavior: smooth;
}

.messages {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Message Styles */
.message {
    display: flex;
    gap: 12px;
    max-width: 80%;
    animation: fadeIn 0.3s ease;
}

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

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

.message.assistant {
    align-self: flex-start;
}

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

.message.user .message-avatar {
    background: linear-gradient(135deg, #667eea, #764ba2);
}

.message.assistant .message-avatar {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
}

.message-content {
    padding: 12px 16px;  /* Slightly smaller padding */
    border-radius: 16px;
    line-height: 1.5;
    font-size: 14px;  /* Smaller message text */
    word-wrap: break-word;
}

.message.user .message-content {
    background: var(--bg-user);
    border-bottom-right-radius: 4px;
    color: white;
}

.message.user .message-text {
    color: white;
}

.message.user .message-time {
    color: rgba(255, 255, 255, 0.9);
}

.message.assistant .message-content {
    background: var(--bg-assistant);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border-color);
}

.message-time {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
    opacity: 0.7;
}

/* Markdown Content Styling */
.message-text {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message-text p {
    margin: 0 0 12px 0;
    line-height: 1.6;
}

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

.message-text strong,
.message-text b {
    font-weight: 700;
    color: var(--text-primary);
}

.message-text em,
.message-text i {
    font-style: italic;
}

.message-text ul,
.message-text ol {
    margin: 8px 0 12px 0;
    padding-left: 24px;
}

.message-text ul {
    list-style-type: disc;
}

.message-text ol {
    list-style-type: decimal;
}

.message-text li {
    margin: 6px 0;
    line-height: 1.6;
}

.message-text li > p {
    margin: 0;
}

.message-text h1,
.message-text h2,
.message-text h3,
.message-text h4,
.message-text h5,
.message-text h6 {
    margin: 12px 0 8px 0;
    font-weight: 600;
    line-height: 1.4;
}

.message-text h1 { font-size: 1.3em; }  /* Smaller headings */
.message-text h2 { font-size: 1.15em; }
.message-text h3 { font-size: 1.05em; }
.message-text h4 { font-size: 1em; }
.message-text h5 { font-size: 0.95em; }
.message-text h6 { font-size: 0.9em; }

.message-text h1:first-child,
.message-text h2:first-child,
.message-text h3:first-child {
    margin-top: 0;
}

.message-text code {
    padding: 2px 6px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.message-text pre {
    padding: 12px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 6px;
    overflow-x: auto;
    margin: 8px 0;
}

.message-text pre code {
    padding: 0;
    background: none;
}

.message-text blockquote {
    margin: 8px 0;
    padding-left: 12px;
    border-left: 3px solid var(--primary-color);
    color: var(--text-secondary);
    font-style: italic;
}

.message-text a {
    color: var(--primary-color);
    text-decoration: none;
    border-bottom: 1px solid var(--primary-color);
}

.message-text a:hover {
    opacity: 0.8;
}

.message-text hr {
    margin: 16px 0;
    border: none;
    border-top: 1px solid var(--border-color);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 6px;
    padding: 14px 18px;
    background: var(--bg-assistant);
    border-radius: 16px;
    width: fit-content;
    margin-left: 52px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary-color);
    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.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Specialists Panel */
.specialists-panel {
    margin-top: 20px;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 2px solid var(--border-color);
}

.specialists-panel h3 {
    color: var(--primary-color);
    margin-bottom: 16px;
}

.specialist-card {
    padding: 16px;
    background: var(--bg-primary);
    border-radius: 8px;
    margin-bottom: 12px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.specialist-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.specialist-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.specialist-info {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Input Container */
.input-container {
    padding: 20px 30px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

.input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

#messageInput {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 24px;
    font-size: 14px;  /* Smaller input text */
    font-family: inherit;
    resize: none;
    outline: none;
    transition: all 0.3s ease;
    max-height: 120px;
}

#messageInput:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(107, 155, 209, 0.1);
}

.send-button {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.send-button:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: var(--shadow-hover);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Suggested Actions */
.suggested-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.action-chip {
    padding: 8px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.action-chip:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Footer */
.footer {
    padding: 16px 30px;
    background: var(--bg-primary);
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
}

.crisis-text {
    display: block;
    color: var(--danger-color);
    font-weight: 600;
    margin-bottom: 4px;
}

.support-text a {
    color: var(--primary-color);
    text-decoration: none;
}

.support-text a:hover {
    text-decoration: underline;
}

/* Crisis Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-secondary);
    padding: 40px;
    border-radius: 16px;
    max-width: 500px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-content h2 {
    color: var(--danger-color);
    margin-bottom: 20px;
}

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

.modal-content li {
    margin: 12px 0;
}

.modal-button {
    width: 100%;
    padding: 14px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.modal-button:hover {
    background: var(--secondary-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 0;
    }

    .container {
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .header {
        padding: 16px 20px;
    }

    .logo h1 {
        font-size: 24px;
    }

    .message {
        max-width: 90%;
    }

    .input-container {
        padding: 16px 20px;
    }
}

/* Scrollbar Styling */
.chat-container::-webkit-scrollbar {
    width: 8px;
}

.chat-container::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

.chat-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.chat-container::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* ============================================
   ROLE SELECTION MENU & AUTHENTICATION
   ============================================ */

/* Role Selection Menu */
.role-selection-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.role-menu-content {
    background: var(--bg-secondary);
    padding: 40px;
    border-radius: 16px;
    max-width: 600px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease-out;
}

.role-menu-content h2 {
    font-size: 28px;
    margin-bottom: 12px;
    color: var(--text-primary);
    text-align: center;
}

.role-menu-content > p {
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 30px;
    font-size: 16px;
}

.role-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.role-button {
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 24px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
}

.role-button:hover {
    border-color: var(--accent-color);
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}

.role-icon {
    font-size: 48px;
    margin-bottom: 8px;
}

.role-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.role-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Login Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    animation: slideIn 0.3s ease-out;
    position: relative;
}

.login-modal {
    max-width: 420px;
    width: 90%;
    padding: 40px;
}

.login-modal h2 {
    margin-bottom: 24px;
    font-size: 24px;
    color: var(--text-primary);
    text-align: center;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 14px;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.error-message {
    background: #FEE;
    border: 1px solid #C33;
    color: #C33;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

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

.btn-primary {
    background: var(--accent-color);
    color: white;
}

.btn-primary:hover {
    background: #5568D3;
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover {
    border-color: var(--accent-color);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: transparent;
    border: none;
    font-size: 32px;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
}

.modal-close:hover {
    color: var(--text-primary);
}

/* Agent Actions (buttons container) */
.agent-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Role Switch Button */
.role-switch-button {
    background: var(--accent-color);
    border: 1px solid var(--accent-color);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.role-switch-button:hover {
    background: var(--secondary-color);
    border-color: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* Logout Button */
.logout-button {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.logout-button:hover {
    background: var(--danger-color);
    border-color: var(--danger-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* Button Spinner */
.button-spinner {
    display: inline-block;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive Design */
@media (max-width: 600px) {
    .role-buttons {
        grid-template-columns: 1fr;
    }

    .role-menu-content {
        padding: 24px;
    }

    .login-modal {
        padding: 28px;
    }
}

/* ============================================
   MOBILE APP DOWNLOAD SECTION
   ============================================ */

.app-download-section {
    margin-top: 30px;
    padding: 24px;
    background: linear-gradient(135deg, #F0F9F6, #E8F5F0);
    border-radius: 12px;
    border: 2px solid var(--border-color);
    text-align: center;
}

.app-store-badges {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin: 16px 0;
}

.app-store-badge {
    display: inline-block;
    transition: all 0.3s ease;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.app-store-badge:hover {
    transform: translateY(-3px);
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
}

.app-store-badge img {
    display: block;
}

/* Responsive for Mobile App Download */
@media (max-width: 600px) {
    .app-download-section {
        padding: 16px;
        margin-top: 20px;
    }

    .app-store-badges {
        flex-direction: column;
        gap: 8px;
    }

    .app-store-badge img {
        height: 45px !important;
    }
}
