/* ============================================================
   DEBIEB-GPT — CSS
   Creator: Yassine Debieb / ضبيب ياسين
   ============================================================ */

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

:root {
  --bg:        #0c0c0f;
  --bg2:       #13131a;
  --bg3:       #1a1a24;
  --border:    rgba(255,255,255,0.07);
  --border2:   rgba(255,255,255,0.12);
  --text:      #f0f0f5;
  --text2:     #9090a8;
  --text3:     #5a5a72;
  --accent:    #7c5cfc;
  --accent2:   #a78bfa;
  --gold:      #f5c842;
  --danger:    #f87171;
  --sidebar-w: 260px;
  --radius:    12px;
  --radius-lg: 18px;
  --transition: 0.18s ease;
}

html { font-size: 16px; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

/* ===================== SIDEBAR ===================== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform var(--transition);
  z-index: 100;
}

.sidebar-top {
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.logo-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--accent), #c084fc);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Syne', sans-serif;
  font-weight: 800; font-size: 16px; color: #fff;
  flex-shrink: 0;
}

.logo-text {
  font-family: 'Syne', sans-serif;
  font-weight: 700; font-size: 17px;
  letter-spacing: -0.02em;
}

.new-chat-btn {
  width: 100%;
  display: flex; align-items: center; gap: 8px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text);
  border-radius: var(--radius);
  padding: 9px 14px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px; cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}
.new-chat-btn:hover { background: var(--bg); border-color: var(--accent); }

.chat-history {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
}

.history-label {
  font-size: 11px; font-weight: 500;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 8px 8px;
}

.history-item {
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text2);
  cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background var(--transition), color var(--transition);
}
.history-item:hover { background: var(--bg3); color: var(--text); }

.sidebar-bottom {
  padding: 16px;
  border-top: 1px solid var(--border);
}

/* ---- LANGUAGE SWITCHER ---- */
.lang-switcher {
  display: flex; gap: 6px;
  margin-bottom: 14px;
}
.lang-btn {
  flex: 1;
  padding: 6px 0;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text2);
  font-size: 12px; font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: 'DM Sans', sans-serif;
}
.lang-btn.active, .lang-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---- CREDITS ---- */
.credits { text-align: center; }
.credits-name {
  font-family: 'Syne', sans-serif;
  font-size: 14px; font-weight: 600;
  color: var(--text);
}
.credits-ar {
  font-size: 13px;
  color: var(--accent2);
  direction: rtl;
  margin: 1px 0 3px;
}
.credits-sub { font-size: 11px; color: var(--text3); }

/* ===================== SIDEBAR TOGGLE (mobile) ===================== */
.sidebar-toggle {
  display: none;
  position: fixed; top: 14px; left: 14px; z-index: 200;
  background: var(--bg2);
  border: 1px solid var(--border2);
  color: var(--text);
  border-radius: 9px;
  width: 38px; height: 38px;
  align-items: center; justify-content: center;
  cursor: pointer;
}

/* ===================== MAIN ===================== */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* ---- MODAL ---- */
.modal-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 300;
}
.modal-overlay.hidden { display: none; }

.modal {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  max-width: 400px; width: 90%;
  text-align: center;
  animation: fadeUp 0.3s ease;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.modal-logo {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--accent), #c084fc);
  border-radius: 16px;
  font-family: 'Syne', sans-serif;
  font-weight: 800; font-size: 26px; color: #fff;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
}

.modal-title {
  font-family: 'Syne', sans-serif;
  font-size: 22px; font-weight: 700;
  margin-bottom: 6px;
}
.modal-sub { font-size: 14px; color: var(--text2); margin-bottom: 4px; }
.modal-hint { font-size: 13px; margin-bottom: 20px; }
.modal-hint a { color: var(--accent2); text-decoration: none; }
.modal-hint a:hover { text-decoration: underline; }

.api-input {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  font-family: monospace;
  margin-bottom: 14px;
  outline: none;
  transition: border-color var(--transition);
}
.api-input:focus { border-color: var(--accent); }

.start-btn {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, var(--accent), #9f7aea);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-family: 'Syne', sans-serif;
  font-size: 15px; font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition);
}
.start-btn:hover { opacity: 0.9; }

/* ---- WELCOME SCREEN ---- */
.welcome-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  animation: fadeIn 0.4s ease;
}
.welcome-screen.hidden { display: none; }

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

.welcome-logo {
  width: 72px; height: 72px;
  background: linear-gradient(135deg, var(--accent), #c084fc);
  border-radius: 22px;
  font-family: 'Syne', sans-serif;
  font-weight: 800; font-size: 34px; color: #fff;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 20px;
  box-shadow: 0 0 40px rgba(124, 92, 252, 0.3);
}

.welcome-title {
  font-family: 'Syne', sans-serif;
  font-size: 36px; font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #fff 40%, var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 10px;
}

.welcome-sub {
  font-size: 16px; color: var(--text2);
  margin-bottom: 32px;
}

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

.suggestion-chip {
  padding: 10px 18px;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 100px;
  color: var(--text2);
  font-size: 13.5px;
  cursor: pointer;
  transition: all var(--transition);
  font-family: 'DM Sans', sans-serif;
}
.suggestion-chip:hover {
  border-color: var(--accent);
  color: var(--accent2);
  background: rgba(124, 92, 252, 0.08);
}

/* ---- CHAT AREA ---- */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0;
  display: none;
  flex-direction: column;
  gap: 0;
}
.chat-area.visible { display: flex; }

.message-row {
  display: flex;
  padding: 12px 24px;
  gap: 14px;
  animation: fadeIn 0.2s ease;
}
.message-row.user { flex-direction: row-reverse; }

.avatar {
  width: 34px; height: 34px;
  border-radius: 10px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
}
.avatar.ai {
  background: linear-gradient(135deg, var(--accent), #c084fc);
  color: #fff;
  font-family: 'Syne', sans-serif;
  font-weight: 800;
}
.avatar.user-av {
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text2);
}

.bubble {
  max-width: min(560px, 75%);
  padding: 13px 16px;
  border-radius: var(--radius);
  font-size: 15px;
  line-height: 1.65;
}
.bubble.ai {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  border-top-left-radius: 4px;
}
.bubble.user {
  background: linear-gradient(135deg, var(--accent), #9f7aea);
  color: #fff;
  border-top-right-radius: 4px;
}
.bubble img {
  max-width: 100%; border-radius: 10px; margin-top: 8px;
  display: block;
}

/* Typing indicator */
.typing-indicator {
  display: flex; gap: 5px; align-items: center;
  padding: 4px 0;
}
.typing-indicator span {
  width: 7px; height: 7px;
  background: var(--accent2);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
  0%,80%,100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-6px); opacity: 1; }
}

/* Code blocks */
.bubble pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  overflow-x: auto;
  margin-top: 8px;
  font-size: 13px;
  font-family: 'Courier New', monospace;
}
.bubble code { font-family: 'Courier New', monospace; font-size: 0.9em; }

/* ---- INPUT BAR ---- */
.input-bar-wrapper {
  padding: 16px 20px 14px;
  background: var(--bg);
  border-top: 1px solid var(--border);
}

.input-bar {
  max-width: 760px;
  margin: 0 auto;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 10px 10px 8px;
  transition: border-color var(--transition);
}
.input-bar:focus-within { border-color: var(--accent); }

.mode-toggle {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: 2px;
}
.mode-btn {
  width: 32px; height: 32px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text3);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}
.mode-btn.active, .mode-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.message-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  resize: none;
  max-height: 180px;
  overflow-y: auto;
  padding: 4px 0;
}
.message-input::placeholder { color: var(--text3); }

.send-btn {
  width: 38px; height: 38px;
  background: var(--accent);
  border: none;
  border-radius: 10px;
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: opacity var(--transition), transform var(--transition);
}
.send-btn:hover { opacity: 0.85; }
.send-btn:active { transform: scale(0.95); }

.input-footer {
  text-align: center;
  font-size: 11.5px;
  color: var(--text3);
  margin-top: 8px;
}

/* Mode indicator */
.mode-indicator {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px;
  padding: 3px 10px;
  border-radius: 100px;
  margin-bottom: 4px;
  margin-left: 72px;
}
.mode-indicator.image {
  background: rgba(245, 200, 66, 0.12);
  color: var(--gold);
  border: 1px solid rgba(245, 200, 66, 0.2);
}
.mode-indicator.text {
  background: rgba(124, 92, 252, 0.12);
  color: var(--accent2);
  border: 1px solid rgba(124, 92, 252, 0.2);
}

/* ===================== RTL (Arabic) ===================== */
[dir="rtl"] .message-row { flex-direction: row-reverse; }
[dir="rtl"] .message-row.user { flex-direction: row; }
[dir="rtl"] .bubble.ai { border-top-left-radius: var(--radius); border-top-right-radius: 4px; }
[dir="rtl"] .bubble.user { border-top-right-radius: var(--radius); border-top-left-radius: 4px; }
[dir="rtl"] .sidebar { border-right: none; border-left: 1px solid var(--border); }
[dir="rtl"] .mode-indicator { margin-left: 0; margin-right: 72px; }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 700px) {
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  [dir="rtl"] .sidebar { left: auto; right: 0; transform: translateX(100%); }
  [dir="rtl"] .sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: flex; }
  .main { padding-left: 0; }
  .welcome-title { font-size: 26px; }
  .message-row { padding: 10px 14px; }
}

/* ===================== ERROR TOAST ===================== */
.toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
  background: #3a1a1a;
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 10px 20px;
  border-radius: 100px;
  font-size: 13.5px;
  z-index: 999;
  animation: fadeIn 0.2s ease;
}
