/* ============================================
   DCN AI – ChatGPT/Claude-style UI
   ============================================ */

:root {
  --bg-main: #0d0d0f;
  --bg-sidebar: #171719;
  --bg-sidebar-hover: #1e1e21;
  --bg-message-user: #2d7d46;
  --bg-message-ai: #1e1e21;
  --bg-input: #2d2d30;
  --bg-input-focus: #3d3d42;
  --border: rgba(255, 255, 255, 0.08);
  --text: #ececec;
  --text-muted: #9b9ba5;
  --accent: #2d7d46;
  --accent-hover: #3d9d56;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  background: var(--bg-main);
  color: var(--text);
  height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* LAYOUT */
.layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ========== SIDEBAR ========== */
.sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 12px;
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease, min-width 0.2s ease;
}

.sidebar.collapsed {
  width: 56px;
  min-width: 56px;
}

.sidebar.collapsed .brand > span,
.sidebar.collapsed .new-chat > span,
.sidebar.collapsed .chat-item > span,
.sidebar.collapsed .chat-item-actions,
.sidebar.collapsed .sidebar-user-details,
.sidebar.collapsed .sidebar-footer {
  opacity: 0;
  width: 0;
  overflow: hidden;
  padding: 0;
  margin: 0;
  white-space: nowrap;
}

.sidebar.collapsed .new-chat,
.sidebar.collapsed .chat-item {
  justify-content: center;
  padding: 12px;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
}

.brand img {
  height: 28px;
  width: 28px;
  object-fit: contain;
  border-radius: 6px;
}

.sidebar-toggle {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}

.sidebar-toggle:hover {
  color: var(--text);
  background: var(--bg-sidebar-hover);
}

.new-chat {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  margin-bottom: 12px;
  transition: background 0.15s, border-color 0.15s;
}

.new-chat:hover {
  background: var(--bg-sidebar-hover);
  border-color: rgba(255, 255, 255, 0.12);
}

.new-chat svg {
  flex-shrink: 0;
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.chat-list-empty {
  font-size: 13px;
  color: var(--text-muted);
  padding: 12px;
  margin: 0;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.chat-item:hover {
  background: var(--bg-sidebar-hover);
  color: var(--text);
}

.chat-item.active {
  background: var(--bg-message-ai);
  color: var(--text);
}

.chat-item svg {
  flex-shrink: 0;
  opacity: 0.8;
}

.chat-item .chat-item-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}

.chat-item-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
}

.chat-item:hover .chat-item-actions {
  opacity: 1;
}

.chat-item-actions button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-item-actions button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
}

.chat-item-actions button svg {
  width: 14px;
  height: 14px;
}

.chat-item input.chat-item-rename {
  flex: 1;
  min-width: 0;
  background: var(--bg-input);
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: var(--text);
  padding: 4px 8px;
  font-size: 13px;
  font-family: var(--font);
}

.chat-item input.chat-item-rename:focus {
  outline: none;
}

.sidebar-user {
  padding: 10px 12px;
  margin-top: 8px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}

.sidebar-user-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar-user-email {
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-logout {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  margin-top: 2px;
}

.sidebar-user-logout:hover {
  color: var(--accent);
}

.sidebar.collapsed .sidebar-user {
  padding: 10px;
}

.sidebar.collapsed .sidebar-user-info {
  justify-content: center;
}

.sidebar-footer {
  font-size: 11px;
  color: var(--text-muted);
  padding: 12px 0 0;
  margin-top: auto;
  border-top: 1px solid var(--border);
  line-height: 1.4;
}

.sidebar-footer .copyright {
  opacity: 0.7;
}

/* ========== CHAT AREA ========== */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-main);
}

.messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px 24px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.messages::-webkit-scrollbar {
  width: 8px;
}

.messages::-webkit-scrollbar-track {
  background: transparent;
}

.messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

.messages::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Message row: avatar + content */
.message-row {
  display: flex;
  gap: 16px;
  width: 100%;
  max-width: 768px;
  margin-bottom: 24px;
  animation: messageIn 0.25s ease;
}

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

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

.message-avatar {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-message-ai);
  color: var(--text-muted);
}

.message-row.user .message-avatar {
  background: var(--bg-message-user);
  color: white;
}

.message-avatar svg {
  width: 20px;
  height: 20px;
}

.message-content {
  flex: 1;
  min-width: 0;
}

.message-content .label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.message-row.user .message-content .label {
  text-align: right;
}

.message {
  padding: 14px 18px;
  border-radius: var(--radius);
  line-height: 1.65;
  font-size: 15px;
}

.message-row .message.user {
  background: var(--bg-message-user);
  color: white;
  border-radius: 18px 18px 4px 18px;
}

.message-row .message.ai {
  background: var(--bg-message-ai);
  border: 1px solid var(--border);
  border-radius: 18px 18px 18px 4px;
}

/* Thinking state – ChatGPT/Claude style */
.message.ai.thinking {
  position: relative;
  overflow: hidden;
  min-height: 44px;
}

.message.ai.thinking::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    transparent 0%,
    rgba(255, 255, 255, 0.03) 45%,
    rgba(255, 255, 255, 0.06) 50%,
    rgba(255, 255, 255, 0.03) 55%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: thinkingShimmer 2s ease-in-out infinite;
  pointer-events: none;
}

@keyframes thinkingShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.thinking-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  position: relative;
  z-index: 1;
}

.thinking-dots {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 20px;
}

.thinking-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: thinkingBounce 0.6s ease-in-out infinite both;
}

.thinking-dots span:nth-child(1) { animation-delay: 0s; }
.thinking-dots span:nth-child(2) { animation-delay: 0.1s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.2s; }

@keyframes thinkingBounce {
  0%, 60%, 100% {
    transform: translateY(0) scale(1);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-6px) scale(1.1);
    opacity: 1;
  }
}

/* Typing cursor */
.typing-cursor {
  display: inline;
  animation: typingBlink 1s step-end infinite;
  margin-left: 2px;
  color: var(--accent);
  font-weight: 100;
}

@keyframes typingBlink {
  50% { opacity: 0; }
}

.separator {
  height: 1px;
  background: linear-gradient(to right, transparent, var(--border), transparent);
  margin: 8px 0;
  max-width: 768px;
  width: 100%;
}

/* Markdown in AI messages */
.message.ai h1, .message.ai h2, .message.ai h3 {
  margin: 16px 0 8px;
  font-weight: 600;
}

.message.ai h1 { font-size: 1.35em; }
.message.ai h2 { font-size: 1.2em; }
.message.ai h3 { font-size: 1.05em; }

.message.ai p {
  margin: 0 0 10px;
}

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

.message.ai ul, .message.ai ol {
  margin: 10px 0;
  padding-left: 1.4em;
}

.message.ai pre {
  background: #0f0f11;
  padding: 16px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 12px 0;
  border: 1px solid var(--border);
}

.message.ai code {
  font-family: "SF Mono", "Consolas", "Monaco", monospace;
  font-size: 13px;
}

.message.ai p code {
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.92em;
}

.message.ai blockquote {
  border-left: 4px solid var(--accent);
  margin: 12px 0;
  padding-left: 16px;
  color: var(--text-muted);
}

/* ========== WELCOME ========== */
.welcome {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  pointer-events: none;
}

.welcome.has-messages {
  display: none;
}

.welcome-inner {
  max-width: 640px;
  text-align: center;
  pointer-events: auto;
}

.welcome-icon {
  color: var(--text-muted);
  margin-bottom: 20px;
}

.welcome-icon svg {
  opacity: 0.6;
}

.welcome h1 {
  font-size: 1.75rem;
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--text);
}

.welcome p {
  color: var(--text-muted);
  font-size: 15px;
  margin: 0 0 28px;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.suggestion {
  background: var(--bg-message-ai);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-family: inherit;
}

.suggestion:hover {
  background: var(--bg-input);
  border-color: rgba(255, 255, 255, 0.15);
}

/* ========== INPUT ========== */
.input-wrapper {
  padding: 16px 24px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-main);
}

.input-bar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  max-width: 768px;
  margin: 0 auto;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 12px 16px 12px 20px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-bar:focus-within {
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
}

textarea {
  flex: 1;
  resize: none;
  background: transparent;
  color: var(--text);
  border: none;
  padding: 8px 0;
  font-size: 15px;
  font-family: var(--font);
  line-height: 1.5;
  min-height: 24px;
  max-height: 200px;
}

textarea::placeholder {
  color: var(--text-muted);
}

textarea:focus {
  outline: none;
}

button.send {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
}

button.send:hover {
  background: var(--accent-hover);
}

button.send:active {
  transform: scale(0.96);
}

.input-hint {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  margin: 8px 0 0;
  max-width: 768px;
  margin-left: auto;
  margin-right: auto;
}

/* ========== REGLEMENT PAGINA ========== */
.reglement-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-main);
}

.reglement-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  max-width: 768px;
  margin: 0 auto;
  width: 100%;
}

.reglement-content h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--text);
}

.reglement-content h2 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 28px 0 12px;
  color: var(--text);
}

.reglement-content h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 20px 0 8px;
  color: var(--text);
}

.reglement-content p {
  margin: 0 0 12px;
  line-height: 1.65;
  color: var(--text);
}

.reglement-content ul,
.reglement-content ol {
  margin: 8px 0 16px;
  padding-left: 1.5em;
}

.reglement-content li {
  margin-bottom: 6px;
}

.reglement-sidebar-nav {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.reglement-sidebar-nav a {
  font-size: 14px;
  color: var(--text-muted);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}

.reglement-sidebar-nav a:hover {
  color: var(--accent);
  background: rgba(255, 255, 255, 0.05);
}
