body {
    background: #BBC6D6;
    font-family: Georgia, serif;
    display: flex;
    flex-direction: column;
    height: 100vh;
    color: #333;
    margin: 0;
}

/*top horizontal navbar*/
.sidebar {
    width: 100%;
    background: linear-gradient(90deg, #1f2b34 0%, #2C4251 100%);
    color: white;
    padding: 10px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-sizing: border-box;
    box-shadow: 0 2px 12px rgba(0,0,0,0.22);
    position: relative;
    z-index: 200;
    flex-shrink: 0;
}

.logo-title {
    display: flex;
    align-items: center;
    font-size: 17px;
    margin: 0;
    color: white;
    font-family: Georgia, serif;
    font-weight: normal;
    gap: 8px;
    white-space: nowrap;
}

.logo {
    height: 36px;
    width: auto;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
}

.nav-hamburger {
    position: relative;
    display: flex;
    align-items: center;
}

.menu-toggle {
    font-size: 22px;
    cursor: pointer;
    color: #c1c1c1;
    padding: 4px 6px;
    border-radius: 4px;
    transition: color 0.2s;
    user-select: none;
}

.menu-toggle:hover { color: white; }

.nav-links {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    background-color: #fff;
    padding: 10px;
    border-radius: 8px;
    flex-direction: column;
    gap: 4px;
    list-style: none;
    margin: 0;
    min-width: 160px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    z-index: 400;
}

.nav-links li { display: block; }

.nav-links.active { display: flex; }

.nav-links a {
    text-decoration: none;
    color: #1f2b34;
    font-size: 14px;
    padding: 8px 12px;
    display: block;
    border-radius: 6px;
    transition: background 0.2s;
}

.nav-links a:hover {
    background-color: #b6c649;
    color: #fff;
}

.topbar-right {
    position: relative;
    display: flex;
    align-items: center;
    margin-left: auto;
    gap: 10px;
}

.avatar {
    cursor: pointer;
    border-radius: 50%;
    overflow: hidden;
    width: 36px;
    height: 36px;
    border: 2px solid rgba(255,255,255,0.3);
    transition: border-color 0.2s;
    flex-shrink: 0;
}

.avatar:hover { border-color: #b6c649; }

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.avatar-menu {
    display: none;
    flex-direction: column;
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    background: white;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    min-width: 140px;
    z-index: 400;
    padding: 6px 0;
    overflow: hidden;
}

.avatar-menu.active { display: flex; }

.avatar-menu .menu-item {
    padding: 10px 18px;
    font-size: 14px;
    color: #1f2b34;
    cursor: pointer;
    transition: background 0.15s;
}

.avatar-menu .menu-item:hover { background: #f0f4f8; }

.sidebar-page-links {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 20px;
    border-top: 1px solid rgba(255,255,255,0.15);
}

.sidebar-link {
    cursor: pointer;
    font-size: 12px;
    padding: 4px 0;
    color: rgba(255,255,255,0.75);
}

.sidebar-link:hover {
    color: white;
    text-decoration: underline;
}

.content {
    display: flex;
    flex: 1;
    padding: 20px;
    overflow: hidden;
}

.chat-page {
    display: flex;
    width: 100%;
    gap: 20px;
}

.chat-sidebar {
    width: 30%;
    background-color: #fff;
    border-radius: 12px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    overflow: hidden;
}

.chats-header h1 {
    font-size: 26px;
    margin: 0 0 8px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.chat-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}

.chat-controls input {
    flex: 1; padding: 5px 10px;
    border-radius: 5px;
    border: 1px solid #ccc;
}

.add-chat {
    cursor: pointer;
    border: none;
    background-color: #2c4251;
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 16px;
}

.add-chat:hover {
    background-color: #1f2b34;
}

.menu-btn {
    border: none;
    background: none;
    font-size: 20px;
    cursor: pointer;
    color: #2c4251;
}

.chat-menu {
    display: none; 
    position: absolute;
    top: 38px;
    right: 0;
    background-color: #1f2b34;
    border-radius: 8px;
    padding: 8px 0;
    min-width: 160px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.25);
    flex-direction: column;
    z-index: 100;
}

.chat-menu.active {
    display: flex;
}

.chat-menu .menu-item {
    padding: 10px 15px;
    cursor: pointer;
    font-size: 14px;
    color: white;
    transition: background 0.2s;
}

.chat-menu .menu-item:hover {
    background-color: #2c3e50;
}

.chats-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
    flex: 1;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s;
}

.chat-item:hover {
    background-color: #f1f2d6;
}

.chat-item.active {
    background-color: #dcdde1; 
}

.chat-avatar {
    width: 42px;
    height: 42px;
    background-color: #718093;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: bold;
    font-size: 14px;
    flex-shrink: 0;
}

.chat-info h3 {
    font-size: 15px;
    margin: 0;
    font-weight: 600;
}

.chat-info p { 
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
    font-size: 13px;
    margin: 2px 0 0;
    color: #777;
}

.chat-meta {
    margin-left: auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
}

.time {
    font-size: 11px;
    color: #999;
}

.unread {
    background-color: #e84118;
    color: white;
    font-size: 11px;
    font-weight: bold;
    border-radius: 50%;
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.unread:empty {
    display: none; 
}

.chat-main {
    flex: 2;
    display: flex;
    flex-direction: column;
    background-color: #fff;
    border-radius: 10px;
    padding: 15px;
    gap: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    overflow: hidden;
}

.chat-main-header {
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.chat-main-header h1 { font-size: 22px; margin: 0; }

.btn-leave-chat {
    margin-left: auto;
    background: none;
    border: 1px solid #e05555;
    color: #e05555;
    border-radius: 6px;
    padding: 5px 14px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.btn-leave-chat:hover { background: #e05555; color: #fff; }
body.dark .btn-leave-chat { border-color: #e07777; color: #e07777; }
body.dark .btn-leave-chat:hover { background: #e07777; color: #fff; }

.ai-badge {
    font-size: 11px;
    background: #e8f4e8;
    color: #2e7d32;
    padding: 3px 8px;
    border-radius: 99px;
    font-family: sans-serif;
}

.messages {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    padding-right: 5px;
}

.message {
    max-width: 60%;
    padding: 8px 12px;
    border-radius: 15px;
    font-size: 14px;
    background-color: #dcdde1; 
    align-self: flex-start;
}

.message p { margin: 0 0 4px; }

.message.sent { 
    background-color: #b6c649;
    color: white;
    align-self: flex-end;
}

.sender-name { 
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: #555;
    margin-bottom: 3px;
}

.message.sent .sender-name {
    display: none;
}

.msg-time {
    display: block;
    font-size: 10px;
    color: rgba(0,0,0,0.4);
    text-align: right;
}

.message.sent .msg-time {
    color: rgba(255,255,255,0.7);
}

.typing-indicator {
    display: none;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
    padding: 6px 16px 10px;
}

.typing-indicator.active {
    display: flex;
}

.typing-bubble {
    display: flex;
    align-items: center;
    gap: 5px;
    background: #e4e6eb;
    border-radius: 18px 18px 18px 4px;
    padding: 10px 14px;
}

.typing-bubble span {
    width: 7px;
    height: 7px;
    background: #90959d;
    border-radius: 50%;
    animation: bounce 1.2s infinite;
}

.typing-bubble span:nth-child(2) { animation-delay: 0.2s; }
.typing-bubble span:nth-child(3) { animation-delay: 0.4s; }

.typing-label {
    font-size: 11px;
    color: #999;
    padding-left: 4px;
}

@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%            { transform: translateY(-6px); }
}

body.dark .typing-bubble { background: #2c3e50; }
body.dark .typing-bubble span { background: #6a8aaa; }
body.dark .typing-label { color: #6a8aaa; }

.chat-input {
    display: flex;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid #eee;
}

.chat-input input {
    flex: 1;
    padding: 9px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
}

.chat-input button {
    padding: 9px 18px;
    background: #2c4251;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
}

.chat-input button:hover {
    background: #1f2b34;
}

.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.modal-overlay.open {
    display: flex;
}

.modal-box {
    background: white;
    padding: 30px;
    border-radius: 12px;
    width: 340px;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 10px; right: 14px;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #555;
}

.modal-close:hover {
    color: #000;
}

.modal-title {
    font-size: 18px;
    margin: 0 0 4px;
}

.modal-subtitle {
    font-size: 13px;
    color: #888;
    margin: 0 0 16px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
}

.form-input {
    width: 100%;
    padding: 8px;
    margin-bottom: 14px;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-sizing: border-box;
    font-size: 14px;
}

.form-hint {
    font-size: 11px;
    color: #aaa;
    margin: -10px 0 14px;
}

.form-select {
    width: 100%;
    padding: 8px;
    margin-bottom: 18px;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-sizing: border-box;
    font-size: 14px;
}

.form-submit {
    width: 100%;
    padding: 10px;
    background: #2C4251;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
}

.form-submit:hover {
    background: #1f2b34;
}

/*float + clearfix = rubric req*/
.logo-float {
    float: left;
    margin-right: 10px;
}

.clearfix::after {
    content: "";
    display: block;
    clear: both;
}

@media (max-width: 768px) {
    body { flex-direction: column; height: auto; }
    .sidebar { width: 100%; height: auto; flex-direction: row; flex-wrap: wrap; }
    .menu-toggle { display: block; }
    .content { padding: 10px; }
    .chat-page { flex-direction: column; }
    .chat-sidebar { width: 100%; }
    .topbar-right { position: static; padding: 8px 16px; }
}

@media (max-width: 480px) {
    .chat-main { padding: 8px; }
    .message { max-width: 90%; }
}

.chat-menu .menu-item.filter-active {
    background-color: #2c4251;
    font-weight: 600;
}

/*dark mode*/
body.dark { background: #1a2330; color: #e0e0e0; }

body.dark .sidebar { background-color: #0f1923; }
body.dark .nav-links { background-color: #1e2d3d; }
body.dark .nav-links a { color: rgba(255,255,255,0.8); }

body.dark .chat-sidebar { background: #243040; }
body.dark .chats-header h1 { color: #e0e0e0; }
body.dark .chat-search { background: #1e2d3d; color: #e0e0e0; border-color: #344558; }
body.dark .add-chat { background: #344558; color: #ccd6e0; }
body.dark .menu-btn { color: #8a9bb0; }
body.dark .chat-menu { background: #1a2330; border-color: #344558; }
body.dark .chat-menu .menu-item { color: #ccd6e0; }
body.dark .chat-menu .menu-item:hover { background: #2c3e50; }

body.dark .chat-item { color: #ccd6e0; border-bottom-color: #344558; }
body.dark .chat-item h3 { color: #e0e0e0; }
body.dark .chat-item p { color: #8a9bb0; }
body.dark .chat-item.active { background: #344558; }
body.dark .chat-item:hover { background: #2c3e50; }
body.dark .time { color: #6a8aaa; }
body.dark .chat-avatar { background: #344558; color: #ccd6e0; }

body.dark .chat-main { background: #1e2d3d; }
body.dark .chat-main-header { border-bottom-color: #344558; }
body.dark .chat-main-header h1 { color: #e0e0e0; }

body.dark .message.received { background: #243040; color: #e0e0e0; }
body.dark .message.sent { color: #e0e0e0; }
body.dark .sender-name { color: #8a9bb0; }
body.dark .msg-time { color: #6a8aaa; }

body.dark .chat-input { border-top-color: #344558; background: #1e2d3d; }
body.dark #message-input { background: #243040; color: #e0e0e0; border-color: #344558; }
body.dark #message-input::placeholder { color: #6a8aaa; }

body.dark .avatar-menu { background: #1e2d3d; }
body.dark .avatar-menu .menu-item { color: #ccd6e0; }
body.dark .avatar-menu .menu-item:hover { background: #243040; }
body.dark .modal-box { background: #243040; }
body.dark .modal-title { color: #e0e0e0; }
body.dark .modal-subtitle { color: #8a9bb0; }
body.dark .form-label { color: #8a9bb0; }
body.dark .form-input, body.dark .form-select { background: #1a2330; color: #e0e0e0; border-color: #344558; }
