﻿:root {
  --primary-color: #c74249;
  --secondary-color: #b388ff;
  --text-primary: #333;
  --text-secondary: #666;
  --background-primary: #fff;
  --background-secondary: #f5f7fb;
  --background-tertiary: #edf0f7;
  --ai-message-bg: #f0f4ff;
  --user-message-bg: #c74249;
  --user-message-text: #fff;
  --border-color: #e0e0e0;
  --shadow-color: rgba(0, 0, 0, 0.1);
  --animation-speed: 0.3s;
  --border-radius: 8px;
  --typing-indicator-color: var(--primary-color);
}

#voice-button{
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    padding: 15px;
    cursor: pointer;
}

#voice-button:hover {
    color: var(--primary-color);
}

/* Add to existing <style> in your HTML */
button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

textarea:disabled {
    background-color: #f0f0f0;
    cursor: not-allowed;
}

.suggestion-chip:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.dark-mode {
  --primary-color: #9d74ff;
  --secondary-color: #b388ff;
  --text-primary: #e0e0e0;
  --text-secondary: #aaaaaa;
  --background-primary: #1a1a1a;
  --background-secondary: #252525;
  --background-tertiary: #333333;
  --ai-message-bg: #2d2d3d;
  --user-message-bg: #9d74ff;
  --user-message-text: #fff;
  --border-color: #444;
  --shadow-color: rgba(0, 0, 0, 0.6);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  transition: background-color var(--animation-speed),
    color var(--animation-speed);
}

body {
  background-color: var(--background-secondary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
}

.code-copy-container {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 10;
}

.code-copy-button {
  background-color: rgba(255, 255, 255, 0.1);
  color: #ddd;
  border: none;
  border-radius: 4px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.code-copy-button:hover {
  background-color: rgba(255, 255, 255, 0.2);
  color: white;
}

.code-copy-button.copied {
  background-color: #4caf50;
  color: white;
}

.container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  padding: 0px;
}

.app-container {
    display: flex;
    width: 100%;
    height: 100vh;
    background-color: var(--background-primary);
    border-radius: var(--border-radius);
    box-shadow: 0 8px 30px var(--shadow-color);
    overflow: hidden;
    position: relative;
    transition: all 0.3s ease;
}

/* Sidebar Styles */
.sidebar {
  width: 260px;
  background-color: var(--background-tertiary);
  padding: 20px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-color);
}

.logo {
  display: flex;
  align-items: center;
  font-size: 22px;
  font-weight: bold;
  margin-bottom: 24px;
  color: var(--primary-color);
}

.logo i {
  margin-right: 10px;
  font-size: 24px;
}

.new-chat-btn {
    vertical-align:middle;
  align-items: center;
  justify-content: center;
  background-color: var(--primary-color);
  color: white;
  border: none;
  padding: 12px;
  border-radius: var(--border-radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 20px;
  transition: background-color 0.2s, transform 0.1s;
}

.new-chat-btn:hover {
  background-color: var(--secondary-color);
  transform: translateY(-2px);
}

.new-chat-btn i {
  margin-right: 8px;
}

.history-container {
  flex: 1;
  overflow-y: auto;
}

.history-container h3 {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 10px;
  padding-left: 5px;
}

.chat-history-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--border-radius);
  margin-bottom: 5px;
  cursor: pointer;
  transition: background-color 0.2s;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  position: relative;
  overflow: visible;
}
#chat-history span {
  white-space: nowrap;
  width: 16ch;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-history-item:hover {
  background-color: var(--background-secondary);
}

.chat-history-item.active {
  background-color: rgba(124, 77, 255, 0.1);
  font-weight: 500;
}

.chat-history-item i {
  margin-right: 10px;
  color: var(--text-secondary);
  font-size: 14px;
}

.settings {
  margin-top: 20px;
  border-top: 1px solid var(--border-color);
  padding-top: 15px;
}

.settings button {
  display: flex;
  align-items: center;
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 10px 5px;
  width: 100%;
  text-align: left;
  cursor: pointer;
  border-radius: var(--border-radius);
  font-size: 14px;
  transition: background-color 0.2s;
}

.settings button:hover {
  background-color: var(--background-secondary);
  color: var(--text-primary);
}

.settings button i {
  margin-right: 10px;
  width: 16px;
}

/* Chat Container Styles */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--background-primary);
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;

    border-bottom: 1px solid var(--border-color);
    margin-top: 25px;
    margin-left: 10px;
}

.current-chat-title {
  font-weight: 600;
  font-size: 16px;
}

.header-actions button {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 16px;
  padding: 5px;
  border-radius: 5px;
  transition: color 0.2s, background-color 0.2s;
}

.header-actions button:hover {
  color: var(--primary-color);
  background-color: var(--background-tertiary);
}

/* Added regenerate, stop, and export button styling */
.header-actions button#regenerate-response {
  margin-right: 5px;
}

/* Chat messages */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 0;
}

.message {
  display: flex;
  margin: 25px;
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-content {
  max-width: 80%;
  padding: 5px 7px;
  border-radius: var(--border-radius);
  font-size: 15px;
  line-height: 1.5;
}

.message.ai {
  justify-content: flex-start;
}

.message.user {
  justify-content: flex-end;
}

.message.ai .message-content {
  background-color: var(--ai-message-bg);
  color: var(--text-primary);
  border-radius: var(--border-radius);
}

.message.user .message-content {
  background-color: var(--user-message-bg);
  color: var(--user-message-text);
  border-radius: var(--border-radius);
}

.message.ai .message-content h1 {
  font-size: 22px;
  margin: 16px 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
  color: var(--primary-color);
}

.message.ai .message-content h2 {
  font-size: 18px;
  margin: 14px 0 8px;
  color: var(--text-primary);
}

.message.ai .message-content h3 {
  font-size: 16px;
  margin: 12px 0 6px;
  color: var(--text-primary);
}

/* List styles for better readability */
.message.ai .message-content ul,
.message.ai .message-content ol {
  margin: 8px 0;
  padding-left: 25px;
}

.message.ai .message-content li {
  margin-bottom: 5px;
}

/* Block quote styling */
.message.ai .message-content blockquote {
  border-left: 4px solid var(--primary-color);
  padding: 0 0 0 15px;
  margin: 10px 0;
  color: var(--text-secondary);
}

/* Table styling */
.message.ai .message-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 15px 0;
}

.message.ai .message-content th,
.message.ai .message-content td {
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  text-align: left;
}

.message.ai .message-content th {
  background-color: var(--background-tertiary);
  font-weight: 600;
}

/* Links styling */
.message.ai .message-content a {
  color: var(--primary-color);
  text-decoration: none;
  transition: color 0.2s;
}

.message.ai .message-content a:hover {
  text-decoration: underline;
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-addition {
  color: #c792ea;
}

.hljs-number,
.hljs-string,
.hljs-doctag,
.hljs-regexp {
  color: #89ca78;
}

.hljs-title,
.hljs-section,
.hljs-built_in,
.hljs-name {
  color: #e2b93d;
}

.hljs-variable,
.hljs-template-variable,
.hljs-selector-id,
.hljs-class .hljs-title {
  color: #7fdbca;
}

.hljs-type,
.hljs-tag {
  color: #e06c75;
}

/* Language badge for code blocks */
pre::before {
  content: attr(class);
  position: absolute;
  top: 5px;
  left: 12px;
  font-size: 12px;
  color: #aaa;
  display: none;
}

/* Horizontal rule */
.message.ai .message-content hr {
  border: none;
  height: 1px;
  background-color: var(--border-color);
  margin: 15px 0;
}

.typing-indicator {
  display: flex;
  padding: 15px 25px;
}

.typing-dot {
  width: 8px;
  height: 8px;
  margin: 0 2px;
  background-color: var(--typing-indicator-color);
  border-radius: 260px;
  opacity: 0.6;
  animation: typingAnimation 1.5s infinite;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingAnimation {
  0% {
    transform: translateY(0px);
  }
  25% {
    transform: translateY(-5px);
  }
   50% {
    transform: translateY(0px);
  }
}

.input-area {
  padding: 5px 10px 0px;
  border-top: 1px solid var(--border-color);
}

.input-container {
  display: flex;
  position: relative;
  background-color: var(--background-tertiary);
  border-radius: var(--border-radius);
  overflow: hidden;
  margin-top: 10px;
}

/* Style for file upload button */
#file-upload-button {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  padding: 15px;
  cursor: pointer;
}

#file-upload-button:hover {
  color: var(--primary-color);
}

textarea {
  flex: 1;
  border: none;
  background: none;
  padding: 15px;
  font-size: 15px;
  resize: none;
  max-height: 150px;
  color: var(--text-primary);
  outline: none;
}

textarea::placeholder {
  color: var(--text-secondary);
}

#send-button {
  /* background-color: var(--primary-color); */
  color: rgb(0, 0, 0);
  border: none;
  width: 50px;
  cursor: pointer;
  font-size: 16px;
  transition: background-color 0.2s;
}

#send-button:hover {
  /* background-color: var(--secondary-color); */
}

.disclaimer {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
  margin-top: 10px;
}

/* Pending file preview (for selected file before send) */
#pending-file-preview {
  display: none;
  margin: 10px 0;
}

/* Intro Message Styles */
.intro-message {
  text-align: center;
  max-width: 600px;
  margin: 40px auto;
  padding: 30px;
  background-color: var(--background-primary);
  border-radius: var(--border-radius);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
  animation: fadeIn 0.5s ease-out;
}

.intro-message h1 {
  color: var(--primary-color);
  font-size: 28px;
  margin-bottom: 15px;
}

.intro-message p {
  color: var(--text-secondary);
  margin-bottom: 25px;
  font-size: 16px;
}

.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.suggestion-chip {
  background-color: var(--background-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.suggestion-chip:hover {
  background-color: var(--background-secondary);
  color: var(--primary-color);
  transform: translateY(-2px);
}

/* Code block styling */
pre {
  position: relative;
  background-color: #282c34;
  border-radius: 5px;
  padding: 12px;
  padding-top: 35px;
  overflow-x: auto;
  /* margin: 10px 0; */
  border: 1px solid #3e4451;
  color: #edf0f7;
}

code {
  font-family: "Fira Code", "Courier New", Courier, monospace;
  font-size: 14px;
}

pre code {
  white-space: pre;
  font-size: 14px;
  line-height: 1.5;
}

:not(pre) > code {
  background-color: rgba(125, 125, 125, 0.1);
  padding: 2px 4px;
  border-radius: 4px;
  color: var(--primary-color);
}

/* New CSS for chat options button and menu */
.chat-options-button {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 16px;
  padding: 5px;
  position: absolute;
  right: 10px;
  top: 260px;
  transform: translateY(-260px);
}

.chat-options-menu {
  position: absolute;
  right: 10px;
  top: 100%;
  background-color: var(--background-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: 0 4px 8px var(--shadow-color);
  z-index: 100;
}

.chat-options-item {
  padding: 8px 12px;
  cursor: pointer;
  white-space: nowrap;
}

.chat-options-item:hover {
  background-color: var(--background-secondary);
}

 .message-wrapper {
            margin-bottom: 10px;
            display: flex;
            flex-direction: column;
            align-items: flex-start;
            padding: 10px;
            position: relative;
        }

        .message-wrapper.user {
            align-items: flex-end;
        }

        .message-content {
            padding: 6px 20px;
            border-radius: 5px;
            background-color: #f1f1f1;
            word-wrap: break-word;
            position: relative;
            font-size: 14px;
        }

        .message-wrapper.ai .message-content {
            background-color: #eef0f7;
            color: #2c2929;
        }

        .message-wrapper.user .message-content {
            background-color: #eef0f7;
            color: #2c2929;
        }

        .timestamp {
            font-size: 10px;
            color: #888;
            margin-top: 5px;
            text-align: right;
            margin: 0;
            padding-top: 5px;
        }

        .loader {
            width: 12px;
            height: 12px;
            border: 3px solid #FFF;
            border-radius: 260px;
            display: inline-block;
            position: relative;
            box-sizing: border-box;
            animation: rotation 1s linear infinite;
        }

        .loader::after {
            content: '';
            box-sizing: border-box;
            position: absolute;
            left: 260px;
            top: 260px;
            transform: translate(-260px, -260px);
            width: 10px;
            height: 10px;
            border-radius: 260px;
            border: 3px solid transparent;
            border-bottom-color: #FF3D00;
        }

        @keyframes rotation {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        .microphone-effect {
            animation: rotateMic 1.5s linear infinite, pulseMic 0.75s ease-in-out infinite, growMic 1.5s ease-in-out infinite;
        }

        @keyframes rotateMic {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        @keyframes pulseMic {
            0% { opacity: 1; }
             50% { opacity: 0.5; }
            100% { opacity: 1; }
        }

        @keyframes growMic {
            0% { transform: scale(1); }
            50% { transform: scale(1.2); }
            100% { transform: scale(1); }
        }

        input.disabled {
            background-color: #f0f0f0;
            cursor: not-allowed;
        }

        #file-name-display {
            max-width: 200px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            font-size: 0.8em;
            color: #555;
            margin-top: 5px;
        }

        /* Sidebar toggle styles */
        

        .sidebar {
            width: 260px;
            overflow-x: hidden;
            transition: width 0.5s ease-in-out;
            background-color: #fff;
            overflow-y: auto;
        }

        .sidebar.collapsed {
            animation: collapseSidebar 0.5s forwards;
            padding: 0;
        }

        @keyframes collapseSidebar {
            from { width: 260px; }
            to { width: 0; }
        }

        .sidebar.expand {
            animation: expandSidebar 0.5s forwards;
        }

        @keyframes expandSidebar {
            from { width: 0; }
            to { width: 260px; }
        }

        .chat-container {
            flex: 1;
            display: flex;
            flex-direction: column;
            transition: margin-left 0.5s ease-in-out;
        }

            .chat-container.sidebar-collapsed {
                margin: auto;
                margin-top: 0;
                padding: 5px 0px;
            }

        .toggle-sidebar-btn {
            background: none;
            border: none;
            cursor: pointer;
            font-size: 18px;
            padding: 5px;
            margin-right: 10px;
        }

        .toggle-sidebar-btn i {
            color: #333;
        }

        .toggle-sidebar-btn:hover i {
            color: #ffa500;
        }

        /* Message actions styles */
        .message-actions {
            display: none;
            position: absolute;
            bottom: -13px;
            left: 10px;
            background-color: rgba(255, 255, 255, 0.9);
            border-radius: 5px;
            padding: 5px;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
        }

        .message-wrapper.ai:hover .message-actions {
            display: flex;
        }

        .message-action {
            background: none;
            border: none;
            cursor: pointer;
            padding: 5px;
            margin: 0 2px;
            font-size: 14px;
            color: #333;
            transition: color 0.2s ease;
        }

        .message-action:hover {
            color: #ffa500;
        }

        .message-action.liked {
            color: #28a745 !important; /* Green for liked */
        }

        .message-action.disliked {
            color: #dc3545 !important; /* Red for disliked */
        }

        .message-action.copied i::before {
            content: "\f00c"; /* fa-check */
        }

        .message-action.reading i::before {
            content: "\f04c"; /* fa-pause */
        }

        .dark-mode .message-actions {
            background-color: rgba(50, 50, 50, 0.9);
        }

        .dark-mode .message-action {
            color: #ddd;
        }

        .dark-mode .message-action:hover {
            color: #ffa500;
        }

        .dark-mode .message-action.liked {
            color: #28a745 !important;
        }

        .dark-mode .message-action.disliked {
            color: #dc3545 !important;
        }

@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        z-index: 1000;
        height: 100%;
        width: 100%;
    }

        .sidebar.collapsed {
            transform: translateX(-100%);
            width: 260px;
        }

    .chat-container {
        width: 100%;
    }

        .chat-container.sidebar-collapsed {
            margin-left: 0;
            height:100%;
        }

    .message-actions {
        bottom: 10px;
        left: 5px;
        padding: 3px;
    }

    .message-action {
        font-size: 12px;
        padding: 3px;
    }

    #toggle-sidebar {
        margin-left: 10px;
        z-index: 9999;
        top: 0;
        left: 0;
        position: absolute;
    }
    }

    .logo {
        display: block;
        align-items: center;
        font-size: 22px;
        font-weight: bold;
        margin-bottom: 24px;
        text-align: center;
        color: var(--primary-color);
    }

@media (max-width: 430px) {
    .sidebar {
        width: 100% !important;
    }
}


.chat-container {
    max-width: 1200px;
    margin: auto;
    height: 95vh;
    padding: 10px 5px;
    margin-top: 0;
    top: 0;
    left: 0;
}


.spinner::after {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-left: 5px;
    border-radius: 260px;
    background-color: red;
    animation: blink 1s infinite;
}
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.typing-indicator.user {
    text-align: left;
    margin-left: 20px;
}
.typing-indicator.user .typing-dot {
    background-color: #007bff; /* Blue for user, adjust as needed */
}
/* Hiệu ứng sóng */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    height: 40px;
    margin-top: 10px;
    margin-bottom: 20px;
}

.obj {
    width: 4px;
    height: 0;
    background: #e71550;
    border-radius: 10px;
    animation: loading 1.2s infinite;
}

    .obj:nth-child(2) {
        animation-delay: 0.15s;
    }

    .obj:nth-child(3) {
        animation-delay: 0.3s;
    }

    .obj:nth-child(4) {
        animation-delay: 0.45s;
    }

    .obj:nth-child(5) {
        animation-delay: 0.6s;
    }

    .obj:nth-child(6) {
        animation-delay: 0.75s;
    }

    .obj:nth-child(7) {
        animation-delay: 0.9s;
    }

    .obj:nth-child(8) {
        animation-delay: 1.05s;
    }

@keyframes loading {
    0% {
        height: 5px;
    }

    50% {
        height: 40px;
    }

    100% {
        height: 5px;
    }
}

/* Container trong Swal */
.swal-recorder-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 0;
}

/* Hướng dẫn */
.swal-instruction {
    margin-top: 10px;
    font-size: 15px;
    text-align: center;
}

/* Tuỳ chỉnh hộp thoại nếu cần */
.swal2-custom-popup {
    padding: 30px 20px;
    border-radius: 12px;
    max-width: 400px;
}

.markdown-body {
    box-sizing: border-box;
    min-width: 200px;
    max-width: 1200px;
    padding: 25px;
}

@media (max-width: 767px) {
    .markdown-body {
        padding: 15px;
    }
}