@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800;900&family=Outfit:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
  /* Light SaaS Modern Palette (Aligned with Desktop App) */
  --bg-primary: #f8fafc;
  --bg-secondary: #f1f5f9;
  --bg-card: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.92);
  --border-color: #e2e8f0;
  --border-subtle: #cbd5e1;
  --border-glow: rgba(37, 99, 235, 0.2);

  --accent-primary: #2563eb;
  --accent-primary-hover: #1d4ed8;
  --accent-primary-glow: rgba(37, 99, 235, 0.25);

  --accent-gold: #2563eb; /* Migrated from yellow to royal blue */
  --accent-gold-light: #3b82f6;
  --accent-gold-glow: rgba(37, 99, 235, 0.2);

  --accent-cyan: #0284c7;
  --accent-emerald: #059669;
  --accent-rose: #e11d48;

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-dim: #94a3b8;

  --font-arabic: 'Cairo', sans-serif;
  --font-english: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', 'Consolas', monospace;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.07), 0 4px 6px -4px rgba(0, 0, 0, 0.03);
}

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

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-arabic);
  direction: rtl;
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
  background-image: 
    radial-gradient(circle at 10% 10%, rgba(37, 99, 235, 0.04) 0%, transparent 40%),
    radial-gradient(circle at 90% 90%, rgba(5, 150, 105, 0.03) 0%, transparent 40%);
}

html[dir="ltr"] body {
  font-family: var(--font-english);
  direction: ltr;
}

html[dir="ltr"] .custom-table {
  text-align: left;
}

/* Language Switcher */
.lang-switcher {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #f1f5f9;
  border: 1px solid var(--border-color);
  padding: 3px 5px;
  border-radius: var(--radius-full);
}

.lang-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.78rem;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition);
}

.lang-btn.active, .lang-btn:hover {
  background: #ffffff;
  color: var(--accent-primary);
  box-shadow: var(--shadow-sm);
}

/* Modern Card / Panel */
.glass-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  transition: var(--transition);
}

.glass-panel:hover {
  border-color: #cbd5e1;
  box-shadow: var(--shadow-lg);
}

/* Header & Nav */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 36px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-main);
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: -0.3px;
}

.brand-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-primary-hover));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 900;
  font-size: 1.1rem;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.nav-brand-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Hamburger Toggle Button */
.menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: space-around;
  width: 36px;
  height: 32px;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 6px;
  z-index: 102;
  transition: var(--transition);
}

.menu-toggle:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.menu-toggle span {
  width: 100%;
  height: 2.5px;
  background: var(--text-main);
  border-radius: 4px;
  transition: all 0.25s ease-in-out;
}

.menu-toggle.active span:nth-child(1) {
  transform: translateY(6.5px) rotate(45deg);
}
.menu-toggle.active span:nth-child(2) {
  opacity: 0;
  transform: scale(0);
}
.menu-toggle.active span:nth-child(3) {
  transform: translateY(-6.5px) rotate(-45deg);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 20px;
  list-style: none;
}

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.nav-link:hover, .nav-link.active {
  color: var(--accent-primary);
  background: #eff6ff;
}

.mobile-only-action {
  display: none;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 20px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
  transform: translateY(-1px);
}

.btn-secondary {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
  background: #e2e8f0;
  color: var(--text-main);
  transform: translateY(-1px);
}

.btn-danger {
  background: #fff1f2;
  color: var(--accent-rose);
  border: 1px solid #fecdd3;
}

.btn-danger:hover {
  background: var(--accent-rose);
  color: #fff;
}

.btn-success {
  background: #ecfdf5;
  color: var(--accent-emerald);
  border: 1px solid #a7f3d0;
}

.btn-success:hover {
  background: var(--accent-emerald);
  color: #fff;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 700;
}

.badge-live {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.badge-live::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--accent-emerald);
  box-shadow: 0 0 6px var(--accent-emerald);
  animation: pulseDot 1.8s infinite;
}

.badge-gold {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.badge-rose {
  background: #fff1f2;
  color: var(--accent-rose);
  border: 1px solid #fecdd3;
}

@keyframes pulseDot {
  0% { transform: scale(0.9); opacity: 0.7; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.7; }
}

/* Layout Containers */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 36px 20px;
}

/* Grid */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 14px;
  border-radius: var(--radius-sm);
}

.table-responsive .custom-table {
  margin-top: 0;
  min-width: 620px;
}

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

@media (max-width: 868px) {
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }
  
  .navbar {
    padding: 12px 18px;
    position: sticky;
    top: 0;
    z-index: 150;
  }
  
  .brand-logo {
    font-size: 1.18rem;
  }
  
  .brand-icon {
    width: 30px;
    height: 30px;
    font-size: 0.95rem;
  }
  
  .menu-toggle {
    display: flex;
  }
  
  .desktop-only-btn {
    display: none !important;
  }
  
  .mobile-only-action {
    display: block !important;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-subtle);
  }
  
  .nav-links {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 16px 32px rgba(15, 23, 42, 0.14);
    flex-direction: column;
    align-items: stretch;
    padding: 16px 20px;
    gap: 8px;
    display: none;
    z-index: 1000;
  }
  
  .nav-links.open {
    display: flex;
    animation: menuSlideDown 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  }
  
  .nav-link {
    padding: 10px 14px;
    font-size: 0.95rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
  }
  
  .container {
    padding: 16px 14px;
  }
  
  .hero {
    padding: 30px 10px 20px;
  }
  
  .hero h1 {
    font-size: 1.85rem !important;
    line-height: 1.3 !important;
  }
  
  .hero p {
    font-size: 1rem !important;
  }
  
  .sim-stage {
    flex-direction: column;
    gap: 12px;
  }
  
  .sim-node {
    width: 100%;
    min-width: unset;
  }
  
  .sim-arrow {
    transform: rotate(90deg);
  }
}

/* Tables */
.custom-table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
  margin-top: 14px;
}

.custom-table th {
  padding: 12px 14px;
  font-weight: 700;
  color: #475569;
  background: #f8fafc;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.82rem;
}

.custom-table td {
  padding: 14px 14px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.88rem;
  color: var(--text-main);
}

.custom-table tr:hover td {
  background: #f8fafc;
}

/* Forms */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 6px;
  color: var(--text-main);
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.95rem;
  transition: var(--transition);
}

.form-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal.active {
  display: flex;
}

/* Broadcast Announcement Banners */
.broadcast-banner {
  border: 1px solid var(--border-color);
  background: #ffffff;
  transition: var(--transition);
}
.broadcast-banner.type-info {
  background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 100%);
  border-color: #bfdbfe;
  color: #1e40af;
}
.broadcast-banner.type-warning {
  background: linear-gradient(135deg, #fefce8 0%, #fffbeb 100%);
  border-color: #fef08a;
  color: #854d0e;
}
.broadcast-banner.type-alert {
  background: linear-gradient(135deg, #fff1f2 0%, #ffe4e6 100%);
  border-color: #fecdd3;
  color: #9f1239;
}
.broadcast-banner.type-success {
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
  border-color: #bbf7d0;
  color: #166534;
}

/* Chat Messages for Support Tickets */
.chat-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 420px;
  overflow-y: auto;
  padding: 16px;
  background: #f8fafc;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}
.chat-bubble {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.6;
  position: relative;
  word-break: break-word;
}
.chat-bubble.admin {
  align-self: flex-start;
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  border-bottom-right-radius: 2px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.chat-bubble.engineer {
  align-self: flex-end;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #ffffff;
  border-bottom-left-radius: 2px;
  box-shadow: 0 2px 6px rgba(37,99,235,0.2);
}
.chat-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  opacity: 0.85;
}
.chat-time {
  font-size: 0.7rem;
  opacity: 0.7;
  margin-top: 4px;
  text-align: left;
  direction: ltr;
}
