/* 1. Global Variables & Themes */
:root {
    --primary: #166534; 
    --accent: #22c55e;
    --bg-body: #f1f5f9; 
    --bg-app: #ffffff;
    --bg-chat: linear-gradient(to bottom, #ffffff, #f9fafb);
    --bg-input: #f8fafc; 
    --text-main: #1e293b;
    --text-light: #64748b; 
    --bot-bubble: #f1f5f9;
    --border: #e2e8f0; 
    --icon-color: #64748b;
    --link-color: #0d00ff; /* Professional Blue for Light Mode */
}

body.dark-mode {
    --bg-body: #0f172a; 
    --bg-app: #1e293b;
    --bg-chat: #1e293b; 
    --bg-input: #0f172a;
    --text-main: #f8fafc; 
    --text-light: #94a3b8;
    --bot-bubble: #334155; 
    --border: #334155;
    --icon-color: #f8fafc;
    --link-color: #ffa321; /* High-Visibility Orange for Dark Mode */
}

/* 2. Global Reset */
* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease; 
}

body { 
    font-family: 'Inter', sans-serif; 
    background: var(--bg-body); 
    color: var(--text-main); 
    display: flex; 
    height: 100vh; 
    justify-content: center; 
    overflow: hidden; 
}

/* 3. Main Layout */
.app-container { 
    width: 100%; 
    max-width: 850px; 
    height: 96vh; 
    margin-top: 2vh; 
    display: flex; 
    flex-direction: column; 
    background: var(--bg-app); 
    border-radius: 24px; 
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1); 
    position: relative; 
}

header { 
    padding: 1.5rem; 
    border-bottom: 1px solid var(--border); 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    gap: 8px; 
    position: relative; 
}

.logo-img { 
    height: 35px; 
    width: auto; 
    object-fit: contain; 
}

#theme-toggle { 
    position: absolute; 
    top: 1.5rem; 
    right: 1.5rem; 
    background: none; 
    border: none; 
    cursor: pointer; 
    width: 40px; 
    height: 40px; 
    border-radius: 12px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    color: var(--icon-color); 
}

#theme-toggle:hover { background: var(--bg-body); }
#theme-toggle svg { width: 22px; height: 22px; stroke-width: 2; }

/* 4. Status Badge */
.status-badge { 
    display: flex; 
    align-items: center; 
    gap: 6px; 
    padding: 4px 12px; 
    background: rgba(16, 185, 129, 0.1); 
    border-radius: 20px; 
}

.status-dot { width: 6px; height: 6px; border-radius: 50%; }
.status-text { 
    font-size: 0.65rem; 
    font-weight: 700; 
    text-transform: uppercase; 
    letter-spacing: 0.05em; 
}

.online .status-dot { 
    background: var(--accent); 
    box-shadow: 0 0 8px var(--accent); 
}
.online .status-text { color: var(--accent); }

.typing .status-dot { 
    background: var(--text-light); 
    animation: pulse 1s infinite; 
}
.typing .status-text { color: var(--text-light); }

/* 5. Chat History & Bubbles */
#chat-box { 
    flex: 1; 
    overflow-y: auto; 
    overflow-x: hidden; 
    padding: 2.5rem; 
    display: flex; 
    flex-direction: column; 
    gap: 1.5rem; 
    background: var(--bg-chat); 
}

.message-row { 
    display: flex; 
    gap: 12px; 
    width: 100%;
    max-width: 85%; 
    animation: slideUp 0.4s ease; 
}

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

.bubble { 
    padding: 1rem 1.25rem; 
    border-radius: 18px; 
    line-height: 1.6; 
    font-size: 0.95rem; 
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Fix for Link Visibility */
.bubble a {
    color: var(--link-color);
    text-decoration: underline;
    font-weight: 500;
    transition: color 0.3s ease;
}

.bot .bubble { 
    background: var(--bot-bubble); 
    border: 1px solid var(--border); 
    border-top-left-radius: 4px; 
    color: var(--text-main); 
}

.user .bubble { 
    background: var(--primary); 
    color: white; 
    border-top-right-radius: 4px; 
    box-shadow: 0 4px 12px rgba(22, 101, 52, 0.15); 
}

.bubble ul { list-style-type: disc; margin: 10px 0 10px 20px; }
.bubble li { margin-bottom: 6px; }

/* 6. Typing Animations */
.loader { display: flex; gap: 4px; padding: 6px 0; }
.dot { 
    width: 5px; 
    height: 5px; 
    background: var(--text-light); 
    border-radius: 50%; 
    animation: bounce 1.4s infinite ease-in-out both; 
}
.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }

/* 7. Input Section */
.input-wrapper { 
    padding: 1.5rem 2.5rem; 
    background: var(--bg-app); 
    border-top: 1px solid var(--border); 
}

.input-box { 
    display: flex; 
    align-items: flex-end; 
    background: var(--bg-input); 
    border-radius: 16px; 
    padding: 8px 12px; 
    border: 1.5px solid var(--border); 
    transition: 0.3s;
    min-height: 56px;
}

.input-box:focus-within { border-color: var(--primary); }

#user-input { 
    flex: 1; 
    border: none; 
    background: transparent; 
    padding: 10px 4px; 
    outline: none; 
    font-size: 0.95rem; 
    color: var(--text-main); 
    font-family: inherit; 
    resize: none; 
    max-height: 150px; 
    overflow-y: auto; 
    line-height: 1.5; 
}

button#send-btn { 
    background: var(--primary); 
    color: white; 
    border: none; 
    padding: 12px 24px; 
    border-radius: 12px; 
    cursor: pointer; 
    font-weight: 600; 
    margin-left: 8px;
    margin-bottom: 4px; 
}

/* 8. Keyframes */
@keyframes slideUp { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }
@keyframes bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* Scrollbar Styling */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }