@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

:root {
  --color-bg: #f5f3ef;
  --color-surface: #ffffff;
  --color-surface-hover: #faf9f7;
  --color-border: #e8e4de;
  --color-border-light: #f0ede8;
  --color-text: #1a1612;
  --color-text-secondary: #6b6359;
  --color-text-muted: #9b9389;
  --color-primary: #c8553d;
  --color-primary-hover: #b44a34;
  --color-primary-light: #fdf0ed;
  --color-success: #3d8c6e;
  --color-success-light: #edf7f2;
  --color-warning: #c49234;
  --color-warning-light: #fdf6e8;
  --color-info: #4a7db5;
  --color-info-light: #edf3fa;
  --color-danger: #c8553d;
  --color-sidebar-bg: #1a1612;
  --color-sidebar-text: #c4beb5;
  --color-sidebar-active: #ffffff;
  --color-sidebar-hover: rgba(255,255,255,0.06);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(26,22,18,0.04);
  --shadow-md: 0 4px 16px rgba(26,22,18,0.06);
  --shadow-lg: 0 8px 32px rgba(26,22,18,0.08);
  --transition: 180ms ease;
}

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

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  background: var(--color-sidebar-bg);
  padding: 28px 16px;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 240px;
  z-index: 100;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px 28px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  margin-bottom: 20px;
}

.sidebar-brand .logo {
  width: 36px;
  height: 36px;
  background: var(--color-primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
}

.sidebar-brand h1 {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  letter-spacing: -0.02em;
}

.sidebar-brand .domain {
  font-size: 11px;
  color: var(--color-sidebar-text);
  font-weight: 400;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--color-sidebar-text);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 14px;
  font-weight: 400;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: var(--color-sidebar-hover);
  color: #e0dbd4;
}

.nav-item.active {
  background: rgba(200,85,61,0.15);
  color: var(--color-sidebar-active);
  font-weight: 500;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-item.active svg { opacity: 1; }

.nav-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.25);
  padding: 20px 12px 6px;
  font-weight: 600;
}

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,0.07);
  padding-top: 16px;
  margin-top: 12px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  color: #fff;
}

.user-name { font-size: 13px; color: #fff; font-weight: 500; }
.user-email { font-size: 11px; color: var(--color-sidebar-text); }

/* Main content */
.main-content {
  padding: 32px 40px;
  overflow-y: auto;
}

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

.page-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--color-text);
}

.page-subtitle {
  font-size: 14px;
  color: var(--color-text-secondary);
  margin-top: 4px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid transparent;
  line-height: 1;
}

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

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
}
.btn-secondary:hover { background: var(--color-surface-hover); border-color: #d5d0c9; }

.btn-ghost {
  background: none;
  color: var(--color-text-secondary);
  padding: 6px 10px;
}
.btn-ghost:hover { background: rgba(0,0,0,0.04); }

.btn-danger {
  background: none;
  color: var(--color-danger);
  border-color: var(--color-danger);
}
.btn-danger:hover { background: #fdf0ed; }

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

.btn svg { width: 16px; height: 16px; }

/* Cards */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}

.stat-label {
  font-size: 12px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--color-text);
}

.stat-value.primary { color: var(--color-primary); }
.stat-value.success { color: var(--color-success); }

/* Table */
.table-container {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--color-border-light);
}

.table-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  text-align: left;
  padding: 12px 24px;
  border-bottom: 1px solid var(--color-border-light);
  background: var(--color-surface-hover);
}

tbody td {
  padding: 14px 24px;
  font-size: 14px;
  border-bottom: 1px solid var(--color-border-light);
  color: var(--color-text);
}

tbody tr:hover { background: var(--color-surface-hover); }

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

.td-name {
  font-weight: 500;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.badge-prospect { background: var(--color-info-light); color: var(--color-info); }
.badge-actif { background: var(--color-success-light); color: var(--color-success); }
.badge-inactif { background: #f3f0eb; color: var(--color-text-muted); }
.badge-archive { background: #f3f0eb; color: var(--color-text-muted); }

.badge-decouverte { background: var(--color-info-light); color: var(--color-info); }
.badge-visite { background: #f0edfb; color: #6b5baa; }
.badge-offre { background: var(--color-warning-light); color: var(--color-warning); }
.badge-negociation { background: #fdf0ed; color: var(--color-primary); }
.badge-compromis { background: var(--color-success-light); color: var(--color-success); }
.badge-acte { background: #e8f5e9; color: #2e7d32; }
.badge-perdu { background: #fce4ec; color: #c62828; }

/* Pipeline kanban */
.pipeline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 20px;
}

.pipeline-column {
  background: var(--color-surface-hover);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  padding: 14px;
  min-height: 200px;
}

.pipeline-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.pipeline-column-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-secondary);
}

.pipeline-column-count {
  font-size: 11px;
  background: var(--color-border);
  color: var(--color-text-secondary);
  padding: 1px 8px;
  border-radius: 10px;
  font-weight: 500;
}

.pipeline-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}

.pipeline-card:hover {
  box-shadow: var(--shadow-md);
  border-color: #d5d0c9;
}

.pipeline-card-title {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
}

.pipeline-card-amount {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-primary);
}

.pipeline-card-contact {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,22,18,0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms;
}

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

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(12px);
  transition: transform 200ms;
}

.modal-overlay.open .modal { transform: translateY(0); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--color-border-light);
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  transition: all var(--transition);
}

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

.modal-body { padding: 24px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--color-border-light);
}

/* Forms */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 9px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color var(--transition);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(200,85,61,0.08);
}

.form-textarea { resize: vertical; min-height: 80px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--color-text-muted);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 14px;
  margin-bottom: 20px;
}

/* Activity feed */
.activity-feed { display: flex; flex-direction: column; gap: 12px; }

.activity-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border-light);
}

.activity-item:last-child { border-bottom: none; }

.activity-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.activity-icon.appel { background: var(--color-info-light); color: var(--color-info); }
.activity-icon.email { background: var(--color-warning-light); color: var(--color-warning); }
.activity-icon.visite { background: var(--color-success-light); color: var(--color-success); }
.activity-icon.reunion { background: #f0edfb; color: #6b5baa; }
.activity-icon.note { background: #f3f0eb; color: var(--color-text-muted); }

.activity-content { flex: 1; }
.activity-title { font-size: 13px; font-weight: 500; }
.activity-desc { font-size: 12px; color: var(--color-text-muted); margin-top: 2px; }
.activity-time { font-size: 11px; color: var(--color-text-muted); margin-top: 4px; }

/* Auth page */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
}

.auth-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 400px;
  padding: 40px 36px;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
  justify-content: center;
}

.auth-logo .logo {
  width: 42px;
  height: 42px;
  background: var(--color-primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  color: #fff;
}

.auth-logo h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.auth-title {
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 24px;
}

.auth-card .btn-primary { width: 100%; justify-content: center; padding: 11px; }

.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--color-text-muted);
}

.auth-footer a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 500;
}

/* Loading spinner */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
}

/* Actions column */
.row-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--transition);
}

tbody tr:hover .row-actions { opacity: 1; }

/* Responsive */
@media (max-width: 900px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: -240px;
    transition: left 200ms;
  }
  .sidebar.open { left: 0; }
  .main-content { padding: 20px; }
  .pipeline { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 24px;
}

.tab {
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
  font-family: inherit;
}

.tab:hover { color: var(--color-text-secondary); }
.tab.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--color-sidebar-bg);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideUp 200ms;
}

.toast.success { border-left: 3px solid var(--color-success); }
.toast.error { border-left: 3px solid var(--color-danger); }

@keyframes slideUp {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Page sections */
.page-section {
  display: none;
}
.page-section.active {
  display: block;
}

/* Search bar */
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  min-width: 240px;
}

.search-bar svg { width: 16px; height: 16px; color: var(--color-text-muted); flex-shrink: 0; }

.search-bar input {
  border: none;
  background: none;
  padding: 9px 0;
  font-size: 13px;
  font-family: inherit;
  color: var(--color-text);
  outline: none;
  width: 100%;
}
