/* smsm - Dark Theme Stylesheet (Arabic-first RTL) */

:root {
  --bg-darkest: #0a0d14;
  --bg-base: #0f141e;
  --bg-surface: #171f2c;
  --bg-card: #1f293d;
  --bg-hover: #26334d;
  --bg-input: #131a26;
  
  --border-subtle: #242f42;
  --border-strong: #33435c;
  
  --text-primary: #f0f6fc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --primary: #38bdf8;
  --primary-hover: #0284c7;
  --primary-glow: rgba(56, 189, 248, 0.15);
  
  --user-bubble: #0284c7;
  --user-text: #ffffff;
  --bot-bubble: #171f2c;
  --bot-text: #f0f6fc;
  
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Cairo", "Tahoma", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  width: 100%;
  background-color: var(--bg-darkest);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
}

/* ================== Login Page ================== */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: radial-gradient(circle at top center, #1b263b 0%, #0a0d14 70%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 24px;
  text-align: center;
}

.login-header .logo-circle {
  width: 68px;
  height: 68px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 2px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin: 0 auto 16px;
  box-shadow: 0 0 20px var(--primary-glow);
}

.login-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
}

.login-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: right;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-input {
  width: 100%;
  padding: 12px 14px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.error-banner {
  background-color: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--danger);
  color: #fca5a5;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  text-align: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-primary {
  background-color: var(--primary);
  color: #06111f;
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-hover);
  color: #fff;
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-block {
  width: 100%;
}

.login-footer {
  font-size: 12px;
  color: var(--text-muted);
}

/* ================== App Layout ================== */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  background-color: var(--bg-darkest);
  position: relative;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 320px;
  background-color: var(--bg-base);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100%;
  z-index: 100;
  transition: transform 0.25s ease-in-out;
}

.sidebar-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  font-size: 22px;
}

.brand-text h1 {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
}

.brand-text span {
  font-size: 12px;
  color: var(--text-secondary);
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background-color: var(--bg-card);
  color: var(--text-primary);
}

/* Projects Section */
.projects-section {
  padding: 14px 16px 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.section-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.projects-select-wrapper {
  position: relative;
}

.project-select {
  width: 100%;
  padding: 10px 14px;
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.project-select:focus {
  border-color: var(--primary);
}

.select-arrow {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--text-secondary);
  font-size: 11px;
}

/* Conversations List Header & Button */
.conversations-header {
  padding: 14px 16px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.btn-new-chat {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--primary);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-new-chat:hover {
  background-color: var(--primary);
  color: #06111f;
  border-color: var(--primary);
}

/* Conversations List */
.conversations-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.conversation-item {
  padding: 10px 14px;
  background-color: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: right;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.conversation-item:hover {
  background-color: var(--bg-surface);
}

.conversation-item.active {
  background-color: var(--bg-card);
  border-color: var(--border-strong);
}

.conv-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.conv-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-badge {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background-color: rgba(56, 189, 248, 0.15);
  color: var(--primary);
  white-space: nowrap;
}

.conv-date {
  font-size: 11px;
  color: var(--text-muted);
}

.empty-conversations {
  padding: 30px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.btn-logout {
  background: transparent;
  border: none;
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
}

.btn-logout:hover {
  background-color: rgba(239, 68, 68, 0.1);
}

/* ================== Chat Area ================== */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  background-color: var(--bg-darkest);
  position: relative;
  min-width: 0;
}

/* Chat Header */
.chat-header {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-subtle);
  background-color: var(--bg-base);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  height: 56px;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.chat-active-title {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-active-meta {
  font-size: 12px;
  color: var(--text-secondary);
}

.btn-menu-toggle {
  display: none;
}

/* Messages Scroll Container */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  scroll-behavior: smooth;
}

.welcome-screen {
  margin: auto;
  max-width: 480px;
  text-align: center;
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.welcome-screen .welcome-icon {
  font-size: 48px;
  margin-bottom: 8px;
}

.welcome-screen h2 {
  font-size: 22px;
  font-weight: 700;
}

.welcome-screen p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Message Bubble */
.message-row {
  display: flex;
  flex-direction: column;
  max-width: 80%;
  animation: fadeIn 0.15s ease-in;
}

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

.message-row.user {
  align-self: flex-start;
  text-align: right;
}

.message-row.assistant {
  align-self: flex-end;
  text-align: right;
}

.message-author {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
  padding: 0 4px;
}

.message-bubble {
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  position: relative;
}

.message-row.user .message-bubble {
  background-color: var(--user-bubble);
  color: var(--user-text);
  border-bottom-right-radius: var(--radius-sm);
}

.message-row.assistant .message-bubble {
  background-color: var(--bot-bubble);
  color: var(--bot-text);
  border: 1px solid var(--border-subtle);
  border-bottom-left-radius: var(--radius-sm);
}

.message-time {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 4px;
  text-align: left;
}

.message-row.assistant .message-time {
  color: var(--text-muted);
}

/* Thinking Indicator */
.thinking-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  align-self: flex-end;
  color: var(--primary);
  font-size: 13px;
  font-weight: 500;
}

.thinking-dots {
  display: flex;
  gap: 4px;
}

.thinking-dots span {
  width: 6px;
  height: 6px;
  background-color: var(--primary);
  border-radius: var(--radius-full);
  animation: pulse 1.2s infinite ease-in-out;
}

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

@keyframes pulse {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1.1); opacity: 1; }
}

/* Chat Input Bar (Bottom fixed/sticky) */
.chat-input-bar {
  padding: 12px 20px 16px;
  background-color: var(--bg-base);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.input-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 6px 12px;
  transition: border-color 0.2s;
}

.input-form:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

.chat-textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.4;
  resize: none;
  max-height: 160px;
  min-height: 24px;
  padding: 6px 0;
  direction: rtl;
}

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

.btn-send {
  background-color: var(--primary);
  color: #06111f;
  border: none;
  border-radius: var(--radius-md);
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  height: 38px;
}

.btn-send:hover:not(:disabled) {
  background-color: var(--primary-hover);
  color: #fff;
}

.btn-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Overlay for Mobile Drawer */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 90;
  backdrop-filter: blur(2px);
}

/* ================== Responsive (Mobile) ================== */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    transform: translateX(100%);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.6);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.active {
    display: block;
  }

  .btn-menu-toggle {
    display: inline-flex;
  }

  .chat-header {
    padding: 10px 16px;
  }

  .messages-container {
    padding: 16px 12px;
    gap: 14px;
  }

  .message-row {
    max-width: 92%;
  }

  .chat-input-bar {
    padding: 8px 10px 12px;
  }
}
