/* ==========================================
   ترقية برج القاهرة الرقمي للوسائط
   Arabic RTL Stylesheet
   ========================================== */

:root {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-card: #1c2128;
  --text-primary: #f0f6fc;
  --text-secondary: #8b949e;
  --accent: #00d4ff;
  --accent-hover: #00b8e6;
  --success: #3fb950;
  --warning: #d29922;
  --danger: #f85149;
  --shadow: rgba(0, 0, 0, 0.3);
  --shadow-lg: rgba(0, 0, 0, 0.5);
}

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

body {
  font-family: 'Cairo', 'Tajawal', 'IBM Plex Sans Arabic', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.8;
  overflow-x: hidden;
  direction: rtl;
  text-align: right;
}

/* ==========================================
   HEADER & NAVIGATION
   ========================================== */

header {
  background: var(--bg-secondary);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 1000;
  transition: box-shadow 0.3s ease;
}

header.scrolled {
  box-shadow: 0 4px 12px var(--shadow-lg);
}

nav {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-direction: row-reverse;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 2rem;
  flex-direction: row-reverse;
}

.nav-links a {
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.3s ease;
  position: relative;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--accent);
}

.nav-links a::after {
  content: '';
  position: absolute;
  bottom: -5px;
  right: 0;
  width: 0;
  height: 2px;
  background: var(--accent);
  transition: width 0.3s ease;
}

.nav-links a:hover::after,
.nav-links a.active::after {
  width: 100%;
}

.burger {
  display: none;
  flex-direction: column;
  cursor: pointer;
  gap: 5px;
}

.burger span {
  width: 25px;
  height: 3px;
  background: var(--text-primary);
  transition: all 0.3s ease;
}

/* ==========================================
   HERO SECTION
   ========================================== */

.hero {
  position: relative;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
}

.hero-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.4);
  z-index: -1;
}

.hero-content {
  max-width: 900px;
  padding: 2rem;
  z-index: 1;
}

.hero h1 {
  font-size: 3.5rem;
  margin-bottom: 1.5rem;
  color: var(--accent);
  text-shadow: 2px 2px 8px var(--shadow-lg);
  line-height: 1.4;
}

.hero p {
  font-size: 1.4rem;
  margin-bottom: 2rem;
  color: var(--text-primary);
  line-height: 1.8;
}

.btn {
  display: inline-block;
  padding: 1rem 2.5rem;
  background: var(--accent);
  color: var(--bg-primary);
  text-decoration: none;
  border-radius: 8px;
  font-weight: 600;
  transition: all 0.3s ease;
  border: none;
  cursor: pointer;
  font-size: 1rem;
}

.btn:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 16px var(--shadow);
}

/* ==========================================
   CONTAINER & SECTIONS
   ========================================== */

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 4rem 2rem;
}

section {
  margin-bottom: 4rem;
}

.section-title {
  font-size: 2.8rem;
  margin-bottom: 1rem;
  color: var(--accent);
  text-align: center;
  font-weight: 700;
}

.section-subtitle {
  font-size: 1.3rem;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 3rem;
  line-height: 1.8;
}

/* ==========================================
   CARDS & GRID
   ========================================== */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 2rem;
  margin-top: 2rem;
}

.card {
  background: var(--bg-card);
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 4px 12px var(--shadow);
  transition: all 0.3s ease;
  border: 1px solid transparent;
}

.card:hover {
  transform: translateY(-8px);
  box-shadow: 0 12px 24px var(--shadow-lg);
  border-color: var(--accent);
}

.card-icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  color: var(--accent);
}

.card h3 {
  font-size: 1.6rem;
  margin-bottom: 1rem;
  color: var(--accent);
  font-weight: 700;
}

.card p {
  color: var(--text-secondary);
  line-height: 1.9;
}

.card-highlight {
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.1), rgba(0, 212, 255, 0.05));
  border: 2px solid var(--accent);
}

/* ==========================================
   TABLES
   ========================================== */

.table-container {
  overflow-x: auto;
  margin: 2rem 0;
  direction: rtl;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border-radius: 8px;
  overflow: hidden;
  direction: rtl;
}

thead {
  background: var(--accent);
  color: var(--bg-primary);
}

th, td {
  padding: 1rem;
  text-align: right;
  border-bottom: 1px solid var(--bg-secondary);
}

th {
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.9rem;
}

tbody tr {
  transition: background 0.2s ease;
}

tbody tr:hover {
  background: rgba(0, 212, 255, 0.05);
}

td input {
  background: var(--bg-primary);
  border: 1px solid var(--text-secondary);
  color: var(--text-primary);
  padding: 0.5rem;
  border-radius: 4px;
  width: 120px;
  font-size: 1rem;
  text-align: right;
}

td input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ==========================================
   FORMS & INPUTS
   ========================================== */

.input-group {
  margin-bottom: 2rem;
}

.input-group label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
  font-weight: 500;
  font-size: 1.1rem;
}

.input-group input[type="number"],
.input-group input[type="range"] {
  width: 100%;
  padding: 1rem;
  background: var(--bg-card);
  border: 2px solid var(--text-secondary);
  color: var(--text-primary);
  border-radius: 8px;
  font-size: 1.1rem;
  transition: border 0.3s ease;
  text-align: right;
}

.input-group input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
}

.input-group input[type="range"] {
  padding: 0;
  height: 8px;
  cursor: pointer;
}

.input-value {
  display: inline-block;
  margin-right: 1rem;
  color: var(--accent);
  font-weight: 700;
  font-size: 1.2rem;
}

/* ==========================================
   RESULTS DISPLAY
   ========================================== */

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin: 3rem 0;
}

.result-card {
  background: var(--bg-card);
  padding: 1.5rem;
  border-radius: 12px;
  text-align: center;
  border-right: 4px solid var(--accent);
  box-shadow: 0 4px 12px var(--shadow);
}

.result-card.success {
  border-right-color: var(--success);
}

.result-card.warning {
  border-right-color: var(--warning);
}

.result-card.danger {
  border-right-color: var(--danger);
}

.result-label {
  font-size: 0.95rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.result-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
}

.result-card.success .result-value {
  color: var(--success);
}

.result-card.warning .result-value {
  color: var(--warning);
}

.result-card.danger .result-value {
  color: var(--danger);
}

/* ==========================================
   FLOWCHART
   ========================================== */

.flowchart {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 600px;
  margin: 2rem auto;
}

.flow-step {
  background: var(--bg-card);
  padding: 1.5rem;
  border-radius: 8px;
  border-right: 4px solid var(--accent);
  position: relative;
}

.flow-step::after {
  content: '↓';
  position: absolute;
  bottom: -2rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 2rem;
  color: var(--accent);
}

.flow-step:last-child::after {
  content: '';
}

.flow-step h4 {
  color: var(--accent);
  margin-bottom: 0.5rem;
  font-weight: 700;
}

/* ==========================================
   CHART CONTAINER
   ========================================== */

.chart-container {
  background: var(--bg-card);
  padding: 2rem;
  border-radius: 12px;
  margin: 3rem 0;
  box-shadow: 0 4px 12px var(--shadow);
}

.chart-container canvas {
  max-height: 400px;
}

/* ==========================================
   FEATURE LIST
   ========================================== */

.feature-list {
  list-style: none;
  margin: 2rem 0;
}

.feature-list li {
  padding: 1rem;
  margin-bottom: 1rem;
  background: var(--bg-card);
  border-radius: 8px;
  border-right: 4px solid var(--accent);
  display: flex;
  align-items: start;
  gap: 1rem;
  flex-direction: row-reverse;
}

.feature-list li::before {
  content: '✓';
  color: var(--success);
  font-weight: 700;
  font-size: 1.5rem;
}

/* ==========================================
   FOOTER
   ========================================== */

footer {
  background: var(--bg-secondary);
  padding: 2rem 0;
  text-align: center;
  margin-top: 4rem;
  border-top: 1px solid var(--accent);
}

footer p {
  color: var(--text-secondary);
}

/* ==========================================
   RESPONSIVE DESIGN
   ========================================== */

@media (max-width: 768px) {
  .hero h1 {
    font-size: 2.2rem;
  }

  .hero p {
    font-size: 1.1rem;
  }

  .nav-links {
    position: fixed;
    left: -100%;
    top: 70px;
    flex-direction: column;
    background: var(--bg-secondary);
    width: 100%;
    text-align: center;
    transition: left 0.3s ease;
    padding: 2rem 0;
    gap: 1rem;
    box-shadow: 0 4px 12px var(--shadow-lg);
  }

  .nav-links.active {
    left: 0;
  }

  .burger {
    display: flex;
  }

  .burger.active span:nth-child(1) {
    transform: rotate(45deg) translate(8px, 8px);
  }

  .burger.active span:nth-child(2) {
    opacity: 0;
  }

  .burger.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .section-title {
    font-size: 2.2rem;
  }

  .container {
    padding: 2rem 1rem;
  }

  table {
    font-size: 0.9rem;
  }

  th, td {
    padding: 0.5rem;
  }
}

/* ==========================================
   PRINT STYLES
   ========================================== */

@media print {
  header, footer, .burger {
    display: none;
  }

  body {
    background: white;
    color: black;
  }

  .card, .result-card {
    border: 1px solid #333;
    box-shadow: none;
    page-break-inside: avoid;
  }

  .hero-bg {
    display: none;
  }

  .section-title, .card h3, .result-value {
    color: #000;
  }
}

/* ==========================================
   UTILITY CLASSES
   ========================================== */

.text-center {
  text-align: center;
}

.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 2rem; }
.mt-3 { margin-top: 3rem; }
.mb-1 { margin-bottom: 1rem; }
.mb-2 { margin-bottom: 2rem; }
.mb-3 { margin-bottom: 3rem; }

.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }

/* ==========================================
   ARABIC NUMBERS
   ========================================== */

.arabic-numbers {
  font-feature-settings: 'lnum' 1;
}

/* Numbers remain left-to-right */
.ltr-numbers {
  direction: ltr;
  display: inline-block;
  unicode-bidi: embed;
}

/* ==========================================
   CHAT WIDGET (ElevenLabs Style - Arabic)
   ========================================== */

.chat-widget {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 9999;
  font-family: 'Cairo', system-ui, -apple-system, sans-serif;
}

.chat-toggle-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--accent, #00d4ff);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 212, 255, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.chat-toggle-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 30px rgba(0, 212, 255, 0.5);
}

.chat-toggle-btn svg {
  width: 28px;
  height: 28px;
  color: var(--bg-primary, #0d1117);
}

.chat-window {
  position: absolute;
  bottom: 80px;
  left: 0;
  width: 380px;
  height: 550px;
  max-height: calc(100vh - 120px);
  background: var(--bg-card, #161b22);
  border-radius: 16px;
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(0, 212, 255, 0.2);
}

.chat-header {
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--accent, #00d4ff), #0099cc);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.chat-avatar {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-avatar svg {
  width: 24px;
  height: 24px;
  color: white;
}

.chat-title {
  font-size: 16px;
  font-weight: 600;
  color: white;
}

.chat-status {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 8px;
  height: 8px;
  background: #4ade80;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.chat-voice-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.chat-voice-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.chat-voice-btn.active {
  background: #4ade80;
}

.chat-voice-btn svg {
  width: 20px;
  height: 20px;
  color: white;
}

.chat-minimize-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}

.chat-minimize-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.chat-minimize-btn svg {
  width: 18px;
  height: 18px;
  color: white;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-welcome {
  text-align: center;
  padding: 24px 16px;
  background: rgba(0, 212, 255, 0.05);
  border-radius: 12px;
  margin-bottom: 8px;
}

.welcome-icon {
  font-size: 40px;
  margin-bottom: 12px;
}

.chat-welcome h3 {
  font-size: 18px;
  color: var(--accent, #00d4ff);
  margin: 0 0 8px 0;
}

.chat-welcome p {
  font-size: 14px;
  color: var(--text-secondary, #8b949e);
  margin: 0 0 12px 0;
  line-height: 1.5;
}

.voice-toggle-info {
  margin-top: 12px;
}

.btn-small {
  padding: 8px 16px;
  font-size: 13px;
}

.chat-message {
  display: flex;
  gap: 10px;
  animation: fadeIn 0.3s ease;
}

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

.chat-message.user {
  flex-direction: row-reverse;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.message-avatar.assistant {
  background: var(--accent, #00d4ff);
}

.message-avatar.assistant svg {
  width: 18px;
  height: 18px;
  color: var(--bg-primary, #0d1117);
}

.message-play-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent, #00d4ff);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
  margin-left: 8px;
}

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

.message-play-btn svg {
  width: 14px;
  height: 14px;
  color: var(--bg-primary, #0d1117);
}

.message-content {
  max-width: 280px;
  padding: 12px 16px;
  border-radius: 16px;
  background: var(--bg-secondary, #21262d);
  display: flex;
  align-items: flex-start;
}

.chat-message.user .message-content {
  background: var(--accent, #00d4ff);
}

.message-text {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary, #e6edf3);
}

.chat-message.user .message-text {
  color: var(--bg-primary, #0d1117);
}

.message-text strong {
  color: inherit;
}

.message-text em {
  font-style: italic;
}

.message-text br {
  margin-bottom: 4px;
}

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

.chat-message.user .message-time {
  color: rgba(0, 0, 0, 0.5);
}

.chat-input-container {
  padding: 16px;
  background: var(--bg-secondary, #21262d);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

#chat-input {
  flex: 1;
  background: var(--bg-card, #161b22);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  padding: 12px 16px;
  color: var(--text-primary, #e6edf3);
  font-size: 14px;
  resize: none;
  max-height: 120px;
  outline: none;
  transition: border-color 0.2s;
  text-align: right;
}

#chat-input:focus {
  border-color: var(--accent, #00d4ff);
}

#chat-input::placeholder {
  color: var(--text-secondary, #8b949e);
}

.chat-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent, #00d4ff);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.chat-send-btn:hover:not(:disabled) {
  transform: scale(1.05);
}

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

.chat-send-btn svg {
  width: 20px;
  height: 20px;
  color: var(--bg-primary, #0d1117);
}

.chat-loading {
  padding: 12px 16px;
  background: var(--bg-secondary, #21262d);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 8px 0;
  justify-content: center;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--accent, #00d4ff);
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.6; }
  30% { transform: translateY(-8px); opacity: 1; }
}

.chat-mic-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-secondary, #21262d);
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.chat-mic-btn:hover {
  background: var(--accent, #00d4ff);
  border-color: var(--accent, #00d4ff);
}

.chat-mic-btn:hover svg {
  color: var(--bg-primary, #0d1117);
}

.chat-mic-btn.recording {
  background: #f85149;
  border-color: #f85149;
  animation: pulse-mic 1s infinite;
}

.chat-mic-btn.recording svg {
  color: white;
}

.chat-mic-btn svg {
  width: 20px;
  height: 20px;
  color: var(--text-secondary, #8b949e);
}

@keyframes pulse-mic {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* Speech Banner */
.speech-banner {
  display: none;
  align-items: flex-start;
  gap: 10px;
  margin: 10px 15px;
  padding: 12px;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  font-size: 13px;
}

.speech-banner-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.speech-banner-content {
  flex: 1;
}

.speech-banner-content strong {
  display: block;
  color: #92400e;
  margin-bottom: 4px;
}

.speech-banner-content p {
  margin: 0;
  color: #a16207;
  line-height: 1.4;
}

.speech-banner-close {
  background: none;
  border: none;
  font-size: 18px;
  color: #a16207;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

/* Responsive */
@media (max-width: 480px) {
  .chat-window {
    width: calc(100vw - 40px);
    height: calc(100vh - 140px);
    bottom: 70px;
    left: -10px;
  }

  .chat-toggle-btn {
    width: 52px;
    height: 52px;
  }

  .chat-toggle-btn svg {
    width: 24px;
    height: 24px;
  }
}
