:root {
    --primary: #0066CC;
    --primary-hover: #0052A3;
    --primary-light: #E6F2FF;
    --success: #00A86B;
    --white: #FFFFFF;
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --charcoal: #1A1A1A;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.08);
    --shadow-xl: 0 20px 25px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--gray-50);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    color: var(--charcoal);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.app-header {
    background: var(--white);
    padding: 16px 32px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand-logo { height: 36px; }
.brand-text h1 { font-size: 20px; font-weight: 600; }
.brand-text p { font-size: 12px; color: var(--gray-500); }

.header-actions { display: flex; gap: 12px; }

.btn-login, .btn-signup {
    padding: 8px 16px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-login { color: var(--gray-700); border: 1px solid var(--gray-300); background: transparent; }
.btn-signup { color: var(--white); background: var(--primary); }

.main-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
}

.aira-card {
    width: 100%;
    max-width: 920px;
    background: var(--white);
    border-radius: 20px;
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    max-height: 88vh;
    border: 1px solid var(--gray-200);
}

.card-header {
    background: linear-gradient(180deg, var(--white), var(--gray-50));
    padding: 28px 32px 24px;
    text-align: center;
    border-bottom: 1px solid var(--gray-200);
}

.card-header h2 {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
}

.card-header .icon {
    width: 44px;
    height: 44px;
    background: var(--primary-light);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px 28px 28px;
    overflow: hidden;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--gray-200);
}

.clear-chat-btn {
    font-size: 12px;
    padding: 6px 14px;
    border: 1px solid var(--gray-300);
    border-radius: 7px;
    background: var(--white);
    cursor: pointer;
    transition: all 0.2s;
}

.clear-chat-btn:hover {
    background: var(--gray-50);
    border-color: #DC3545;
    color: #DC3545;
}

#chat {
    flex: 1;
    overflow-y: auto;
    border: 1px solid var(--gray-200);
    border-radius: 14px;
    padding: 18px;
    background: var(--gray-50);
    min-height: 280px;
    max-height: 380px;
    scroll-behavior: smooth;
}

#chat::-webkit-scrollbar { width: 6px; }
#chat::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }

.chat-message {
    margin-bottom: 14px;
    display: flex;
    animation: fadeIn 0.3s;
    position: relative;
}

.chat-message.aira { justify-content: flex-start; }
.chat-message.user { justify-content: flex-end; }
.chat-message.system, .chat-message.links, .chat-message.suggestion { justify-content: center; }

.message-bubble {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 15px;
    line-height: 1.5;
    box-shadow: var(--shadow-sm);
    position: relative;
}

.chat-message.aira .message-bubble {
    background: var(--white);
    border: 1px solid #D0E4F5;
    border-bottom-left-radius: 4px;
}

.chat-message.user .message-bubble {
    background: var(--primary);
    color: var(--white);
    border-bottom-right-radius: 4px;
}

.chat-message.system .message-bubble {
    background: var(--primary-light);
    border: 1px solid #D0E4F5;
    font-size: 13px;
    max-width: 80%;
    text-align: center;
}

/* IN-CHAT SUGGESTIONS */
.chat-message.suggestion .message-bubble {
    background: #FFF9E6;
    border: 1px solid #FFC107;
    max-width: 85%;
    padding: 14px 18px;
}

.suggestion-header {
    font-weight: 600;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.suggestion-pills {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.pill {
    display: inline-block;
    font-size: 12px;
    padding: 5px 14px;
    border-radius: 20px;
    border: 1px solid;
    font-weight: 500;
}

.pill-dept { border-color: #D0E4F5; background: var(--white); color: var(--primary); }
.pill-urgent { border-color: #FECACA; background: #FEF2F2; color: #DC3545; font-weight: 600; }
.pill-routine { border-color: var(--gray-300); background: var(--white); color: var(--gray-600); }

.chat-message.links .message-bubble {
    background: #F0FDF4;
    border: 1px solid #86EFAC;
    max-width: 85%;
    padding: 16px;
}

.message-sender {
    font-weight: 600;
    font-size: 12px;
    margin-bottom: 6px;
    color: var(--gray-500);
}

.chat-message.aira .message-sender { color: var(--primary); }
.chat-message.user .message-sender { color: rgba(255,255,255,0.9); text-align: right; }

.message-content { word-wrap: break-word; }

.edit-indicator {
    font-size: 11px;
    color: var(--gray-400);
    font-style: italic;
    margin-left: 6px;
}

.deleted-message {
    font-style: italic;
    color: var(--gray-500);
}

.message-actions {
    position: absolute;
    top: -8px;
    right: -8px;
    display: none;
    gap: 4px;
    background: var(--white);
    border-radius: 12px;
    padding: 4px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--gray-200);
    z-index: 10;
}

.chat-message.user:hover .message-actions,
.chat-message.aira:hover .message-actions {
    display: flex;
}

.message-action-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s;
}

.message-action-btn:hover { background: var(--gray-100); }

.reply-preview {
    background: var(--gray-100);
    padding: 8px 12px;
    border-left: 3px solid var(--primary);
    border-radius: 6px;
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--gray-600);
}

.message-reactions {
    display: flex;
    gap: 4px;
    margin-top: 6px;
}

.reaction { font-size: 16px; padding: 2px; }

.reaction-picker {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 0;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    padding: 8px;
    box-shadow: var(--shadow-lg);
    gap: 6px;
    margin-bottom: 8px;
    z-index: 10;
}

.chat-message.aira:hover .reaction-picker { display: flex; }

.reaction-picker button {
    border: none;
    background: transparent;
    font-size: 20px;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: all 0.2s;
}

.reaction-picker button:hover {
    background: var(--gray-100);
    transform: scale(1.2);
}

/* FILE MESSAGE BUBBLE */
.file-message {
    background: var(--gray-100);
    padding: 12px;
    border-radius: 10px;
    margin-top: 8px;
    border: 1px solid var(--gray-300);
}

.file-preview-img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    margin-top: 8px;
}

.file-info {
    font-size: 13px;
    color: var(--gray-600);
    margin-top: 6px;
}

.controls-group {
    display: flex;
    gap: 10px;
    margin-top: 14px;
    padding: 14px;
    background: var(--gray-50);
    border-radius: 12px;
    border: 1px solid var(--gray-200);
}

.controls-group input {
    flex: 1;
    min-width: 200px;
    padding: 11px 16px;
    border-radius: 10px;
    border: 1px solid var(--gray-300);
    font-size: 14px;
    background: var(--white);
}

.input-group {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    align-items: center;
    position: relative;
}

.input-wrapper {
    flex: 1;
    position: relative;
}

.input-wrapper input {
    width: 100%;
    padding: 12px 90px 12px 18px;
    border-radius: 12px;
    border: 1px solid var(--gray-300);
    font-size: 15px;
    background: var(--white);
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.input-actions {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 4px;
}

.btn-voice-inside, .btn-attach-inside {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 8px;
    font-size: 18px;
    transition: all 0.2s;
}

.btn-voice-inside:hover, .btn-attach-inside:hover {
    background: var(--gray-100);
}

/* MIC RECORDING STATE */
.btn-voice-inside.recording {
    background: #FEE;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% {
        background: #FEE;
        transform: translateY(-50%) scale(1);
    }
    50% {
        background: #FDD;
        transform: translateY(-50%) scale(1.1);
    }
}

.btn {
    padding: 11px 20px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--white);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}

.link-item { margin: 10px 0; }
.link-label { font-weight: 600; margin-bottom: 6px; font-size: 13px; }

.link-input-group {
    display: flex;
    gap: 8px;
}

.link-input-group input {
    flex: 1;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--gray-300);
    font-size: 13px;
    font-family: monospace;
}

.link-input-group button {
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--gray-300);
    background: var(--white);
    cursor: pointer;
}

.typing-indicator span {
    display: inline-block;
    width: 6px;
    height: 6px;
    margin: 0 2px;
    background: var(--gray-400);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

.welcome-screen {
    text-align: center;
    padding: 40px 20px;
}

.welcome-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 18px;
    background: var(--primary-light);
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
}

.welcome-title {
    font-weight: 600;
    font-size: 22px;
    margin-bottom: 8px;
}

.welcome-suggestions {
    margin-top: 24px;
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.welcome-suggestions button {
    padding: 9px 16px;
    border: 1px solid var(--gray-300);
    border-radius: 20px;
    background: var(--white);
    cursor: pointer;
    font-size: 13px;
}

.app-footer {
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    padding: 18px 32px;
    text-align: center;
    font-size: 13px;
    color: var(--gray-500);
}

/* CUSTOM MODAL SYSTEM */
.custom-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s;
}

/* GUEST AUTH MODAL */
.guest-auth-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(6px);
    animation: fadeIn 0.3s;
}

.guest-auth-content {
    width: min(480px, 90vw);
    background: var(--white);
    border-radius: 20px;
    padding: 32px;
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.3s;
}

.guest-auth-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.guest-auth-icon {
    width: 48px;
    height: 48px;
    background: var(--primary-light);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.guest-auth-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--charcoal);
}

.guest-auth-close {
    margin-left: auto;
    width: 32px;
    height: 32px;
    border: none;
    background: var(--gray-100);
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s;
}

.guest-auth-close:hover {
    background: var(--gray-200);
}

.guest-auth-body {
    color: var(--gray-600);
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 24px;
}

.guest-auth-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.guest-auth-btn {
    padding: 12px 24px;
    border-radius: 12px;
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
}

.guest-auth-btn.primary {
    background: var(--primary);
    color: var(--white);
    flex: 1;
}

.guest-auth-btn.primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.guest-auth-btn.secondary {
    background: var(--white);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
    flex: 1;
}

.guest-auth-btn.secondary:hover {
    background: var(--gray-50);
}

.guest-auth-btn.tertiary {
    background: var(--gray-50);
    color: var(--gray-600);
    border: 1px solid var(--gray-200);
}

.guest-auth-btn.tertiary:hover {
    background: var(--gray-100);
}

.guest-cta-banner {
    margin-top: 12px;
    padding: 12px 16px;
    background: linear-gradient(135deg, var(--primary-light) 0%, #E6F2FF 100%);
    border: 1px solid #B3D9FF;
    border-radius: 10px;
    display: none;
}

.guest-cta-header {
    font-weight: 600;
    font-size: 14px;
    color: var(--charcoal);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.guest-cta-actions {
    display: flex;
    gap: 8px;
}

.guest-cta-actions .btn {
    padding: 8px 16px;
    font-size: 13px;
}

/* ANIMATED CURVED ARROW pointing to Start Consultation button */
.suggestion-arrow {
    position: absolute;
    right: -80px;
    top: 50%;
    transform: translateY(-50%);
    width: 80px;
    height: 100px;
    display: none;
    z-index: 5;
}

.suggestion-arrow.active {
    display: block;
    animation: arrowGlow 2s ease-in-out infinite;
}

.suggestion-arrow svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 2px 8px rgba(0, 102, 204, 0.4));
}

@keyframes arrowGlow {
    0%, 100% {
        opacity: 1;
        filter: drop-shadow(0 2px 8px rgba(0, 102, 204, 0.4));
    }
    50% {
        opacity: 0.7;
        filter: drop-shadow(0 2px 12px rgba(0, 102, 204, 0.6));
    }
}

/* Responsive arrow positioning */
@media (max-width: 768px) {
    .suggestion-arrow {
        right: auto;
        left: 50%;
        top: auto;
        bottom: -70px;
        transform: translateX(-50%);
        width: 60px;
        height: 70px;
    }
}

.modal-content {
    width: min(420px, 90vw);
    background: var(--white);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.3s;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 12px;
}

.modal-body {
    margin-bottom: 20px;
    color: var(--gray-600);
}

.modal-input {
    width: 100%;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--gray-300);
    font-size: 15px;
}

.modal-input[type="date"],
.modal-input[type="time"] {
    cursor: pointer;
}

.modal-input::-webkit-calendar-picker-indicator {
    cursor: pointer;
    padding: 4px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-8px); }
}
