/* Reset and base styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Body styling with professional colors */
body {
  margin: 0;
  font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Tahoma, Arial, sans-serif;
  height: 100vh;
  background: #1a1d29;
  color: #e8eaed;
  overflow: hidden;
  transition: background 0.3s ease;
}

/* Main wrapper styling */
.wrapper {
  display: flex;
  height: 100vh;
  width: 100%;
}

/* Sidebar styling - Professional design */
.sidebar {
  width: 280px;
  min-width: 280px;
  background: #252936;
  border-right: 1px solid #2d3142;
  padding: 24px;
  position: relative;
  transition: all 0.3s ease;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
}

/* Collapsed sidebar */
.sidebar.collapsed {
  min-width: 0;
  width: 70px;
  padding: 24px 15px;
  overflow: hidden;
}

.sidebar.collapsed .toggle-content {
  display: none;
}

/* Toggle button styling */
.sidebar .toggle-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 36px;
  height: 36px;
  border: none;
  background: #2d3142;
  color: #e8eaed;
  font-size: 18px;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar .toggle-btn:hover {
  background: #353a4d;
}

/* Sidebar content styling */
.sidebar .toggle-content {
  margin-top: 50px;
}

.sidebar h3 {
  margin: 0 0 16px 0;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: #9aa0a6;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar button {
  display: block;
  width: 100%;
  padding: 12px 16px;
  margin: 8px 0;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  background: #2d3142;
  color: #e8eaed;
  text-align: left;
}

.sidebar button:hover {
  background: #353a4d;
}

/* Active state for buttons */
.sidebar button.theme-btn.active,
.sidebar button.mode-btn.active,
.sidebar button.language-btn.active {
  background: #1e88e5;
  color: #ffffff;
}

/* Custom manager button special styling */
.sidebar button.custom-manager-btn {
  background: #2d3142;
  border: 1px solid #3d4154;
  margin-top: 16px;
  font-weight: 600;
}

.sidebar button.custom-manager-btn:hover {
  background: #353a4d;
  border-color: #1e88e5;
}

/* Horizontal line */
.sidebar hr {
  border: 0;
  border-top: 1px solid #2d3142;
  margin: 20px 0;
}

/* Chat container styling */
.chat-container {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  background: #1a1d29;
}

/* Chat window styling */
.chat-window {
  flex-grow: 1;
  padding: 32px;
  overflow-y: auto;
  scroll-behavior: smooth;
}

/* Custom scrollbar */
.chat-window::-webkit-scrollbar {
  width: 6px;
}

.chat-window::-webkit-scrollbar-track {
  background: #252936;
}

.chat-window::-webkit-scrollbar-thumb {
  background: #3d4154;
  border-radius: 3px;
}

.chat-window::-webkit-scrollbar-thumb:hover {
  background: #4a4f64;
}

/* Message styling - Professional card design */
.message {
  display: block;
  width: fit-content;
  max-width: 70%;
  padding: 14px 18px;
  border-radius: 8px;
  word-wrap: break-word;
  margin: 16px 0;
  clear: both;
  animation: slideIn 0.2s ease-out;
  line-height: 1.6;
  font-size: 15px;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 0.5;
  }
  50% {
    opacity: 1;
  }
}

/* User message styling */
.message.user {
  background: #1e88e5;
  text-align: right;
  margin-right: 0;
  margin-left: auto;
  color: #ffffff;
  border-radius: 8px 8px 2px 8px;
}

/* AI message styling */
.message.ai {
  background: #2d3142;
  text-align: left;
  margin-left: 0;
  margin-right: auto;
  color: #e8eaed;
  border-radius: 8px 8px 8px 2px;
  border: 1px solid #353a4d;
}

/* Agent label styling */
.agent-label {
  font-size: 10px;
  font-weight: 500;
  color: #9aa0a6;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid #353a4d;
}

.message-content {
  margin-top: 0;
}

/* Message time styling */
.message-time {
  font-size: 10px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 8px;
  text-align: right;
  padding-top: 4px;
}

.message.ai .message-time {
  color: #9aa0a6;
  text-align: left;
}

.message.ai p {
  margin: 0.5em 0;
}

.message.ai p:first-child {
  margin-top: 0;
}

.message.ai p:last-child {
  margin-bottom: 0;
}

/* Input area styling */
.input-area {
  border-top: 1px solid #2d3142;
  padding: 20px 32px;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  background: #252936;
}

/* Textarea styling */
.input-area textarea {
  flex-grow: 1;
  padding: 14px 18px;
  font-size: 15px;
  border: 1px solid #3d4154;
  border-radius: 8px;
  background: #2d3142;
  color: #e8eaed;
  resize: none;
  min-height: 52px;
  max-height: 200px;
  font-family: inherit;
  transition: all 0.2s ease;
}

.input-area textarea:focus {
  outline: none;
  border-color: #1e88e5;
  background: #353a4d;
}

.input-area textarea::placeholder {
  color: #6b7280;
}

/* Button styling in input area */
.input-area button {
  padding: 14px 28px;
  font-size: 15px;
  font-weight: 500;
  border: none;
  background: #1e88e5;
  color: #ffffff;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.input-area button:hover {
  background: #1976d2;
}

.input-area button:active {
  background: #1565c0;
}

.input-area button:disabled {
  background: #3d4154;
  color: #6b7280;
  cursor: not-allowed;
}

/* Light mode styles */
body.light-mode {
  background: #f5f5f5;
  color: #202124;
}

body.light-mode .sidebar {
  background: #ffffff;
  border-right: 1px solid #e0e0e0;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05);
}

body.light-mode .sidebar .toggle-btn {
  background: #f5f5f5;
  color: #202124;
}

body.light-mode .sidebar .toggle-btn:hover {
  background: #eeeeee;
}

body.light-mode .sidebar h3 {
  color: #5f6368;
}

body.light-mode .sidebar button {
  background: #f5f5f5;
  color: #202124;
}

body.light-mode .sidebar button:hover {
  background: #eeeeee;
}

body.light-mode .sidebar button.theme-btn.active,
body.light-mode .sidebar button.mode-btn.active {
  background: #1e88e5;
  color: #ffffff;
}

body.light-mode .sidebar button.custom-manager-btn {
  background: #ffffff;
  border: 1px solid #e0e0e0;
}

body.light-mode .sidebar button.custom-manager-btn:hover {
  background: #f5f5f5;
  border-color: #1e88e5;
}

body.light-mode .chat-container {
  background: #ffffff;
}

body.light-mode .message.user {
  background: #1e88e5;
  color: #ffffff;
}

body.light-mode .message.ai {
  background: #f5f5f5;
  color: #202124;
  border: 1px solid #e0e0e0;
}

body.light-mode .agent-label {
  color: #5f6368;
  border-bottom: 1px solid #e0e0e0;
}

body.light-mode .message-time {
  color: rgba(0, 0, 0, 0.4);
}

body.light-mode .message.ai .message-time {
  color: #5f6368;
}

body.light-mode .input-area {
  background: #ffffff;
  border-top: 1px solid #e0e0e0;
}

body.light-mode .input-area textarea {
  background: #ffffff;
  color: #202124;
  border: 1px solid #e0e0e0;
}

body.light-mode .input-area textarea:focus {
  border-color: #1e88e5;
  background: #ffffff;
}

body.light-mode .input-area textarea::placeholder {
  color: #9aa0a6;
}

body.light-mode .sidebar hr {
  border-top: 1px solid #e0e0e0;
}

body.light-mode .chat-window::-webkit-scrollbar-track {
  background: #f5f5f5;
}

body.light-mode .chat-window::-webkit-scrollbar-thumb {
  background: #e0e0e0;
}

body.light-mode .chat-window::-webkit-scrollbar-thumb:hover {
  background: #d0d0d0;
}

/* Modal styles - Professional design */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Modal content */
.modal-content {
  background: #252936;
  color: #e8eaed;
  margin: 5% auto;
  padding: 32px;
  border: 1px solid #2d3142;
  width: 90%;
  max-width: 600px;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.2s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-content h2 {
  margin: 0 0 24px 0;
  font-size: 24px;
  font-weight: 600;
  text-align: center;
  color: #e8eaed;
}

.modal-content h3 {
  margin: 24px 0 12px 0;
  font-size: 16px;
  font-weight: 600;
  color: #e8eaed;
}

.modal-section {
  margin-bottom: 24px;
}

/* Close button */
.close {
  color: #9aa0a6;
  float: right;
  font-size: 28px;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: transparent;
}

.close:hover,
.close:focus {
  color: #e8eaed;
  background: #2d3142;
}

/* Form and input element styles in modal */
.custom-modal-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.custom-modal-form input.custom-input,
.custom-modal-form textarea.custom-textarea {
  width: 100%;
  padding: 12px 16px;
  margin-bottom: 0;
  border: 1px solid #3d4154;
  border-radius: 8px;
  background: #2d3142;
  color: #e8eaed;
  font-size: 15px;
  font-family: inherit;
  transition: all 0.2s ease;
}

.custom-modal-form input.custom-input:focus,
.custom-modal-form textarea.custom-textarea:focus {
  outline: none;
  border-color: #1e88e5;
  background: #353a4d;
}

.custom-modal-form textarea.custom-textarea {
  min-height: 120px;
  resize: vertical;
}

.custom-modal-form input.custom-input::placeholder,
.custom-modal-form textarea.custom-textarea::placeholder {
  color: #6b7280;
}

/* Submit button in form */
.custom-submit-btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  background: #1e88e5;
  color: #ffffff;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 8px;
}

.custom-submit-btn:hover {
  background: #1976d2;
}

.custom-submit-btn:active {
  background: #1565c0;
}

/* Custom options list styling */
.custom-option-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  margin-bottom: 8px;
  border: 1px solid #3d4154;
  border-radius: 8px;
  background: #2d3142;
  transition: all 0.2s ease;
}

.custom-option-item:hover {
  background: #353a4d;
  border-color: #4a4f64;
}

.custom-option-item span {
  flex-grow: 1;
  cursor: pointer;
  font-weight: 400;
  color: #e8eaed;
  font-size: 14px;
}

/* Button styles in modal */
.custom-delete-btn,
.custom-edit-btn,
.custom-refresh-btn {
  color: #ffffff;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 13px;
  font-weight: 500;
  margin-left: 6px;
}

.custom-delete-btn {
  background: #d32f2f;
}

.custom-delete-btn:hover {
  background: #c62828;
}

.custom-edit-btn {
  background: #1e88e5;
}

.custom-edit-btn:hover {
  background: #1976d2;
}

.custom-refresh-btn {
  background: #388e3c;
}

.custom-refresh-btn:hover {
  background: #2e7d32;
}

/* Text direction classes */
.rtl {
  direction: rtl;
  text-align: right;
}

.ltr {
  direction: ltr;
  text-align: left;
}

/* Light mode modal styles */
body.light-mode .modal-content {
  background: #ffffff;
  color: #202124;
  border: 1px solid #e0e0e0;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

body.light-mode .modal-content h2 {
  color: #202124;
}

body.light-mode .modal-content h3 {
  color: #202124;
}

body.light-mode .close {
  color: #5f6368;
  background: transparent;
}

body.light-mode .close:hover {
  background: #f5f5f5;
  color: #202124;
}

body.light-mode .custom-modal-form input.custom-input,
body.light-mode .custom-modal-form textarea.custom-textarea {
  background: #ffffff;
  color: #202124;
  border: 1px solid #e0e0e0;
}

body.light-mode .custom-modal-form input.custom-input:focus,
body.light-mode .custom-modal-form textarea.custom-textarea:focus {
  border-color: #1e88e5;
  background: #ffffff;
}

body.light-mode .custom-modal-form input.custom-input::placeholder,
body.light-mode .custom-modal-form textarea.custom-textarea::placeholder {
  color: #9aa0a6;
}

body.light-mode .custom-option-item {
  background: #f5f5f5;
  border: 1px solid #e0e0e0;
}

body.light-mode .custom-option-item:hover {
  background: #eeeeee;
  border-color: #d0d0d0;
}

body.light-mode .custom-option-item span {
  color: #202124;
}

/* Responsive design */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    position: fixed;
    z-index: 100;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }

  .sidebar:not(.collapsed) {
    transform: translateX(0);
  }

  .message {
    max-width: 85%;
  }

  .modal-content {
    width: 95%;
    padding: 24px;
    margin: 10% auto;
  }
}
