/* ---------- Shared CSS based on index.php design ---------- */
/* Color tokens */
:root {
  --bg: #eef2f8;
  --panel: #ffffff;
  --muted: #7a7f88;
  --primary: #7f4eff;
  --primary-2: #a87fff;
  --accent-blue: #00b9ff;
  --accent-green: #1dd75b;
  --accent-yellow: #ffb347;
  --glass: rgba(255,255,255,0.6);
  --card-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 8px;
  --fw-600: 600;
  --mono: 'Segoe UI', Roboto, system-ui, -apple-system, "Helvetica Neue", Arial;
  --text-primary: #222;
  --text-secondary: #666;
  --border-color: #e6e9ef;
  --chat-bg: #fafbff;
  --footer-bg: #0f1724;
  --footer-text: #fff;
}

/* Dark mode */
[data-theme="dark"] {
  --bg: #0f1117;
  --panel: #1a1d29;
  --muted: #9ca3af;
  --primary: #9f7aff;
  --primary-2: #b99fff;
  --accent-blue: #4dc9ff;
  --accent-green: #4ee77d;
  --accent-yellow: #ffc670;
  --glass: rgba(255,255,255,0.1);
  --card-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  --text-primary: #e4e4e7;
  --text-secondary: #f4f4f5;
  --border-color: #2d3139;
  --chat-bg: #1a1d29;
  --footer-bg: #0a0c10;
  --footer-text: #e4e4e7;
}

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

html, body {
  height: 100%;
}

body {
  font-family: var(--mono);
  background: linear-gradient(180deg, #f3f6fb 0%, #eef2f8 100%);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Dark mode body gradient */
[data-theme="dark"] body {
  background: linear-gradient(180deg, #0f1117 0%, #1a1d29 100%);
}

/* RTL support for Arabic */
[dir="rtl"] {
  direction: rtl;
  text-align: right;
}

[dir="rtl"] .nav-link i,
[dir="rtl"] .stat-icon,
[dir="rtl"] .feature-icon {
  margin-right: 0;
  margin-left: var(--spacing-sm, 10px);
}

/* Header */
header {
  position: sticky;
  top: 0;
  z-index: 60;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  padding: 18px 28px;
  box-shadow: 0 2px 10px rgba(26, 18, 64, 0.06);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 22px;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  text-decoration: none;
}

.brand .logo {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: linear-gradient(135deg, #ffffff22, #ffffff14);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 -3px 8px rgba(255,255,255,0.06);
  font-weight: 700;
  color: #fff;
}

.brand h1 {
  font-size: 1.05rem;
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.2px;
}

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

.nav a {
  color: rgba(255,255,255,0.95);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s;
}

.nav a:hover {
  color: #fff;
}

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

/* Theme toggle button */
.theme-toggle {
  background: var(--glass);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 18px;
}

.theme-toggle:hover {
  background: rgba(255,255,255,0.2);
  transform: rotate(180deg);
}

/* Language selector */
.lang-selector {
  position: relative;
}

.lang-btn {
  background: var(--glass);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.3s ease;
}

.lang-btn:hover {
  background: rgba(255,255,255,0.2);
}

.lang-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--panel);
  border-radius: var(--radius-md);
  box-shadow: var(--card-shadow);
  min-width: 120px;
  display: none;
  z-index: 100;
  margin-top: 8px;
}

.lang-dropdown.show {
  display: block;
}

.lang-dropdown a {
  display: block;
  padding: 10px 16px;
  color: var(--text-primary);
  text-decoration: none;
  transition: background 0.2s;
}

.lang-dropdown a:hover {
  background: var(--bg);
}

[dir="rtl"] .lang-dropdown {
  right: auto;
  left: 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 0;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: all .18s ease;
}

.btn.primary {
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  color: #fff;
  box-shadow: 0 6px 18px rgba(127,78,255,0.18);
  border: 1px solid rgba(255,255,255,0.06);
}

.btn.ghost {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.08);
}

.btn.primary:hover {
  transform: translateY(-2px);
}

.btn.ghost:hover {
  background: rgba(255,255,255,0.2);
}

.mobile-menu-btn {
  display: none;
  background: transparent;
  border: 0;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}

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

/* Cards */
.card {
  background: var(--panel);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--card-shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
}

[data-theme="dark"] .card {
  background: var(--panel);
  color: var(--text-primary);
}

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

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-family: var(--mono);
  background: var(--panel);
  color: var(--text-primary);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(127,78,255,0.1);
}

[data-theme="dark"] .form-group input,
[data-theme="dark"] .form-group select,
[data-theme="dark"] .form-group textarea {
  background: var(--panel);
  color: var(--text-primary);
  border-color: var(--border-color);
}

/* Tables */
.table-responsive {
  overflow-x: auto;
  background: var(--panel);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

[dir="rtl"] th,
[dir="rtl"] td {
  text-align: right;
}

th {
  background: var(--bg);
  font-weight: 600;
  color: var(--text-primary);
}

[data-theme="dark"] th {
  background: var(--panel);
  color: var(--text-primary);
}

tr:hover {
  background: rgba(127,78,255,0.05);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}

.badge-success {
  background: #e8f8f0;
  color: #0f5132;
}

.badge-warning {
  background: #fff3cd;
  color: #664d03;
}

.badge-danger {
  background: #f8d7da;
  color: #842029;
}

.badge-primary {
  background: #e9f7fe;
  color: #0c63e4;
}

[data-theme="dark"] .badge-success {
  background: rgba(29,215,91,0.2);
  color: #4ee77d;
}

[data-theme="dark"] .badge-warning {
  background: rgba(255,179,71,0.2);
  color: #ffc670;
}

[data-theme="dark"] .badge-danger {
  background: rgba(255,71,87,0.2);
  color: #ff6b6b;
}

[data-theme="dark"] .badge-primary {
  background: rgba(127,78,255,0.2);
  color: #9f7aff;
}

/* Footer */
footer {
  background: var(--footer-bg);
  color: var(--footer-text);
  padding: 28px;
  border-radius: var(--radius-lg);
  margin-top: 28px;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 18px;
}

.footer-grid h4 {
  margin-bottom: 12px;
  color: var(--primary);
}

.footer-grid ul {
  list-style: none;
}

.footer-grid ul li {
  margin-bottom: 8px;
}

.footer-grid a {
  color: rgba(255,255,255,0.9);
  text-decoration: none;
  transition: color 0.2s;
}

.footer-grid a:hover {
  color: var(--primary);
}

/* Chat widget */
.message-icon {
  position: fixed;
  right: 28px;
  bottom: 28px;
  width: 56px;
  height: 56px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  box-shadow: 0 12px 30px rgba(127,78,255,0.18);
  cursor: pointer;
  z-index: 90;
  transition: transform 0.3s ease;
}

[dir="rtl"] .message-icon {
  right: auto;
  left: 28px;
}

.message-icon:hover {
  transform: scale(1.1);
}

.chat-container {
  position: fixed;
  right: 28px;
  bottom: 96px;
  width: 360px;
  max-width: calc(100% - 40px);
  display: none;
  flex-direction: column;
  background: var(--panel);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(2,6,23,0.18);
  z-index: 95;
  overflow: hidden;
}

[dir="rtl"] .chat-container {
  right: auto;
  left: 28px;
}

.chat-header {
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  color: #fff;
  padding: 12px 16px;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-messages {
  padding: 12px;
  max-height: 280px;
  overflow: auto;
  background: var(--chat-bg);
}

.message {
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 8px;
  max-width: 86%;
}

.welcome-message {
  background: #f3f5ff;
  color: #111;
}

.user-message {
  background: var(--primary);
  color: #fff;
  margin-left: auto;
}

[dir="rtl"] .user-message {
  margin-left: 0;
  margin-right: auto;
}

.error-message {
  background: #fdecea;
  color: #721c24;
  border-left: 4px solid #f5c6cb;
}

[dir="rtl"] .error-message {
  border-left: none;
  border-right: 4px solid #f5c6cb;
}

[data-theme="dark"] .welcome-message {
  background: #2d3139;
  color: var(--text-primary);
}

[data-theme="dark"] .chat-container {
  background: var(--panel);
  color: var(--text-primary);
}

[data-theme="dark"] .chat-messages {
  background: var(--chat-bg);
}

/* Responsive */
@media (max-width: 900px) {
  .header-inner {
    padding: 0 8px;
  }

  .nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: linear-gradient(90deg, var(--primary), var(--primary-2));
    flex-direction: column;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  }

  .nav.show {
    display: flex;
  }

  .nav a {
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
  }

  .nav a:last-child {
    border-bottom: none;
  }

  .mobile-menu-btn {
    display: block;
  }

  .theme-toggle {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }

  .chat-container {
    width: 90%;
    right: 5%;
  }

  [dir="rtl"] .chat-container {
    right: auto;
    left: 5%;
  }
}

@media (min-width: 901px) {
  .nav {
    display: flex !important;
  }
}
