/* Livro - Ultra Professional, Minimal & Animated Design System */
@import url('https://fonts.googleapis.com/css2?family=Noto+Kufi+Arabic:wght@300;400;500;600;700;800;900&family=Inter:wght@300;400;500;600;700;800;900&display=swap');

:root {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-overlay: rgba(15, 23, 42, 0.65);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border-color: #e2e8f0;
  
  /* Livro Signature Green Accent */
  --accent: #10b981;
  --accent-vibrant: #00e676;
  --accent-hover: #059669;
  --accent-light: #ecfdf5;
  --accent-glow: rgba(16, 185, 129, 0.25);
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 6px 16px -2px rgba(0, 0, 0, 0.06), 0 2px 6px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 16px 36px -4px rgba(0, 0, 0, 0.1), 0 6px 14px -2px rgba(0, 0, 0, 0.04);
  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
  --sidebar-width: 260px;
  --topbar-height: 60px;

  /* Smooth Rounded Design System Tokens */
  --radius-sm: 12px;
  --radius-md: 22px;
  --radius-lg: 32px;
  --radius-xl: 42px;
}

[data-theme="dark"] {
  --bg-primary: #090d16;
  --bg-secondary: #111827;
  --bg-sidebar: #111827;
  --bg-card: rgba(17, 24, 39, 0.85);
  --bg-overlay: rgba(0, 0, 0, 0.85);
  --text-primary: #f9fafb;
  --text-secondary: #9ca3af;
  --text-muted: #4b5563;
  --border-color: #1f2937;
  --accent-light: rgba(16, 185, 129, 0.12);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 16px -2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 36px -4px rgba(0, 0, 0, 0.6);
}

/* Complete Arabic Font & Global Rule Override */
[dir="rtl"],
[dir="rtl"] body,
[dir="rtl"] input,
[dir="rtl"] button,
[dir="rtl"] select,
[dir="rtl"] textarea,
[dir="rtl"] .btn,
[dir="rtl"] .badge,
[dir="rtl"] .leaflet-container,
[dir="rtl"] .leaflet-popup-content {
  font-family: 'Noto Kufi Arabic', system-ui, -apple-system, sans-serif !important;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
}

/* Keyframe Animations */
@keyframes floatAnim {
  0% { transform: translateY(0px); }
  50% { transform: translateY(-8px); }
  100% { transform: translateY(0px); }
}

@keyframes pulseGlow {
  0% { box-shadow: 0 0 0 0 var(--accent-glow); }
  70% { box-shadow: 0 0 0 14px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.float-animated {
  animation: floatAnim 4s ease-in-out infinite;
}

.pulse-glow {
  animation: pulseGlow 2.5s infinite;
}

/* App Shell Layout */
.app-layout {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

/* Desktop Sidebar */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
  overflow-y: auto;
}

[dir="rtl"] .sidebar {
  left: auto;
  right: 0;
  border-right: none;
  border-left: 1px solid var(--border-color);
  text-align: right;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 900;
  font-size: 1.35rem;
  padding-bottom: 1.25rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.brand-icon-box {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--accent), var(--accent-vibrant));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 1.4rem;
  box-shadow: 0 4px 14px var(--accent-glow);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  list-style: none;
  flex: 1;
}

.sidebar-nav-item a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.94rem;
  cursor: pointer;
}

.sidebar-nav-item a:hover {
  color: var(--text-primary);
  background: var(--bg-primary);
  transform: translateX(3px);
}

[dir="rtl"] .sidebar-nav-item a:hover {
  transform: translateX(-3px);
}

.sidebar-nav-item a.active {
  color: var(--accent);
  background: var(--accent-light);
  font-weight: 700;
}

.sidebar-nav-item a i {
  font-size: 1.3rem;
}

.sidebar-footer {
  padding-top: 1rem;
  margin-top: auto;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Main Content Area */
.main-content-wrapper {
  margin-left: var(--sidebar-width);
  width: calc(100% - var(--sidebar-width));
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

[dir="rtl"] .main-content-wrapper {
  margin-left: 0;
  margin-right: var(--sidebar-width);
}

/* Top Mobile Bar */
.mobile-topbar {
  display: none;
  height: var(--topbar-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 0 1.25rem;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 900;
}

/* Mobile Bottom Navigation */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  z-index: 1000;
  justify-content: space-around;
  align-items: center;
  padding: 4px 0;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.06);
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 500;
  flex: 1;
  cursor: pointer;
}

.mobile-nav-item.active {
  color: var(--accent);
  font-weight: 700;
}

.mobile-nav-item i {
  font-size: 1.4rem;
}

@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content-wrapper {
    margin-left: 0 !important;
    margin-right: 0 !important;
    width: 100% !important;
    padding-bottom: 74px;
  }
  .mobile-topbar { display: flex; }
  .mobile-bottom-nav { display: flex; }
}

/* Container */
.content-container {
  padding: 1.75rem 2.25rem;
  flex: 1;
  max-width: 1350px;
  width: 100%;
  margin: 0 auto;
}

@media (max-width: 768px) {
  .content-container { padding: 1rem; }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: 28px;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  border: none;
  outline: none;
  font-family: inherit;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn:active {
  transform: scale(0.97);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent), var(--accent-vibrant));
  color: #ffffff;
  box-shadow: 0 4px 14px var(--accent-glow);
}

.btn-accent:hover {
  box-shadow: 0 6px 20px var(--accent-glow);
  transform: translateY(-2px);
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-2px);
}

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-outline:hover {
  background: var(--accent-light);
  color: var(--accent);
  border-color: var(--accent);
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: rotate(15deg);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 14px;
  font-size: 0.8rem;
  font-weight: 600;
}

.badge-accent {
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.12);
  color: #d97706;
}

.badge-info {
  background: rgba(59, 130, 246, 0.12);
  color: #2563eb;
}

/* HERO COMPONENT */
.hero-glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 4rem 2.5rem;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  margin-bottom: 2.5rem;
}

.hero-glass-card::before {
  content: '';
  position: absolute;
  top: -120px;
  right: -120px;
  width: 340px;
  height: 340px;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

[dir="rtl"] .hero-glass-card::before {
  right: auto;
  left: -120px;
}

.hero-grid-hero {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 2.5rem;
  align-items: center;
}

[dir="rtl"] .hero-grid-hero {
  text-align: right;
}

@media (max-width: 992px) {
  .hero-grid-hero {
    grid-template-columns: 1fr;
    text-align: center;
  }
}

.hero-title {
  font-size: 2.8rem;
  font-weight: 900;
  letter-spacing: -0.03em;
  margin-bottom: 1.2rem;
  line-height: 1.3;
}

.hero-title span {
  color: var(--accent);
  position: relative;
  display: inline-block;
}

.hero-subtitle {
  font-size: 1.15rem;
  color: var(--text-secondary);
  margin-bottom: 2.2rem;
  line-height: 1.65;
}

/* Stats Row */
.stats-banner-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.25rem;
  margin-top: 2.5rem;
}

.stat-card-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.stat-card-box:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
}

.stat-number {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Steps */
.steps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.step-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 2rem 1.5rem;
  position: relative;
  box-shadow: var(--shadow-sm);
}

[dir="rtl"] .step-card {
  text-align: right;
}

.step-card:hover {
  transform: translateY(-6px);
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}

.step-number-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 1.25rem;
}

/* Explorer Grid */
.explorer-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.25rem;
  height: calc(100vh - 120px);
  min-height: 550px;
}

@media (max-width: 900px) {
  .explorer-grid {
    grid-template-columns: 1fr;
    height: auto;
  }
}

.sidebar-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
}

[dir="rtl"] .sidebar-panel {
  text-align: right;
}

.map-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

#map {
  width: 100%;
  height: 100%;
  min-height: 400px;
  z-index: 1;
}

/* Forms */
.form-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-sm);
  max-width: 800px;
  margin: 0 auto;
}

[dir="rtl"] .form-card {
  text-align: right;
}

.form-group {
  margin-bottom: 1.1rem;
}

.form-label {
  display: block;
  font-weight: 600;
  font-size: 0.88rem;
  margin-bottom: 5px;
}

.form-control {
  width: 100%;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
}

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

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.checkbox-group input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

/* Borne Cards */
.borne-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  gap: 12px;
  align-items: center;
  cursor: pointer;
}

.borne-card:hover {
  border-color: var(--accent);
  transform: translateX(2px);
}

[dir="rtl"] .borne-card:hover {
  transform: translateX(-2px);
}

.borne-thumb {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}

.borne-info {
  flex: 1;
}

.borne-title {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 2px;
}

.borne-meta {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(6px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-dialog {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.75rem;
  box-shadow: var(--shadow-lg);
}

[dir="rtl"] .modal-dialog {
  text-align: right;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

/* Chat */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 450px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-primary);
}

.message-bubble {
  max-width: 80%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 0.88rem;
}

.message-outgoing {
  align-self: flex-end;
  background: var(--accent);
  color: #ffffff;
  border-bottom-right-radius: 2px;
}

[dir="rtl"] .message-outgoing {
  align-self: flex-start;
  border-bottom-right-radius: 12px;
  border-bottom-left-radius: 2px;
}

.message-incoming {
  align-self: flex-start;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-bottom-left-radius: 2px;
}

[dir="rtl"] .message-incoming {
  align-self: flex-end;
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 2px;
}

.chat-input-bar {
  display: flex;
  padding: 10px;
  gap: 8px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
}
