/* Base Styles & Design Tokens */
:root {
  --bg-color: #0b0f19;
  --bg-gradient: radial-gradient(circle at top right, #1e293b, #0f172a, #0b0f19);
  --card-bg: rgba(22, 30, 49, 0.65);
  --card-border: rgba(255, 255, 255, 0.08);
  --primary-color: #4f46e5;
  --primary-hover: #4338ca;
  --primary-gradient: linear-gradient(135deg, #6366f1, #3b82f6);
  --text-color: #f3f4f6;
  --text-muted: #9ca3af;
  
  --success-color: #10b981;
  --success-bg: rgba(16, 185, 129, 0.1);
  --warning-color: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.1);
  --error-color: #ef4444;
  --error-bg: rgba(239, 68, 68, 0.1);
  --info-color: #3b82f6;
  --info-bg: rgba(59, 130, 246, 0.1);
  
  --font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --border-radius: 12px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
}

/* Light Theme */
body.light-theme {
  --bg-color: #f1f5f9;
  --bg-gradient: radial-gradient(circle at top right, #e2e8f0, #f1f5f9, #f8fafc);
  --card-bg: rgba(255, 255, 255, 0.9);
  --card-border: rgba(15, 23, 42, 0.08);
  --text-color: #0f172a;
  --text-muted: #64748b;
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
  --success-bg: rgba(16, 185, 129, 0.12);
  --warning-bg: rgba(245, 158, 11, 0.12);
  --error-bg: rgba(239, 68, 68, 0.12);
  --info-bg: rgba(59, 130, 246, 0.12);
}
body.light-theme .sidebar {
  background: rgba(248, 250, 252, 0.95);
  border-right-color: rgba(15, 23, 42, 0.08);
}
body.light-theme .sidebar-brand {
  border-bottom-color: rgba(15, 23, 42, 0.06);
}
body.light-theme .sidebar-footer {
  border-top-color: rgba(15, 23, 42, 0.06);
}
body.light-theme .menu-item:hover {
  background: rgba(15, 23, 42, 0.04);
  color: #0f172a;
}
body.light-theme .main-header {
  border-bottom-color: rgba(15, 23, 42, 0.07);
}
body.light-theme input,
body.light-theme select,
body.light-theme textarea {
  background: rgba(15, 23, 42, 0.03);
  border-color: rgba(15, 23, 42, 0.12);
  color: var(--text-color);
}
body.light-theme input:focus,
body.light-theme select:focus,
body.light-theme textarea:focus {
  background: rgba(15, 23, 42, 0.04);
}
body.light-theme .modal-card {
  background: #ffffff;
}
body.light-theme .modal-header {
  border-bottom-color: rgba(15, 23, 42, 0.07);
}
body.light-theme .modal-footer {
  border-top-color: rgba(15, 23, 42, 0.07);
}
body.light-theme .modal-close-btn:hover {
  color: #0f172a;
}
body.light-theme ::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.04);
}
body.light-theme ::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, 0.15);
}
body.light-theme ::-webkit-scrollbar-thumb:hover {
  background: rgba(15, 23, 42, 0.25);
}
body.light-theme code {
  background: rgba(15, 23, 42, 0.06);
  color: #4f46e5;
}
body.light-theme .table-container table thead th {
  background: rgba(15, 23, 42, 0.04);
  border-bottom-color: rgba(15, 23, 42, 0.08);
}
body.light-theme .table-container table tbody tr {
  border-bottom-color: rgba(15, 23, 42, 0.05);
}
body.light-theme .table-container table tbody tr:hover {
  background: rgba(15, 23, 42, 0.02);
}
body.light-theme .btn-outline {
  border-color: rgba(15, 23, 42, 0.15);
  color: var(--text-color);
}
body.light-theme .btn-outline:hover {
  background: rgba(15, 23, 42, 0.05);
}
body.light-theme .alert {
  border-color: rgba(15, 23, 42, 0.08);
}

/* ── Correctifs couleurs hardcodées manquants en thème clair ── */
body.light-theme .auth-card {
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.12);
}
body.light-theme .section-title {
  color: var(--text-color);
  border-bottom-color: rgba(15, 23, 42, 0.08);
}
body.light-theme .error-banner {
  color: #991b1b;
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.2);
}
body.light-theme .alert-info {
  color: #1e40af;
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.2);
}
body.light-theme .alert-warning {
  color: #92400e;
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.25);
}
body.light-theme .status-active {
  color: #065f46;
}
body.light-theme .status-inactive {
  color: #92400e;
}
body.light-theme .status-unknown {
  color: #991b1b;
}
body.light-theme .status-not_deployed {
  color: #374151;
  background: rgba(15, 23, 42, 0.06);
}
body.light-theme .success-msg {
  color: #065f46;
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.2);
}
body.light-theme .error-msg {
  color: #991b1b;
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.2);
}
body.light-theme .import-zone {
  border-color: rgba(15, 23, 42, 0.15);
  background: rgba(15, 23, 42, 0.02);
}
body.light-theme .import-zone:hover,
body.light-theme .import-zone.dragover {
  border-color: #6366f1;
  background: rgba(99, 102, 241, 0.04);
}
body.light-theme .form-tab-btn:hover {
  color: var(--text-color);
}
body.light-theme .form-tabs {
  background: rgba(15, 23, 42, 0.02);
  border-bottom-color: rgba(15, 23, 42, 0.07);
}
body.light-theme .data-table th,
body.light-theme .data-table td {
  border-bottom-color: rgba(15, 23, 42, 0.07);
}
body.light-theme .modal-close-btn:hover {
  color: #0f172a;
}
body.light-theme .input-action-btn:hover {
  color: #0f172a;
}


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

body {
  font-family: var(--font-family);
  background: var(--bg-color);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-color);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Helpers */
.hidden { display: none !important; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.py-4 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.inline-flex { display: inline-flex; align-items: center; gap: 0.5rem; }

/* Buttons */
.btn {
  font-family: var(--font-family);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.625rem 1.25rem;
  border-radius: var(--border-radius);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: var(--transition);
  color: #fff;
}

.btn-primary {
  background: var(--primary-gradient);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.3);
}
.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-outline {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}
.btn-outline:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-block {
  width: 100%;
}

.btn-icon {
  padding: 0.625rem;
  border-radius: var(--border-radius);
}

/* Forms */
.form-group {
  margin-bottom: 1.25rem;
}
.form-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input, select, textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--border-radius);
  color: var(--text-color);
  font-family: var(--font-family);
  font-size: 0.9375rem;
  transition: var(--transition);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #6366f1;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Input Wrapper (Password Toggle) */
.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.input-wrapper input {
  padding-right: 3rem;
}
.input-action-btn {
  position: absolute;
  right: 1rem;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.input-action-btn:hover {
  color: #fff;
}

/* Grids & Layouts */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}
.grid-2-inline {
  display: flex;
  gap: 0.5rem;
}

/* Cards */
.card {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 1.75rem;
  overflow: hidden;
}
.card-header {
  margin-bottom: 1.5rem;
}
.card-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}
.card-header p {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Banners & Alerts */
.error-banner {
  background: var(--error-bg);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.2);
  padding: 0.75rem 1rem;
  border-radius: var(--border-radius);
  font-size: 0.875rem;
  margin-bottom: 1.25rem;
}
.alert {
  padding: 1rem;
  border-radius: var(--border-radius);
  font-size: 0.875rem;
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  line-height: 1.4;
}
.alert-info {
  background: var(--info-bg);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.2);
}
.alert-warning {
  background: var(--warning-bg);
  color: #fde047;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

/* ── AUTHENTICATION PAGE ─────────────────────────────────────────────── */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.auth-container {
  width: 100%;
  max-width: 440px;
}
.auth-card {
  background: rgba(22, 30, 49, 0.75);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  padding: 2.5rem;
}
.auth-header {
  text-align: center;
  margin-bottom: 2rem;
}
.auth-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  border-radius: 16px;
  background: var(--primary-gradient);
  color: #fff;
  margin-bottom: 1.25rem;
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3);
}
.auth-header h1 {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  margin-bottom: 0.25rem;
}
.auth-header p {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* Arrow micro-animation on login button hover */
.btn-arrow {
  transition: transform 0.2s ease;
}
.btn:hover .btn-arrow {
  transform: translateX(4px);
}

/* ── DASHBOARD LAYOUT ────────────────────────────────────────────────── */
.dashboard-page {
  display: flex;
  overflow: hidden;
  height: 100vh;
}
.app-layout {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* Barre Latérale */
.sidebar {
  width: 260px;
  background: rgba(15, 23, 42, 0.8);
  border-right: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.sidebar-brand {
  padding: 1.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.125rem;
  font-weight: 700;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.sidebar-brand .logo-icon {
  color: #6366f1;
}

.sidebar-menu {
  padding: 1.5rem 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}
.menu-item {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-family);
  font-size: 0.9375rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.75rem 1rem;
  border-radius: var(--border-radius);
  cursor: pointer;
  text-align: left;
  transition: var(--transition);
}
.menu-item:hover {
  background: rgba(255, 255, 255, 0.03);
  color: #fff;
}
.menu-item.active {
  background: rgba(99, 102, 241, 0.1);
  color: #6366f1;
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* Main Content Area */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 2.25rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}
.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 1.5rem;
}
.header-title h1 {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
}
.header-title p {
  color: var(--text-muted);
  font-size: 0.875rem;
}
.header-actions {
  display: flex;
  gap: 0.75rem;
}

/* Stats Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  padding: 1.5rem;
  border-radius: 16px;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  box-shadow: var(--shadow-lg);
}
.stat-icon {
  padding: 0.875rem;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.clients-icon {
  background: rgba(99, 102, 241, 0.1);
  color: #6366f1;
}
.active-icon {
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
}
.stopped-icon {
  background: rgba(156, 163, 175, 0.1);
  color: #9ca3af;
}
.stat-info h3 {
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.stat-info p {
  font-size: 1.75rem;
  font-weight: 700;
  margin-top: 0.25rem;
}

/* Data Table Card */
.card-table {
  padding: 0;
}
.table-responsive {
  width: 100%;
  overflow-x: auto;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
.data-table th, .data-table td {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.data-table th {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(255, 255, 255, 0.02);
}
.data-table tbody tr {
  transition: background 0.2s ease;
}
.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.625rem;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.status-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.status-active {
  background: var(--success-bg);
  color: #6ee7b7;
}
.status-active::before {
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
  animation: pulse 1.8s infinite;
}

.status-inactive {
  background: var(--warning-bg);
  color: #fde047;
}
.status-inactive::before {
  background: #f59e0b;
}

.status-not_deployed {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
}
.status-not_deployed::before {
  background: #9ca3af;
}

.status-unknown {
  background: var(--error-bg);
  color: #fca5a5;
}
.status-unknown::before {
  background: #ef4444;
}

@keyframes pulse {
  0% { transform: scale(0.9); opacity: 0.7; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.7; }
}

/* Action Buttons inside Table */
.actions-cell {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}
.actions-cell .btn {
  padding: 0.5rem;
  font-size: 0.75rem;
}

/* Rotating Refresh icon on click */
.refreshing .refresh-icon {
  animation: rotate 1s linear infinite;
}
@keyframes rotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Tab Panels */
.tab-pane {
  display: none;
  flex-direction: column;
  gap: 1.5rem;
}
.tab-pane.active {
  display: flex;
}

/* ── MODALS ──────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 1;
  transition: var(--transition);
}
.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}
.modal-card {
  width: 100%;
  max-width: 800px;
  max-height: 90vh;
  background: #0f172a;
  border: 1px solid var(--card-border);
  border-radius: 20px;
  box-shadow: 0 30px 60px -15px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  padding: 1.5rem 1.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
}
.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
}
.modal-close-btn:hover {
  color: #fff;
}

.modal-body {
  padding: 1.75rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 1.25rem 1.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  align-items: center;
  background: rgba(255, 255, 255, 0.01);
}

/* Tabs inside Modal Form */
.form-tabs {
  display: flex;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(0, 0, 0, 0.1);
  padding: 0 1rem;
}
.form-tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  padding: 1rem 1.25rem;
  font-family: var(--font-family);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.form-tab-btn:hover {
  color: #fff;
}
.form-tab-btn.active {
  color: #6366f1;
  border-bottom-color: #6366f1;
}

.form-tab-pane {
  display: none;
}
.form-tab-pane.active {
  display: block;
}

.section-title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: #fff;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 0.375rem;
}

.field-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  display: block;
}

/* Status messages (success, error) */
.status-msg {
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius);
}
.success-msg {
  background: var(--success-bg);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.2);
}
.error-msg {
  background: var(--error-bg);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Import Drag and Drop Zone */
.import-zone {
  border: 2px dashed rgba(255, 255, 255, 0.1);
  padding: 2.5rem 1.5rem;
  border-radius: 16px;
  text-align: center;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.01);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}
.import-zone:hover, .import-zone.dragover {
  border-color: #6366f1;
  background: rgba(99, 102, 241, 0.05);
}
.upload-cloud-icon {
  color: var(--text-muted);
}
.import-zone:hover .upload-cloud-icon {
  color: #6366f1;
}

/* Settings Form Styles */
.form-section {
  margin-top: 1.25rem;
}
