/* ============================================
   LifeExpensive Mairie System - Custom Theme
   Green / Administration Municipale
   ============================================ */

/* --- Sidebar Enhancement --- */
.duik-sidebar {
  background: linear-gradient(180deg, #001a2a 0%, #00293d 100%) !important;
  border-right: 1px solid rgba(0, 188, 212, 0.15);
  min-height: 100vh;
}

/* Permettre le scroll dans la sidebar quand le contenu depasse */
.duik-sidebar-sticky {
  overflow-y: auto !important;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 188, 212, 0.3) transparent;
}
.duik-sidebar-sticky::-webkit-scrollbar {
  width: 5px;
}
.duik-sidebar-sticky::-webkit-scrollbar-track {
  background: transparent;
}
.duik-sidebar-sticky::-webkit-scrollbar-thumb {
  background: rgba(0, 188, 212, 0.3);
  border-radius: 3px;
}
.duik-sidebar-sticky::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 188, 212, 0.5);
}

.duik-sidebar__heading {
  color: #66d4dd !important;
  font-size: 0.7rem !important;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 0.8rem 1rem 0.3rem;
  margin-top: 0.5rem;
  border-top: 1px solid rgba(255,255,255,0.05);
}

.duik-sidebar__heading:first-child {
  border-top: none;
  margin-top: 0;
}

.duik-sidebar__link {
  color: #8ecfdf !important;
  padding: 0.45rem 1rem !important;
  font-size: 0.85rem;
  border-radius: 6px;
  margin: 1px 0.5rem;
  transition: all 0.2s ease;
}

.duik-sidebar__link:hover {
  color: #ffffff !important;
  background: rgba(0, 188, 212, 0.15);
}

.duik-sidebar__link.active {
  color: #ffffff !important;
  background: linear-gradient(135deg, #00BCD4, #0088b3) !important;
  box-shadow: 0 2px 8px rgba(0, 188, 212, 0.3);
  font-weight: 500;
}

.duik-sidebar__item {
  list-style: none;
}

/* Sidebar Logo Section */
.sidebar-logo {
  text-align: center;
  padding: 0.5rem 0.8rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 0.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.sidebar-logo img {
  max-width: 48px;
  height: auto;
  filter: drop-shadow(0 1px 4px rgba(0, 188, 212, 0.4));
  border-radius: 8px;
}

.sidebar-logo .server-name {
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  line-height: 1.2;
}

.sidebar-logo .server-subtitle {
  color: #00BCD4;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* --- Header Enhancement --- */
.duik-header .navbar {
  background: linear-gradient(135deg, #001a2a 0%, #003a4d 100%) !important;
  border-bottom: 2px solid #00BCD4;
  box-shadow: 0 2px 15px rgba(0, 0, 0, 0.3);
}

.duik-header .navbar-brand {
  background: rgba(0, 188, 212, 0.12) !important;
  font-weight: 600;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
}

.duik-header .navbar-brand img {
  filter: drop-shadow(0 1px 3px rgba(0, 188, 212, 0.5));
}

.duik-header .form-control {
  background: rgba(255, 255, 255, 0.08) !important;
  color: #ffffff !important;
  border: 1px solid rgba(0, 188, 212, 0.2) !important;
  border-radius: 8px;
}

.duik-header .form-control:focus {
  background: rgba(255, 255, 255, 0.12) !important;
  border-color: #00BCD4 !important;
  box-shadow: 0 0 0 0.15rem rgba(0, 188, 212, 0.25);
}

.duik-header .form-control::placeholder {
  color: rgba(255, 255, 255, 0.4) !important;
}

/* --- Card Enhancements --- */
.card {
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* Stat Cards */
.stat-card {
  position: relative;
  overflow: hidden;
  border-left: 4px solid #00BCD4 !important;
  border-radius: 12px;
  padding: 0.5rem;
}

.stat-card.stat-primary { border-left-color: #00BCD4 !important; }
.stat-card.stat-success { border-left-color: #28a745 !important; }
.stat-card.stat-danger { border-left-color: #dc3545 !important; }
.stat-card.stat-warning { border-left-color: #ffc107 !important; }
.stat-card.stat-info { border-left-color: #17a2b8 !important; }

.stat-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #6c757d;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}

.stat-icon {
  width: 45px;
  height: 45px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.bg-primary-soft { background: rgba(0, 188, 212, 0.1); color: #00BCD4; }
.bg-success-soft { background: rgba(40, 167, 69, 0.1); color: #28a745; }
.bg-danger-soft { background: rgba(220, 53, 69, 0.1); color: #dc3545; }
.bg-warning-soft { background: rgba(255, 193, 7, 0.1); color: #ffc107; }
.bg-info-soft { background: rgba(23, 162, 184, 0.1); color: #17a2b8; }

/* --- BTP Status Badges --- */
.badge-btp-available {
  background: rgba(40, 167, 69, 0.15);
  color: #28a745;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
}

.badge-btp-sold {
  background: rgba(0, 188, 212, 0.15);
  color: #00BCD4;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
}

.badge-btp-construction {
  background: rgba(23, 162, 184, 0.15);
  color: #17a2b8;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
}

.badge-btp-completed {
  background: rgba(108, 117, 125, 0.15);
  color: #6c757d;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
}

.badge-btp-integrated {
  background: rgba(111, 66, 193, 0.15);
  color: #6f42c1;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
}

/* Contract status */
.badge-status-pending {
  background: rgba(255, 193, 7, 0.15);
  color: #d4a106;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
}

.badge-status-signed {
  background: rgba(0, 188, 212, 0.15);
  color: #00BCD4;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
}

.badge-status-permit_requested {
  background: rgba(63, 114, 175, 0.15);
  color: #3f72af;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
}

.badge-status-permit_granted {
  background: rgba(23, 162, 184, 0.15);
  color: #17a2b8;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
}

.badge-status-in_progress {
  background: rgba(23, 162, 184, 0.15);
  color: #17a2b8;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
}

.badge-status-validated {
  background: rgba(40, 167, 69, 0.15);
  color: #28a745;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
}

.badge-status-cancelled {
  background: rgba(220, 53, 69, 0.15);
  color: #dc3545;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
}

.badge-status-refused {
  background: rgba(255, 152, 0, 0.15);
  color: #e68a00;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
}

.badge-status-permit_refused {
  background: rgba(255, 152, 0, 0.15);
  color: #e68a00;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
}

.badge-status-integrated {
  background: rgba(108, 117, 125, 0.15);
  color: #6c757d;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
}

.badge-status-permit_revoked {
  background: rgba(220, 53, 69, 0.15);
  color: #dc3545;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
}

.badge-status-proposed {
  background: rgba(255, 152, 0, 0.15);
  color: #ff9800;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
}

.badge-status-completed {
  background: rgba(40, 167, 69, 0.15);
  color: #28a745;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
}

/* --- Progress Bar Mairie --- */
.progress-mairie {
  height: 20px;
  border-radius: 10px;
  background: rgba(0,0,0,0.05);
}

.progress-mairie .progress-bar {
  background: linear-gradient(90deg, #00BCD4, #44ccdd);
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
}

/* --- Form Styling --- */
.form-control {
  border-radius: 8px;
  border: 1px solid #dee2e6;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus {
  border-color: #00BCD4;
  box-shadow: 0 0 0 0.15rem rgba(0, 188, 212, 0.25);
}

.custom-control-input:checked ~ .custom-control-label::before {
  background-color: #00BCD4;
  border-color: #00BCD4;
}

/* --- DataTables Dark Theme Overrides --- */
.dataTables_wrapper .dataTables_filter input {
  border-radius: 8px;
  border: 1px solid #dee2e6;
  padding: 4px 12px;
}

.dataTables_wrapper .dataTables_filter input:focus {
  border-color: #00BCD4;
  box-shadow: 0 0 0 0.15rem rgba(0, 188, 212, 0.25);
  outline: none;
}

.dataTables_wrapper .dataTables_length select {
  border-radius: 6px;
  padding: 2px 8px;
}

table.dataTable thead th {
  background: linear-gradient(135deg, #001a2a 0%, #00293d 100%) !important;
  color: #ffffff !important;
  border-bottom: 2px solid #00BCD4 !important;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

table.dataTable tbody td {
  vertical-align: middle;
  font-size: 0.85rem;
  color: #e0e0e0;
}

table.dataTable tbody tr {
  background-color: #001a2a;
}

table.dataTable tbody tr:nth-child(even) {
  background-color: #00223a;
}

table.dataTable tbody tr:hover {
  background-color: rgba(0, 188, 212, 0.15) !important;
}

.page-item.active .page-link {
  background-color: #00BCD4;
  border-color: #00BCD4;
}

.page-link {
  color: #00BCD4;
}

.page-link:hover {
  color: #0088b3;
}

/* --- Modal --- */
.modal-header {
  border-bottom: 2px solid #00BCD4;
}

.modal-content {
  border-radius: 12px;
  overflow: hidden;
}

/* --- Buttons Mairie --- */
.btn-mairie {
  background: linear-gradient(135deg, #00BCD4 0%, #0088b3 100%);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  letter-spacing: 0.5px;
  transition: all 0.3s ease;
}

.btn-mairie:hover {
  background: linear-gradient(135deg, #44ccdd 0%, #00BCD4 100%);
  color: #fff;
  box-shadow: 0 4px 15px rgba(0, 188, 212, 0.4);
}

.btn-outline-mairie {
  color: #00BCD4;
  border: 1px solid #00BCD4;
  background: transparent;
  border-radius: 8px;
}

.btn-outline-mairie:hover {
  color: #fff;
  background: #00BCD4;
}

/* --- Sidebar Mobile Backdrop --- */
.sidebar-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1025;
  display: none;
}
.sidebar-backdrop.show {
  display: block;
}

/* --- Responsive --- */
@media (max-width: 767px) {
  .stat-value {
    font-size: 1.2rem;
  }

  .stat-icon {
    width: 35px;
    height: 35px;
    font-size: 0.9rem;
  }

  .duik-sidebar {
    position: fixed;
    z-index: 1030;
    top: 56px;
    left: 0;
    right: 0;
    max-height: calc(100vh - 56px);
    overflow-y: auto;
  }

  /* Padding-top pour compenser la navbar fixe */
  main.ml-md-auto { padding-top: 4rem; }

  /* Quick actions : 2 colonnes au lieu de 3 */
  .quick-action-btn { padding: 0.7rem 0.5rem; font-size: 0.8rem; }
  .quick-action-btn i { font-size: 1.2rem; }

  /* Tables DataTables scroll horizontal */
  .dataTables_wrapper { overflow-x: auto; }
  .dataTables_wrapper table { min-width: 600px; }

  /* Formulaires pleine largeur */
  .form-control, .custom-select { font-size: 16px; }

  /* Forms inline -> vertical sur mobile */
  .form-inline { flex-direction: column; align-items: stretch; }
  .form-inline .form-control,
  .form-inline .custom-select,
  .form-inline .btn { width: 100%; margin-bottom: 0.5rem; }

  /* Override inline min-width */
  input[style*="min-width"] { min-width: 100% !important; }

  /* Autocomplete dropdown responsive */
  .ui-autocomplete { max-width: calc(100vw - 2rem) !important; overflow-x: hidden; }
}

/* --- Callout (messages) --- */
.duik-callout {
  padding: 1rem 1.25rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-left: 4px solid #6c757d;
  display: flex;
  align-items: center;
}

.duik-callout-success { border-left-color: #28a745; background: rgba(40,167,69,0.05); }
.duik-callout-danger { border-left-color: #dc3545; background: rgba(220,53,69,0.05); }
.duik-callout-warning { border-left-color: #ffc107; background: rgba(255,193,7,0.05); }
.duik-callout-info { border-left-color: #17a2b8; background: rgba(23,162,184,0.05); }

/* --- Page Title --- */
.page-title-bar {
  padding-bottom: 0.5rem;
  border-bottom: 2px solid rgba(0, 188, 212, 0.15);
}

/* --- Dark Theme: Main Content Area --- */
.duik-content {
  background: #001020;
  color: #e0e0e0;
}

/* --- Dark Theme: Text & Labels --- */
.duik-content label,
.duik-content .form-group label {
  color: #b0c4d8;
}

.duik-content p,
.duik-content li,
.duik-content span:not(.badge):not(.stat-value):not(.stat-label) {
  color: inherit;
}

.duik-content .text-muted {
  color: #7a98b0 !important;
}

.duik-content h4, .duik-content h5, .duik-content h6 {
  color: #e8f0f8;
}

.duik-content code {
  color: #8ecfdf;
  background: rgba(0, 188, 212, 0.1);
  padding: 1px 5px;
  border-radius: 3px;
}

.duik-content small {
  color: #8a9fb3;
}

/* --- Dark Theme: Form Controls --- */
.duik-content .form-control,
.duik-content .custom-select {
  background: #001a2a;
  color: #e0e0e0;
  border: 1px solid rgba(0, 188, 212, 0.2);
}

.duik-content .form-control:focus,
.duik-content .custom-select:focus {
  background: #00223a;
  color: #ffffff;
  border-color: #00BCD4;
  box-shadow: 0 0 0 0.15rem rgba(0, 188, 212, 0.25);
}

.duik-content .form-control::placeholder {
  color: rgba(255, 255, 255, 0.35);
}

.duik-content textarea.form-control {
  background: #001a2a;
  color: #e0e0e0;
}

.duik-content .custom-control-label {
  color: #b0c4d8;
}

/* --- Dark Theme: DataTables Controls --- */
.duik-content .dataTables_wrapper .dataTables_filter label,
.duik-content .dataTables_wrapper .dataTables_length label {
  color: #8ecfdf;
}

.duik-content .dataTables_wrapper .dataTables_filter input {
  background: #001a2a;
  color: #e0e0e0;
  border: 1px solid rgba(0, 188, 212, 0.2);
}

.duik-content .dataTables_wrapper .dataTables_filter input:focus {
  background: #00223a;
  color: #ffffff;
}

.duik-content .dataTables_wrapper .dataTables_length select {
  background: #001a2a;
  color: #e0e0e0;
  border: 1px solid rgba(0, 188, 212, 0.2);
}

.duik-content .dataTables_wrapper .dataTables_info {
  color: #7a98b0;
}

.duik-content .dataTables_wrapper .dataTables_paginate .page-link {
  background: #001a2a;
  color: #8ecfdf;
  border-color: rgba(0, 188, 212, 0.15);
}

.duik-content .dataTables_wrapper .dataTables_paginate .page-item.active .page-link {
  background: #00BCD4;
  color: #ffffff;
  border-color: #00BCD4;
}

.duik-content .dataTables_wrapper .dataTables_paginate .page-item.disabled .page-link {
  background: #00111e;
  color: #4a6070;
  border-color: rgba(0, 188, 212, 0.08);
}

.duik-content .dataTables_wrapper .dataTables_empty {
  color: #7a98b0;
}

/* --- Dark Theme: Tables (non-DataTables) --- */
.duik-content .table {
  color: #e0e0e0;
}

.duik-content .table td,
.duik-content .table th {
  border-color: rgba(255, 255, 255, 0.05);
}

/* --- Dark Theme: Modal --- */
.modal-content {
  background: #001a2a;
  color: #e0e0e0;
}

.modal-header {
  border-bottom: 2px solid #00BCD4;
  color: #e8f0f8;
}

.modal-footer {
  border-top: 1px solid rgba(0, 188, 212, 0.15);
}

.modal-content label {
  color: #b0c4d8;
}

.modal-content .form-control {
  background: #00293d;
  color: #e0e0e0;
  border: 1px solid rgba(0, 188, 212, 0.2);
}

.modal-content .form-control:focus {
  background: #003a50;
  color: #ffffff;
  border-color: #00BCD4;
}

.modal-content .close {
  color: #8ecfdf;
  text-shadow: none;
  opacity: 0.7;
}

.modal-content .close:hover {
  color: #ffffff;
  opacity: 1;
}

/* --- Dark Theme: Cards body text --- */
.duik-content .card-body {
  color: #e0e0e0;
}

.duik-content .card-header small {
  color: #7a98b0;
}

/* --- Dark Theme: Alerts/Callouts on dark bg --- */
.duik-content .duik-callout {
  background: #001a2a;
  border-color: rgba(255, 255, 255, 0.08);
  color: #e0e0e0;
}

.duik-content .duik-callout-success { background: rgba(40,167,69,0.1); }
.duik-content .duik-callout-danger { background: rgba(220,53,69,0.1); }
.duik-content .duik-callout-warning { background: rgba(255,193,7,0.1); }
.duik-content .duik-callout-info { background: rgba(23,162,184,0.1); }

/* --- Dark Theme: Stat cards text --- */
.duik-content .stat-card {
  background: #00293d;
}

.duik-content .stat-label {
  color: #7a98b0;
}