:root {
    /* Main background: Very light gray-blue */
    --bg: #f8fafc; 
    
    /* Sidebar: Deep navy for professional contrast */
    --sidebar: #1e293b; 
    
    /* Card/Bubble backgrounds: Pure white */
    --card: #ffffff; 
    
    /* Primary Aero Blue (#3f6ac9) */
    --mint: #3f6ac9; 
    
    /* Secondary Accent / User Bubble */
    --violet: #3f6ac9; 
    
    /* Text: High contrast charcoal */
    --text-high: #0f172a; 
    
    /* Muted text: Slate gray */
    --text-low: #64748b; 
    
    /* Borders: Soft blue-tinted gray */
    --border: rgba(63, 106, 201, 0.1); 
}

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

body {
    background-color: var(--bg);
    color: var(--text-high);
    font-family: 'Plus Jakarta Sans', sans-serif;
    height: 100vh;
    overflow: hidden;
}

.chat-app-container {
    display: flex;
    height: 100vh;
}

/* --- SIDEBAR --- */
.chat-sidebar {
    width: 320px;
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 30px;
    color: white; /* Sidebar text is light on dark navy */
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
}

.btn-back { 
    color: #94a3b8; 
    text-decoration: none; 
    font-size: 0.85rem; 
    font-weight: 700; 
    transition: 0.3s;
}
.btn-back:hover { color: var(--mint); }

.case-id { font-size: 0.7rem; color: var(--mint); font-weight: 800; letter-spacing: 1px; }

.context-card {
    background: rgba(255, 255, 255, 0.05);
    padding: 20px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 40px;
}

.card-label { font-size: 0.65rem; color: #94a3b8; text-transform: uppercase; margin-bottom: 15px; letter-spacing: 1px; }

.mini-ticket { border-left: 2px solid var(--mint); padding-left: 15px; }
.m-route { font-size: 1.1rem; font-weight: 800; margin-bottom: 5px; color: white; }
.m-date { font-size: 0.8rem; color: #94a3b8; margin-bottom: 5px; }
.m-status { font-size: 0.75rem; color: var(--mint); font-weight: 700; }

.agent-info { display: flex; align-items: center; gap: 15px; margin-top: auto; padding: 20px 0; border-top: 1px solid rgba(255, 255, 255, 0.1); }
.agent-avatar { position: relative; }
.agent-avatar img { width: 45px; height: 45px; border-radius: 50%; border: 2px solid var(--mint); }
.online-status { position: absolute; bottom: 2px; right: 2px; width: 10px; height: 10px; background: #10b981; border-radius: 50%; border: 2px solid var(--sidebar); }
.agent-text strong { display: block; font-size: 0.9rem; color: white; }
.agent-text p { font-size: 0.75rem; color: #94a3b8; }

.sidebar-footer { font-size: 0.7rem; text-align: center; color: #94a3b8; margin-top: 10px; }

/* --- MAIN CHAT AREA --- */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background: white;
}

.chat-header {
    padding: 20px 40px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
}

.header-info h3 { font-size: 1.1rem; color: var(--text-high); }
.header-info p { font-size: 0.8rem; color: #10b981; font-weight: 600; }

.btn-end { background: transparent; border: 1px solid #ef4444; color: #ef4444; padding: 8px 16px; border-radius: 8px; font-weight: 700; cursor: pointer; transition: 0.3s; }
.btn-end:hover { background: #ef4444; color: white; }

.chat-messages {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 25px;
    background-color: #f8fafc;
}

.system-msg { text-align: center; margin: 20px 0; }
.system-msg span { font-size: 0.7rem; color: var(--text-low); text-transform: uppercase; font-weight: 700; }
.system-msg p { font-size: 0.85rem; color: var(--text-low); margin-top: 5px; font-style: italic; }

.msg { max-width: 70%; display: flex; flex-direction: column; }
.msg-bubble { padding: 16px 20px; border-radius: 20px; font-size: 0.95rem; line-height: 1.5; box-shadow: 0 2px 5px rgba(0,0,0,0.02); }
.msg-time { font-size: 0.7rem; color: var(--text-low); margin-top: 8px; font-weight: 600; }

.msg.agent { align-self: flex-start; }
.msg.agent .msg-bubble { background: white; border: 1px solid var(--border); color: var(--text-high); border-bottom-left-radius: 4px; }

.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.user .msg-bubble { background: var(--mint); color: white; border-bottom-right-radius: 4px; box-shadow: 0 4px 10px rgba(63, 106, 201, 0.2); }

/* --- INPUT AREA --- */
.chat-input-area {
    padding: 25px 40px;
    background: white;
    border-top: 1px solid var(--border);
}

.input-wrapper {
    background: #f1f5f9;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 8px;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: 0.3s;
}

.input-wrapper:focus-within {
    border-color: var(--mint);
    background: white;
    box-shadow: 0 0 0 4px rgba(63, 106, 201, 0.05);
}

.input-wrapper input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-high);
    padding: 10px;
    outline: none;
    font-size: 1rem;
}

.btn-attach { background: transparent; border: none; color: var(--text-low); font-size: 1.2rem; cursor: pointer; padding-left: 10px; transition: 0.3s; }
.btn-attach:hover { color: var(--mint); }

.btn-send { 
    background: var(--mint); 
    color: white; 
    border: none; 
    width: 40px; 
    height: 40px; 
    border-radius: 10px; 
    cursor: pointer; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    transition: 0.3s; 
}
.btn-send:hover { background: var(--sidebar); transform: scale(1.05); }

/* Scrollbar Styling */
.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 10px; }

@media (max-width: 800px) {
    .chat-sidebar { display: none; }
    .msg { max-width: 90%; }
}