/* =============================================
   CRM Amélie Développement
   ============================================= */

:root {
  --primary:        #7B1F6A;
  --primary-light:  #9B3589;
  --primary-ultra:  #f5eaf3;
  --teal:           #2C5F74;
  --teal-light:     #3a7a91;
  --blue:           #6EC1E4;
  --blue-light:     #e8f6fc;
  --success:        #2e9e6b;
  --success-light:  #e6f7f0;
  --warning:        #e07b2a;
  --warning-light:  #fef3e6;
  --danger:         #c0392b;
  --danger-light:   #fdecea;
  --bg:             #f7f5f9;
  --surface:        #ffffff;
  --surface-2:      #f0edf4;
  --text:           #1a1025;
  --text-2:         #5a4f6b;
  --text-3:         #9988aa;
  --border:         #e2d9ec;
  --sidebar-w:      240px;
  --radius:         10px;
  --radius-lg:      16px;
  --shadow:         0 2px 12px rgba(123,31,106,0.07);
  --shadow-lg:      0 8px 32px rgba(123,31,106,0.12);
  --transition:     0.2s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
}

/* SIDEBAR */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: linear-gradient(175deg, #5c1750 0%, #7B1F6A 55%, #2C5F74 100%);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  transition: transform var(--transition);
}

.sidebar-logo {
  padding: 24px 20px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  margin-bottom: 8px;
}
.logo-icon { font-size: 1.4rem; color: var(--blue); }
.logo-text  { font-size: 1.05rem; font-weight: 700; color: #fff; letter-spacing: -0.02em; }

.sidebar-nav { padding: 8px 12px; flex: 1; }

.nav-section {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.4);
  padding: 18px 8px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: rgba(255,255,255,0.75);
  font-size: 0.88rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255,255,255,0.12); color: #fff; }
.nav-item.active { background: rgba(255,255,255,0.18); color: #fff; font-weight: 600; }
.nav-icon { font-size: 1rem; width: 18px; text-align: center; }
.notif-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px; height: 18px;
  padding: 0 5px;
  background: var(--danger);
  color: #fff;
  border-radius: 10px;
  font-size: 0.65rem;
  font-weight: 700;
  margin-left: auto;
}

.sidebar-footer {
  padding: 16px 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.12);
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 32px; height: 32px;
  background: var(--blue);
  color: var(--teal);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem; flex-shrink: 0;
}
.user-name { color: rgba(255,255,255,0.85); font-size: 0.85rem; flex: 1; }
.btn-logout { color: rgba(255,255,255,0.5); text-decoration: none; font-size: 1.1rem; transition: color var(--transition); padding: 4px; }
.btn-logout:hover { color: #fff; }

/* MAIN LAYOUT */
.main-wrapper { margin-left: var(--sidebar-w); flex: 1; min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 60px;
  display: flex; align-items: center; gap: 16px;
  z-index: 50;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.menu-toggle { display: none; background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--text-2); padding: 4px 8px; }
.page-title { font-size: 1.1rem; font-weight: 600; color: var(--text); flex: 1; }
.today-date { font-size: 0.8rem; color: var(--text-3); text-transform: capitalize; }

.main-content { padding: 28px; flex: 1; }

/* CARDS */
.card { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow); border: 1px solid var(--border); overflow: hidden; }
.card-header { padding: 18px 22px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-title { font-size: 0.95rem; font-weight: 600; color: var(--text); }
.card-body { padding: 18px 22px; }

/* STATS */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 6px;
  transition: transform var(--transition), box-shadow var(--transition);
  text-decoration: none; color: inherit;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; margin-bottom: 4px; }
.stat-icon.violet { background: var(--primary-ultra); }
.stat-icon.teal   { background: #e5eff3; }
.stat-icon.blue   { background: var(--blue-light); }
.stat-icon.green  { background: var(--success-light); }
.stat-icon.orange { background: var(--warning-light); }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--text); line-height: 1; letter-spacing: -0.03em; }
.stat-label { font-size: 0.78rem; color: var(--text-3); font-weight: 500; }

/* DASHBOARD */
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.dashboard-grid .full-width { grid-column: 1 / -1; }

/* TABLES */
.table-responsive { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th { padding: 10px 14px; text-align: left; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-3); background: var(--bg); border-bottom: 1px solid var(--border); }
tbody td { padding: 12px 14px; font-size: 0.875rem; color: var(--text); border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg); }
tbody tr.overdue td { background: #fff8f7; }
tbody tr.overdue:hover td { background: #fef0ee; }
.table-actions { display: flex; gap: 6px; }

/* BADGES */
.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 20px; font-size: 0.72rem; font-weight: 600; white-space: nowrap; }
.badge-nouveau    { background: var(--surface-2); color: var(--text-2); }
.badge-contacte   { background: var(--blue-light); color: var(--teal); }
.badge-rdv        { background: #fef9e6; color: #a07020; }
.badge-devis      { background: #ece8f7; color: #5535b0; }
.badge-signe      { background: var(--success-light); color: var(--success); }
.badge-perdu      { background: var(--danger-light); color: var(--danger); }

/* BUTTONS */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 16px; border-radius: 8px; font-size: 0.85rem; font-weight: 600; cursor: pointer; text-decoration: none; transition: all var(--transition); border: 1px solid transparent; white-space: nowrap; font-family: inherit; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-light); border-color: var(--primary-light); }
.btn-teal { background: var(--teal); color: #fff; border-color: var(--teal); }
.btn-teal:hover { background: var(--teal-light); }
.btn-secondary { background: var(--surface); color: var(--text-2); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-danger { background: var(--danger-light); color: var(--danger); border-color: #f5c6c1; }
.btn-danger:hover { background: #f9d0cb; }
.btn-icon { padding: 6px 9px; font-size: 0.85rem; border-radius: 7px; }
.btn-sm { padding: 5px 11px; font-size: 0.8rem; }

/* FORMS */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 0.8rem; font-weight: 600; color: var(--text-2); }
input, select, textarea { padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 0.875rem; font-family: inherit; color: var(--text); background: var(--surface); transition: border-color var(--transition), box-shadow var(--transition); width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(123,31,106,0.1); }
textarea { min-height: 90px; resize: vertical; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; padding-top: 8px; grid-column: 1 / -1; }

/* TOOLBAR */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.search-input { flex: 1; min-width: 200px; max-width: 340px; }
.filter-select { min-width: 150px; width: auto; }

/* MODAL */
.modal-overlay { position: fixed; inset: 0; background: rgba(20,10,30,0.45); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px; opacity: 0; pointer-events: none; transition: opacity var(--transition); }
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal { background: var(--surface); border-radius: var(--radius-lg); width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); transform: translateY(10px); transition: transform var(--transition); }
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header { padding: 20px 24px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 1rem; font-weight: 700; color: var(--text); }
.modal-close { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--text-3); padding: 2px 6px; border-radius: 5px; transition: background var(--transition); }
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 20px 24px 24px; }

/* ALERTS */
.alert { padding: 12px 16px; border-radius: var(--radius); font-size: 0.875rem; font-weight: 500; margin-bottom: 16px; }
.alert-danger  { background: var(--danger-light); color: var(--danger); border-left: 3px solid var(--danger); }
.alert-success { background: var(--success-light); color: var(--success); border-left: 3px solid var(--success); }
.alert-warning { background: var(--warning-light); color: var(--warning); border-left: 3px solid var(--warning); }

/* EMPTY STATE */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-3); }
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state p { font-size: 0.9rem; }

/* RELANCES */
.relance-item { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); transition: background var(--transition); }
.relance-item:last-child { border-bottom: none; }
.relance-item:hover { background: var(--warning-light); }
.relance-item.overdue .relance-date { color: var(--danger); font-weight: 600; }
.relance-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warning); flex-shrink: 0; }
.relance-item.overdue .relance-dot { background: var(--danger); }
.relance-name { font-weight: 600; font-size: 0.875rem; }
.relance-sub  { font-size: 0.78rem; color: var(--text-3); }
.relance-date { font-size: 0.78rem; color: var(--warning); margin-left: auto; white-space: nowrap; }

/* LOGIN */
.login-page { min-height: 100vh; background: linear-gradient(135deg, #5c1750 0%, #7B1F6A 55%, #2C5F74 100%); display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: var(--surface); border-radius: 20px; padding: 44px 40px 40px; width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,0.25); }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo-icon { font-size: 2.5rem; display: block; color: var(--primary); line-height: 1; margin-bottom: 10px; }
.login-logo-text { font-size: 1.35rem; font-weight: 700; color: var(--text); letter-spacing: -0.03em; }
.login-logo-sub { font-size: 0.8rem; color: var(--text-3); margin-top: 3px; }
.login-card .form-group { margin-bottom: 14px; }
.login-card .btn-primary { width: 100%; justify-content: center; padding: 10px; margin-top: 6px; font-size: 0.95rem; }

/* PRIORITY */
.priority-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.p-basse   { background: var(--text-3); }
.p-normale { background: var(--blue); }
.p-haute   { background: var(--warning); }
.p-urgente { background: var(--danger); }

/* SIDEBAR OVERLAY */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 99; }

/* RESPONSIVE */
@media (max-width: 900px) { .dashboard-grid { grid-template-columns: 1fr; } }
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .main-wrapper { margin-left: 0; }
  .menu-toggle { display: block; }
  .main-content { padding: 18px; }
  .topbar { padding: 0 18px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-group.full { grid-column: 1; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .toolbar { flex-direction: column; align-items: stretch; }
  .search-input { max-width: 100%; }
  .login-card { padding: 32px 24px 28px; }
}
@media (max-width: 480px) { .stats-grid { grid-template-columns: 1fr 1fr; } .today-date { display: none; } }
