@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700;800;900&display=swap');

:root {
  --primary: #047857;
  --primary-hover: #065f46;
  --primary-light: #ecfdf5;
  --secondary: #d97706;
  --secondary-light: #fef3c7;
  --dark: #0f172a;
  --dark-surface: #1e293b;
  --light-bg: #f8fafc;
  --card-bg: #ffffff;
  --border-color: #e2e8f0;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --font-family: 'Tajawal', system-ui, -apple-system, sans-serif;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius: 0.75rem;
}

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

body {
  font-family: var(--font-family);
  direction: rtl;
  text-align: right;
  background-color: var(--light-bg);
  color: var(--text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Amazigh Subtle Geometric Header Border Pattern */
.amazigh-border-top {
  border-top: 4px solid var(--primary);
  background-image: repeating-linear-gradient(
    45deg,
    rgba(4, 120, 87, 0.05) 0px,
    rgba(4, 120, 87, 0.05) 10px,
    transparent 10px,
    transparent 20px
  );
}

/* Moroccan Municipal Hero Banner */
.hero-gradient {
  background: linear-gradient(135deg, rgba(6, 78, 59, 0.90) 0%, rgba(4, 120, 87, 0.86) 50%, rgba(15, 118, 110, 0.88) 100%),
              url('../img/eamizmiz_hero.jpg') center center / cover no-repeat;
  position: relative;
  overflow: hidden;
}

.hero-pattern {
  position: absolute;
  inset: 0;
  opacity: 0.07;
  background-image: radial-gradient(#ffffff 1.5px, transparent 1.5px);
  background-size: 24px 24px;
}

/* Container */
.container {
  width: 100%;
  max-width: 1280px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

/* Olive-Colored Top Institutional Bar (Amizmiz Authentic Olive Palette) */
.top-institutional-bar {
  background: #3c4f26;
  background: linear-gradient(90deg, #2d3c1c 0%, #3c4f26 50%, #475d2e 100%);
  color: #f2f6ec;
  border-bottom: 2px solid #556e36;
  font-size: 0.8rem;
  padding: 0.45rem 0;
  line-height: 1.4;
}

.top-institutional-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.top-institutional-hierarchy {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: #e4ecd4;
}

.top-institutional-hierarchy .hierarchy-commune {
  color: #ffffff;
  font-weight: 800;
}

.top-institutional-hierarchy .divider-dot {
  color: #a4be85;
  opacity: 0.8;
}

.top-institutional-slogan {
  color: #fef08a;
  font-weight: 700;
  font-size: 0.78rem;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

/* Header & Nav */
.navbar {
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 8px -2px rgba(0, 0, 0, 0.05);
  padding: 0.5rem 0;
}

.navbar-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  flex-shrink: 0;
}

.navbar-logo {
  height: 48px;
  width: auto;
  max-width: 52px;
  object-fit: contain;
}

.navbar-brand-text {
  display: flex;
  flex-direction: column;
}

.navbar-title {
  font-size: 1.18rem;
  font-weight: 800;
  color: #065f46;
  line-height: 1.2;
  margin: 0;
  white-space: nowrap;
}

.navbar-subtitle {
  font-size: 0.72rem;
  color: #64748b;
  margin: 2px 0 0;
  white-space: nowrap;
}

/* Nav Links & Actions */
.navbar-nav-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
}

.nav-link {
  font-weight: 600;
  font-size: 0.85rem;
  color: #334155;
  text-decoration: none;
  padding: 0.42rem 0.65rem;
  border-radius: 6px;
  white-space: nowrap;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.nav-link:hover {
  color: var(--primary);
  background-color: var(--primary-light);
}

.nav-link.active {
  color: var(--primary);
  background-color: var(--primary-light);
  font-weight: 700;
}

.nav-link-gis {
  color: #047857;
  font-weight: 700;
  background-color: #f0fdf4;
  border: 1px solid #bbf7d0;
}

.nav-link-gis:hover {
  background-color: #dcfce7;
}

.btn-cta-need {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background-color: #047857;
  color: #ffffff !important;
  font-size: 0.84rem;
  font-weight: 700;
  padding: 0.45rem 0.95rem;
  border-radius: 6px;
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid #047857;
  box-shadow: 0 1px 3px rgba(4, 120, 87, 0.2);
  transition: all 0.15s ease;
}

.btn-cta-need:hover {
  background-color: #065f46;
  border-color: #065f46;
  box-shadow: 0 2px 6px rgba(4, 120, 87, 0.3);
}

.btn-nav-login {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #475569 !important;
  background-color: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 0.45rem 0.75rem;
  border-radius: 6px;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.btn-nav-login:hover {
  background-color: #f1f5f9;
  border-color: #cbd5e1;
  color: #0f172a !important;
}

.navbar-toggle {
  display: none;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  color: #334155;
  font-size: 1.25rem;
  line-height: 1;
}

@media (max-width: 1260px) {
  .nav-link {
    padding: 0.4rem 0.45rem;
    font-size: 0.82rem;
  }
  .navbar-subtitle {
    display: none;
  }
}

@media (max-width: 1024px) {
  .navbar-toggle {
    display: block;
  }
  .navbar-nav-wrap {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    background: #ffffff;
    flex-direction: column;
    align-items: stretch;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    gap: 8px;
    z-index: 999;
  }
  .navbar-nav-wrap.is-open {
    display: flex;
  }
  .nav-link {
    padding: 0.6rem 0.85rem;
    font-size: 0.92rem;
  }
  .btn-cta-need, .btn-nav-login {
    width: 100%;
    justify-content: center;
  }
  .top-institutional-inner {
    justify-content: center;
    text-align: center;
  }
}

/* Card Styles */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.65rem 1.25rem;
  border-radius: 0.5rem;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-secondary {
  background-color: var(--secondary);
  color: #ffffff;
}

.btn-outline {
  border-color: var(--border-color);
  background-color: #ffffff;
  color: var(--text-main);
}

.btn-outline:hover {
  background-color: #f1f5f9;
  border-color: #cbd5e1;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 9999px;
  line-height: 1;
}

/* Forms */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 0.4rem;
  color: var(--text-main);
}

.form-control, .form-select {
  width: 100%;
  padding: 0.65rem 0.9rem;
  font-family: inherit;
  font-size: 0.95rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  background-color: #ffffff;
  color: var(--text-main);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus, .form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(4, 120, 87, 0.15);
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
  font-size: 0.9rem;
}

.table th {
  background-color: #f8fafc;
  color: var(--text-muted);
  font-weight: 700;
  padding: 0.75rem 1rem;
  border-bottom: 2px solid var(--border-color);
}

.table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.table tr:hover td {
  background-color: #f1f5f9;
}

/* Alerts */
.alert {
  padding: 0.9rem 1.25rem;
  border-radius: 0.5rem;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: #e0f2fe; color: #075985; border: 1px solid #bae6fd; }

/* Grid Helpers */
.grid { display: grid; }
.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.gap-8 { gap: 2rem; }

@media (max-width: 768px) {
  .grid-cols-2, .grid-cols-3, .grid-cols-4 {
    grid-template-columns: 1fr;
  }
  .navbar-nav {
    flex-direction: column;
    width: 100%;
  }
}

/* Map Container */
#map {
  width: 100%;
  height: 580px;
  border-radius: var(--radius);
  z-index: 10;
}

/* Map Popups */
.leaflet-popup-content-wrapper {
  border-radius: 0.75rem;
  font-family: var(--font-family);
  direction: rtl;
  text-align: right;
  padding: 0.25rem;
}

.leaflet-popup-content {
  margin: 0.75rem 1rem;
  line-height: 1.5;
}

/* Admin Sidebar */
.admin-sidebar {
  width: 260px;
  background: #0f172a;
  color: #e2e8f0;
  min-height: 100vh;
  padding: 1.5rem 1rem;
}

.admin-sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #94a3b8;
  padding: 0.7rem 1rem;
  border-radius: 0.5rem;
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s ease;
  margin-bottom: 0.25rem;
}

.admin-sidebar-link:hover, .admin-sidebar-link.active {
  color: #ffffff;
  background-color: rgba(4, 120, 87, 0.4);
}
