/* Majdi Command Center — Design System */
:root {
  --color-olive: #5C5A3C;
  --color-warm-brown: #8B7355;
  --color-cream: #F5F0E8;
  --color-dark-bg: #1A1814;
  --color-dark-surface: #1E1C17;
  --color-dark-elevated: #252320;
  --color-gold: #B48C50;
  --color-teal: #2A8B8B;
  --color-text-primary: #E8E0D4;
  --color-text-secondary: #A39888;
  --color-text-muted: #6B5B45;
  --color-border: rgba(139, 115, 85, 0.2);
  --color-border-active: rgba(139, 115, 85, 0.5);
  --color-success: #34D399;
  --color-warning: #FBBF24;
  --color-error: #F87171;

  --font-display: 'Georgia', 'Noto Kufi Arabic', serif;
  --font-body: 'DM Sans', 'Noto Kufi Arabic', sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  --bottom-nav-height: 0px;
}

/* =================== Light Mode =================== */
[data-theme="light"] {
  --color-olive: #5C5A3C;
  --color-warm-brown: #8B7355;
  --color-cream: #F5F0E8;
  --color-dark-bg: #F5F0E8;
  --color-dark-surface: #EDE7DB;
  --color-dark-elevated: #FFFFFF;
  --color-gold: #9A7530;
  --color-text-primary: #2C2518;
  --color-text-secondary: #6B5B45;
  --color-text-muted: #A39888;
  --color-border: rgba(139, 115, 85, 0.15);
  --color-border-active: rgba(139, 115, 85, 0.4);
  --color-success: #059669;
  --color-warning: #D97706;
  --color-error: #DC2626;
}

/* Light mode overrides for specific elements */
[data-theme="light"] .msg-user {
  color: #fff;
}
[data-theme="light"] input,
[data-theme="light"] textarea,
[data-theme="light"] select {
  background: #FFFFFF;
}
[data-theme="light"] .msg-assistant pre {
  background: #2C2518;
  color: #E8E0D4;
}
[data-theme="light"] .msg-assistant code {
  color: #2C2518;
}
[data-theme="light"] .msg-assistant p code {
  background: rgba(92,90,60,0.1);
  color: var(--color-olive);
}

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

html {
  scroll-behavior: smooth;
}

html, body, #root {
  height: 100%;
  overflow: hidden;
  background: var(--color-dark-bg);
  color: var(--color-text-primary);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Allow scrolling on landing page */
.landing-scroll {
  overflow: auto !important;
}

body {
  padding-top: var(--safe-top);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--color-border-active); }

/* Hide scrollbar utility */
.hide-scrollbar {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.hide-scrollbar::-webkit-scrollbar {
  display: none;
}

/* Input reset — prevent iOS zoom */
input, textarea, select {
  font-size: 16px;
  font-family: var(--font-body);
  color: var(--color-text-primary);
  background: var(--color-dark-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.2s;
}
input:focus, textarea:focus {
  border-color: var(--color-gold);
  box-shadow: 0 0 0 3px rgba(180,140,80,0.1);
}

button {
  font-family: var(--font-body);
  cursor: pointer;
  border: none;
  outline: none;
  transition: all 0.2s;
}

/* =================== Layout =================== */
.app-layout {
  display: flex;
  height: 100%;
  overflow: hidden;
}

.sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--color-dark-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Show delete button on hover */
.sidebar button:hover .show-on-hover {
  opacity: 0.6 !important;
}
.show-on-hover:hover {
  opacity: 1 !important;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* =================== Dashboard Header =================== */
.dashboard-header {
  border-bottom: 1px solid var(--color-border);
  background: linear-gradient(180deg, var(--color-dark-surface) 0%, var(--color-dark-bg) 100%);
}

/* =================== Mobile app home =================== */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

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

.mobile-home {
  animation: fadeIn 0.2s ease;
}

/* =================== Mobile =================== */
@media (max-width: 1023px) {
  /* Sidebar drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 300px;
    min-width: 300px;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,0.4);
  }
  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
    backdrop-filter: blur(2px);
  }
  .sidebar-overlay.open {
    display: block;
  }

  .sidebar-close-btn {
    display: flex !important;
  }
}

@media (min-width: 1024px) {
  .sidebar-overlay { display: none !important; }
  .bottom-nav { display: none !important; }
}

/* =================== Status dot =================== */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.status-dot.active { background: var(--color-success); box-shadow: 0 0 6px var(--color-success); }
.status-dot.idle { background: var(--color-warning); }
.status-dot.offline { background: var(--color-text-muted); }

/* =================== Chat bubbles =================== */
.msg-user {
  background: linear-gradient(135deg, var(--color-olive), #6B6847);
  color: var(--color-cream);
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-sm) var(--radius-lg);
  padding: 12px 16px;
  max-width: 85%;
  margin-left: auto;
  word-break: break-word;
  box-shadow: 0 2px 8px rgba(92,90,60,0.2);
}
.msg-assistant {
  background: var(--color-dark-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) var(--radius-sm);
  padding: 12px 16px;
  max-width: 85%;
  word-break: break-word;
}

/* Code blocks inside messages */
.msg-assistant pre {
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  overflow-x: auto;
  margin: 8px 0;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.5;
}
.msg-assistant code {
  font-family: var(--font-mono);
  font-size: 13px;
}
.msg-assistant p code {
  background: rgba(180,140,80,0.1);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--color-gold);
}

/* =================== Buttons =================== */
.btn-primary {
  background: linear-gradient(135deg, var(--color-olive), #6B6847);
  color: var(--color-cream);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  min-height: 44px;
  min-width: 44px;
  box-shadow: 0 2px 8px rgba(92,90,60,0.2);
}
.btn-primary:hover {
  box-shadow: 0 4px 16px rgba(92,90,60,0.3);
  transform: translateY(-1px);
}
.btn-primary:active {
  transform: translateY(0);
}
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}
.btn-ghost:hover { background: rgba(255,255,255,0.05); }

.btn-gold {
  background: linear-gradient(135deg, var(--color-gold), #D4A660);
  color: #1A1814;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  min-height: 44px;
}
.btn-gold:hover {
  box-shadow: 0 4px 16px rgba(180,140,80,0.3);
  transform: translateY(-1px);
}

/* =================== Cards =================== */
.card {
  background: var(--color-dark-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: all 0.3s ease;
}
.card:hover {
  border-color: rgba(180,140,80,0.3);
}

/* =================== Toast =================== */
.toast-container {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  animation: slideDown 0.3s ease;
  min-width: 200px;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.toast.success { background: var(--color-success); color: #000; }
.toast.error { background: var(--color-error); color: #fff; }
.toast.info { background: var(--color-gold); color: #000; }

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

/* =================== Animations =================== */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.loading-dots span {
  animation: pulse 1.4s infinite;
  display: inline-block;
}
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }
