/* Lynkstor Admin — design opérationnel, sobre */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e5e7eb;
  --border-strong: #d1d5db;

  --text: #111827;
  --text-secondary: #4b5563;
  --text-muted: #6b7280;
  --text-faint: #9ca3af;

  --accent: #1e3a5f;
  --accent-hover: #162d4a;
  --accent-soft: #e8eef5;

  --success: #047857;
  --success-bg: #ecfdf5;
  --warning: #b45309;
  --warning-bg: #fffbeb;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --info: #1d4ed8;
  --info-bg: #eff6ff;

  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08);

  --sidebar-w: 240px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "SF Mono", "Consolas", "Liberation Mono", monospace;
}

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
}

/* ——— Layout ——— */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  height: 100vh;
  z-index: 50;
  padding: 20px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.brand img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: contain;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.brand-text h2 {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.2;
}

.brand-text p {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

.role-selector-box {
  margin: 0 4px 14px;
}

.role-selector-box label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.select-role-input,
.select-input,
.search-box input,
.form-group input,
.form-group select,
.copy-input input,
.input-readonly {
  width: 100%;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.select-role-input:focus,
.select-input:focus,
.search-box input:focus,
.form-group input:focus,
.form-group select:focus,
.copy-input input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
  padding: 0 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
}

.nav-item i {
  width: 16px;
  text-align: center;
  font-size: 13px;
  color: var(--text-faint);
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-item:hover i {
  color: var(--text-secondary);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
  font-weight: 600;
}

.nav-item.active i {
  color: var(--accent);
}

.badge {
  margin-left: auto;
  min-width: 22px;
  text-align: center;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.badge-accent {
  background: var(--success-bg);
  color: var(--success);
  border-color: #a7f3d0;
}

.badge-pulse {
  background: var(--info-bg);
  color: var(--info);
  border-color: #bfdbfe;
}

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

.server-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  padding: 0 6px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 650;
  flex-shrink: 0;
}

.user-info h4 {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
}

.user-info p {
  font-size: 11px;
  color: var(--text-muted);
}

/* ——— Main ——— */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 28px 32px 40px;
  max-width: 1400px;
}

.top-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.header-title h1 {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.03em;
  color: var(--text);
}

.header-title p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
  max-width: 520px;
}

.header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ——— Buttons ——— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
  background: var(--surface);
  color: var(--text);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

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

.btn-outline {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text-secondary);
}

.btn-outline:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
}

/* ——— Tabs ——— */
.tab-page {
  display: none;
}

.tab-page.active {
  display: block;
}

/* ——— KPI ——— */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}

@media (max-width: 1100px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .sidebar {
    display: none;
  }
  .main-content {
    margin-left: 0;
    padding: 16px;
  }
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 104px;
}

.kpi-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.kpi-value {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.15;
}

.kpi-meta {
  font-size: 12px;
  color: var(--text-faint);
}

/* hide legacy icon wrappers if present */
.kpi-icon {
  display: none;
}

.kpi-trend {
  display: none;
}

/* ——— Cards ——— */
.dashboard-row {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 14px;
}

@media (max-width: 960px) {
  .dashboard-row {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.card-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-header h3 i {
  color: var(--text-faint);
  font-size: 13px;
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.card-body {
  padding: 18px;
}

.padding-none {
  padding: 0;
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.table-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  width: 220px;
}

.search-box i {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  font-size: 12px;
}

.search-box input {
  padding-left: 30px;
}

/* ——— Map ——— */
#map-container {
  width: 100%;
  height: 560px;
  background: #e5e7eb;
  z-index: 1;
}

.custom-shop-pin,
.custom-agent-pin {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.pin-active {
  background: var(--success);
}

.pin-expired {
  background: var(--danger);
}

.custom-agent-pin {
  background: var(--accent);
}

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th {
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: #f9fafb;
}

.data-table code {
  font-size: 11px;
  color: var(--text-secondary);
}

/* ——— Badges status / plans ——— */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid transparent;
}

.status-badge i {
  font-size: 7px;
}

.status-active {
  background: var(--success-bg);
  color: var(--success);
  border-color: #a7f3d0;
}

.status-expired {
  background: var(--warning-bg);
  color: var(--warning);
  border-color: #fde68a;
}

.status-suspended {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: #fecaca;
}

.plan-badge {
  display: inline-block;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  background: var(--surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.plan-pro {
  background: var(--info-bg);
  color: var(--info);
  border-color: #bfdbfe;
}

.plan-enterprise {
  background: #f5f3ff;
  color: #5b21b6;
  border-color: #ddd6fe;
}

.plan-starter {
  background: var(--success-bg);
  color: var(--success);
  border-color: #a7f3d0;
}

.plan-gratuit {
  background: var(--surface-2);
  color: var(--text-muted);
}

/* ——— Activity list ——— */
.recent-list {
  display: flex;
  flex-direction: column;
}

.recent-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.recent-item:first-child {
  padding-top: 0;
}

.recent-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.recent-info h5 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.recent-info p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.recent-amount {
  font-size: 13px;
  font-weight: 600;
  color: var(--success);
  white-space: nowrap;
}

/* ——— Settings ——— */
.config-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 720px;
}

.config-box + .config-box {
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}

.config-box > label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.copy-input {
  display: flex;
  gap: 8px;
  align-items: center;
}

.copy-input input {
  flex: 1;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--surface-2);
}

.help-text {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ——— Modals ——— */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  padding: 16px;
}

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

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 100%;
  max-width: 440px;
  padding: 22px;
  box-shadow: var(--shadow-md);
}

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

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-header h3 i {
  color: var(--text-faint);
  font-size: 14px;
}

.close-modal {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.close-modal:hover {
  color: var(--text);
}

.form-group {
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group label {
  font-size: 12px;
  font-weight: 550;
  color: var(--text-secondary);
}

.input-readonly {
  background: var(--surface-2);
  color: var(--text-muted);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* ——— Login ——— */
.login-gate {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: var(--bg);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-gate.active {
  display: flex;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 28px 26px;
  box-shadow: var(--shadow-md);
}

.login-brand {
  text-align: center;
  margin-bottom: 22px;
}

.login-brand img {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-bottom: 12px;
  object-fit: contain;
  background: var(--surface-2);
}

.login-brand h2 {
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.login-brand p {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}

.login-error {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 10px;
  padding: 8px 10px;
  background: var(--danger-bg);
  border-radius: var(--radius-sm);
  border: 1px solid #fecaca;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
  color: var(--text-faint);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Leaflet popup light */
.leaflet-popup-content-wrapper {
  border-radius: 8px !important;
  box-shadow: var(--shadow-md) !important;
}

.leaflet-popup-content {
  margin: 10px 12px !important;
  font-family: var(--font) !important;
}
