/* KEYNDGO Theme - Modern Property Management Dashboard */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&display=swap');

:root {
  /* Primary Colors - Warm Terracotta */
  --primary: #D97356;
  --primary-hover: #C4624A;
  --primary-light: rgba(217, 115, 86, 0.1);
  --primary-glow: rgba(217, 115, 86, 0.15);
  
  /* Region Colors */
  --tunisia: #D9923B;
  --tunisia-light: rgba(217, 146, 59, 0.1);
  --france: #3B82D9;
  --france-light: rgba(59, 130, 217, 0.1);
  
  /* Status Colors */
  --success: #22C55E;
  --success-light: rgba(34, 197, 94, 0.1);
  --warning: #F59E0B;
  --warning-light: rgba(245, 158, 11, 0.1);
  --danger: #EF4444;
  --danger-light: rgba(239, 68, 68, 0.1);
  --info: #0EA5E9;
  --info-light: rgba(14, 165, 233, 0.1);
  
  /* Neutrals */
  --background: #FAF8F6;
  --surface: #FFFFFF;
  --border: #E8E4E0;
  --text-primary: #1F1A17;
  --text-secondary: #6B6560;
  --text-muted: #9B9590;
  
  /* Sidebar */
  --sidebar-bg: #1F1A17;
  --sidebar-text: #E8E4E0;
  --sidebar-hover: rgba(217, 115, 86, 0.15);
  --sidebar-active: #D97356;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(31, 26, 23, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(31, 26, 23, 0.08), 0 2px 4px -2px rgba(31, 26, 23, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(31, 26, 23, 0.08), 0 4px 6px -4px rgba(31, 26, 23, 0.05);
  --shadow-glow: 0 0 40px var(--primary-glow);
  
  /* Gradients */
  --gradient-hero: linear-gradient(135deg, var(--primary) 0%, var(--tunisia) 100%);
  --gradient-sidebar: linear-gradient(180deg, #1F1A17 0%, #2D2520 100%);
  
  /* Radius */
  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 200ms ease;
  --transition-slow: 300ms ease;
}

/* Base Styles */
* {
  box-sizing: border-box;
}

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--background);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ====== SIDEBAR STYLES ====== */
.sidebar {
  background: var(--gradient-sidebar);
  min-height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  width: 260px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: width var(--transition-normal);
}

.sidebar-brand {
  padding: 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand-icon {
  width: 42px;
  height: 42px;
  background: var(--primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.25rem;
}

.sidebar-brand-text {
  margin-left: 0.75rem;
}

.sidebar-brand-name {
  font-weight: 700;
  font-size: 1.125rem;
  color: white;
  letter-spacing: -0.01em;
}

.sidebar-brand-tagline {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sidebar-nav {
  flex: 1;
  padding: 1.5rem 0.75rem;
}

.nav-item {
  margin-bottom: 0.25rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9375rem;
  transition: all var(--transition-fast);
}

.nav-link:hover {
  background: var(--sidebar-hover);
  color: white;
}

.nav-link.active {
  background: var(--sidebar-hover);
  color: var(--sidebar-active);
}

.nav-link i {
  font-size: 1.125rem;
  width: 1.25rem;
  text-align: center;
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-sync-btn {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--primary);
  border: none;
  border-radius: var(--radius-md);
  color: white;
  font-weight: 600;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.sidebar-sync-btn:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.sidebar-sync-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ====== MAIN CONTENT ====== */
.main-content {
  margin-left: 260px;
  padding: 2rem;
  min-height: 100vh;
}

/* ====== PAGE HEADER ====== */
.page-header {
  margin-bottom: 2rem;
}

.page-header-title {
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 0.25rem 0;
  letter-spacing: -0.02em;
}

.page-header-subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  margin: 0;
}

.page-header-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ====== SYNC PROGRESS CARD ====== */
.sync-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
}

.sync-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.sync-card-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sync-icon {
  width: 44px;
  height: 44px;
  background: var(--success-light);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--success);
  font-size: 1.25rem;
}

.sync-card-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-primary);
  margin: 0;
}

.sync-card-stage {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin: 0;
}

.sync-percentage {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.sync-progress-bar {
  height: 10px;
  background: var(--border);
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.sync-progress-fill {
  height: 100%;
  background: var(--gradient-hero);
  border-radius: 5px;
  transition: width 300ms ease;
}

.sync-details {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* ====== STAT CARDS ====== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--card-accent, var(--primary));
}

.stat-card.tunisia::before { background: var(--tunisia); }
.stat-card.france::before { background: var(--france); }
.stat-card.success::before { background: var(--success); }
.stat-card.warning::before { background: var(--warning); }
.stat-card.danger::before { background: var(--danger); }
.stat-card.info::before { background: var(--info); }

.stat-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.stat-card-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin: 0;
}

.stat-card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.stat-card.tunisia .stat-card-icon {
  background: var(--tunisia-light);
  color: var(--tunisia);
}

.stat-card.france .stat-card-icon {
  background: var(--france-light);
  color: var(--france);
}

.stat-card.success .stat-card-icon {
  background: var(--success-light);
  color: var(--success);
}

.stat-card.warning .stat-card-icon {
  background: var(--warning-light);
  color: var(--warning);
}

.stat-card.danger .stat-card-icon {
  background: var(--danger-light);
  color: var(--danger);
}

.stat-card.info .stat-card-icon {
  background: var(--info-light);
  color: var(--info);
}

.stat-card-value {
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 0.25rem;
}

.stat-card-subtitle {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: 0;
}

/* Clickable stat cards */
.stat-card-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.stat-card-link:hover .stat-card {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.stat-card-link .stat-card-footer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.8125rem;
  color: var(--primary);
  font-weight: 500;
}

/* ====== CHART CARDS ====== */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.chart-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
}

.chart-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.chart-card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chart-card-title .region-badge {
  font-size: 0.75rem;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-weight: 500;
}

.chart-card-title .region-badge.tunisia {
  background: var(--tunisia-light);
  color: var(--tunisia);
}

.chart-card-title .region-badge.france {
  background: var(--france-light);
  color: var(--france);
}

.chart-container {
  position: relative;
  height: 280px;
}

/* ====== TABLE CARDS ====== */
.table-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  overflow: hidden;
}

.table-card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.table-card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.table-keyndgo {
  width: 100%;
  border-collapse: collapse;
}

.table-keyndgo th {
  background: var(--background);
  padding: 0.875rem 1.5rem;
  text-align: left;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}

.table-keyndgo td {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9375rem;
  color: var(--text-primary);
}

.table-keyndgo tbody tr:last-child td {
  border-bottom: none;
}

.table-keyndgo tbody tr:hover {
  background: var(--primary-light);
}

.table-empty {
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
}

/* ====== BADGES ====== */
.badge-keyndgo {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-tunisia {
  background: var(--tunisia-light);
  color: var(--tunisia);
}

.badge-france {
  background: var(--france-light);
  color: var(--france);
}

.badge-success {
  background: var(--success-light);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-light);
  color: var(--warning);
}

.badge-danger {
  background: var(--danger-light);
  color: var(--danger);
}

/* ====== BUTTONS ====== */
.btn-keyndgo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
  text-decoration: none;
}

.btn-keyndgo:hover {
  transform: translateY(-1px);
}

.btn-keyndgo:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: var(--shadow-md);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.btn-outline:hover {
  background: var(--background);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-danger-outline {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
}

.btn-danger-outline:hover {
  background: var(--danger);
  color: white;
}

.btn-sm {
  padding: 0.5rem 0.875rem;
  font-size: 0.8125rem;
}

.btn-icon {
  padding: 0.5rem;
  width: 36px;
  height: 36px;
}

/* ====== ANIMATIONS ====== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.animate-fade-in {
  animation: fadeIn 0.5s ease-out forwards;
}

.animate-slide-up {
  animation: slideUp 0.5s ease-out forwards;
}

.animate-pulse {
  animation: pulse 2s ease-in-out infinite;
}

/* Animation delays for staggered effects */
.delay-100 { animation-delay: 100ms; }
.delay-200 { animation-delay: 200ms; }
.delay-300 { animation-delay: 300ms; }
.delay-400 { animation-delay: 400ms; }

/* ====== RESPONSIVE ====== */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
  }
  
  .sidebar.show {
    transform: translateX(0);
  }
  
  .main-content {
    margin-left: 0;
  }
  
  .chart-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 767.98px) {
  .main-content {
    padding: 1rem;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .page-header {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 1rem;
  }
  
  .page-header-actions {
    width: 100%;
  }
}

/* ====== UTILITIES ====== */
.text-tunisia { color: var(--tunisia); }
.text-france { color: var(--france); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-muted); }

.bg-tunisia-light { background: var(--tunisia-light); }
.bg-france-light { background: var(--france-light); }
.bg-success-light { background: var(--success-light); }
.bg-warning-light { background: var(--warning-light); }
.bg-danger-light { background: var(--danger-light); }

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.5rem;
}

.status-dot.success { background: var(--success); }
.status-dot.warning { background: var(--warning); }
.status-dot.danger { background: var(--danger); }
.status-dot.pulse { animation: pulse 2s ease-in-out infinite; }
/* ====== GLOBAL BOOTSTRAP THEME OVERRIDES ====== */
:root {
  --bs-primary: var(--primary);
  --bs-secondary: var(--france);
  --bs-success: var(--success);
  --bs-info: var(--info);
  --bs-warning: var(--warning);
  --bs-danger: var(--danger);
  --bs-light: #f8f9fa;
  --bs-dark: #212529;
}

/* Buttons */
.btn-primary {
  --bs-btn-bg: var(--primary);
  --bs-btn-border-color: var(--primary);
  --bs-btn-hover-bg: var(--primary-hover);
  --bs-btn-hover-border-color: var(--primary-hover);
  --bs-btn-active-bg: var(--primary-hover);
  --bs-btn-active-border-color: var(--primary-hover);
}

/* Cards */
.card {
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header { background-color: var(--primary-light); border-bottom: 1px solid var(--border); }

/* Tables */
.table { --bs-table-striped-bg: rgba(0,0,0,0.02); --bs-table-hover-bg: rgba(0,0,0,0.03); }
.table-modern {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
}
.table-modern thead th {
  background: var(--primary-light);
  color: var(--text-secondary);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
}
.table-modern tbody td, .table-modern thead th {
  padding: 0.75rem 1rem;
}
.table-modern tbody tr:hover td {
  background-color: rgba(0,0,0,0.03);
}
.table-modern tbody tr + tr td {
  border-top: 1px solid var(--border);
}
.table-modern th:first-child, .table-modern td:first-child { border-top-left-radius: var(--radius-sm); }
.table-modern th:last-child, .table-modern td:last-child { border-top-right-radius: var(--radius-sm); }
.table-modern tbody tr:last-child td:first-child { border-bottom-left-radius: var(--radius-sm); }
.table-modern tbody tr:last-child td:last-child { border-bottom-right-radius: var(--radius-sm); }

/* Forms */
.form-control, .form-select { border-radius: var(--radius-md); box-shadow: none; }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 0.2rem var(--primary-light); }
