/* ============================================================
   GestionInter — Feuille de style principale
   ============================================================ */

/* --- Variables CSS --- */
:root {
  --primary:      #1a2f5e;
  --secondary:    #2d4a8a;
  --accent:       #4a90d9;
  --bg:           #f0f2f5;
  --white:        #ffffff;
  --success:      #27ae60;
  --warning:      #f39c12;
  --danger:       #e74c3c;
  --orange:       #e67e22;
  --info:         #3498db;
  --text:         #2c3e50;
  --text-muted:   #7f8c8d;
  --border:       #dde1e7;
  --shadow:       0 2px 8px rgba(0,0,0,.08);
  --shadow-md:    0 4px 16px rgba(0,0,0,.12);
  --radius:       8px;
  --sidebar-w:    260px;
  --topbar-h:     64px;
  --transition:   all .2s ease;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: 'Segoe UI', Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1,h2,h3,h4 { margin: 0 0 .5rem; font-weight: 600; }
p { margin: 0 0 .75rem; }
label { display: block; font-weight: 600; margin-bottom: 4px; font-size: 13px; }

/* ============================================================
   LAYOUT : Sidebar + Main
   ============================================================ */

/* --- Sidebar --- */
.sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--primary);
  display: flex; flex-direction: column;
  overflow: hidden;
  z-index: 1000;
  transition: transform .25s ease;
}

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}

.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  font-size: 20px; font-weight: 700; color: var(--white);
}

.logo-icon { font-size: 24px; }
.sidebar-agence { color: rgba(255,255,255,.55); font-size: 12px; margin-top: 4px; }

/* Menus */
.sidebar-menu {
  list-style: none; margin: 0; padding: 8px 0;
  flex: 1; overflow-y: auto;
}

.menu-item a {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 20px;
  color: rgba(255,255,255,.75);
  transition: var(--transition);
  border-left: 3px solid transparent;
}

.menu-item a:hover,
.menu-item.active a {
  background: rgba(255,255,255,.1);
  color: var(--white);
  border-left-color: var(--accent);
  text-decoration: none;
}

.menu-icon { font-size: 18px; min-width: 22px; text-align: center; }
.menu-label { font-size: 14px; font-weight: 500; }

.menu-badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: 11px; font-weight: 700;
  padding: 2px 7px; border-radius: 12px;
  min-width: 20px; text-align: center;
}

/* Bas du sidebar */
.sidebar-bottom {
  border-top: 1px solid rgba(255,255,255,.1);
  padding: 8px 0 0;
  margin-top: auto;
}

.menu-item-make a { color: rgba(255,255,255,.6); }
.menu-item-make a:hover { color: var(--white); }

.btn-logout {
  display: flex; align-items: center; gap: 10px;
  margin: 8px 12px 12px;
  padding: 10px 16px;
  background: var(--danger);
  color: var(--white) !important;
  border-radius: var(--radius);
  font-weight: 600; font-size: 14px;
  transition: var(--transition);
  text-decoration: none;
}

.btn-logout:hover {
  background: #c0392b;
  text-decoration: none;
}

/* --- Contenu principal --- */
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex; flex-direction: column;
}

/* --- Topbar --- */
.topbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  box-shadow: var(--shadow);
}

.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-title { font-size: 16px; font-weight: 600; color: var(--text); }

.hamburger {
  display: none; flex-direction: column; gap: 5px;
  background: none; border: none; cursor: pointer; padding: 4px;
}
.hamburger span {
  display: block; width: 22px; height: 2px;
  background: var(--text); border-radius: 2px; transition: var(--transition);
}

.topbar-right { display: flex; align-items: center; gap: 16px; }

.notif-badge {
  background: var(--danger); color: white;
  padding: 4px 10px; border-radius: 20px;
  font-size: 13px; font-weight: 600;
  display: flex; align-items: center; gap: 4px;
  text-decoration: none;
}
.badge-count { font-weight: 700; }

.user-info { display: flex; align-items: center; gap: 8px; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--secondary); color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
}
.user-name { font-weight: 600; font-size: 14px; }
.badge-role {
  background: var(--accent); color: white;
  font-size: 11px; padding: 2px 8px; border-radius: 12px;
}

/* --- Page content --- */
.page-content { padding: 24px; flex: 1; }

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-header h2 { font-size: 22px; margin: 0; }

/* --- Footer --- */
.app-footer {
  text-align: center; padding: 16px;
  color: var(--text-muted); font-size: 12px;
  border-top: 1px solid var(--border);
  margin-left: var(--sidebar-w);
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 20px;
}

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 15px;
}

.card-header h3 { margin: 0; font-size: 15px; }

.card-body { padding: 20px; }
.card-body.p-0 { padding: 0; }

.card-footer-link {
  text-align: center; padding: 12px;
  border-top: 1px solid var(--border);
  font-size: 13px;
}

/* --- Stat cards --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 20px;
  display: flex; align-items: center; gap: 16px;
  transition: var(--transition);
}

.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-card-urgent { border-left: 4px solid var(--danger); }

.stat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}
.stat-icon-blue   { background: #ebf3ff; }
.stat-icon-red    { background: #fef0f0; }
.stat-icon-green  { background: #edfaf3; }
.stat-icon-orange { background: #fef6ed; }
.stat-icon-done   { background: #f0fdf4; }

.stat-number { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-label  { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ============================================================
   TABLEAU
   ============================================================ */
.table-responsive { overflow-x: auto; }

.table-custom {
  width: 100%; border-collapse: collapse; font-size: 13.5px;
}

.table-custom thead th {
  background: #f7f8fa;
  padding: 10px 14px;
  text-align: left; font-weight: 600;
  border-bottom: 2px solid var(--border);
  white-space: nowrap; color: var(--text-muted);
  font-size: 12px; text-transform: uppercase; letter-spacing: .4px;
}

.table-custom tbody tr { border-bottom: 1px solid var(--border); transition: background .15s; }
.table-custom tbody tr:hover { background: #f9fafb; }
.table-custom tbody tr:last-child { border-bottom: none; }
.table-custom td { padding: 11px 14px; vertical-align: middle; }

.actions-cell { white-space: nowrap; }

/* ============================================================
   BADGES & STATUTS
   ============================================================ */
.badge-statut {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}

.badge-info     { background: #ebf5fb; color: #2980b9; }
.badge-warning  { background: #fef9e7; color: #d68910; }
.badge-orange   { background: #fef0e6; color: #ca6f1e; }
.badge-success  { background: #eafaf1; color: #1e8449; }
.badge-primary  { background: #eaf0fb; color: #1a5276; }
.badge-done     { background: #d5f5e3; color: #1d6a39; }
.badge-danger   { background: #fdedec; color: #922b21; }
.badge-secondary{ background: #f2f3f4; color: #7f8c8d; }

.badge-source {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; margin-left: 6px;
}
.badge-source.email  { background: #ebf5fb; color: #2980b9; }
.badge-source.manuel { background: #f2f3f4; color: #7f8c8d; }

/* ============================================================
   FORMULAIRES
   ============================================================ */
.form-control {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; color: var(--text);
  background: var(--white);
  transition: border-color .2s, box-shadow .2s;
  outline: none;
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(74,144,217,.15);
}

select.form-control { cursor: pointer; }

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

.form-group { margin-bottom: 16px; }
.form-group.flex-grow { flex: 1; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.form-row {
  display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap;
}

.form-actions {
  display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap;
}

.required { color: var(--danger); }

/* Filtres */
.filters-card .card-body { padding: 16px 20px; }
.filters-form .filter-row {
  display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap;
}
.form-group-btn { display: flex; gap: 8px; align-items: flex-end; }

/* ============================================================
   BOUTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--radius);
  font-size: 14px; font-weight: 600; cursor: pointer;
  border: 1.5px solid transparent;
  transition: var(--transition); white-space: nowrap;
  text-decoration: none; line-height: 1;
}
.btn:hover { text-decoration: none; }

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

.btn-success   { background: var(--success);   color: white; border-color: var(--success); }
.btn-success:hover { background: #1e8449; }

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

.btn-warning   { background: var(--warning);   color: white; border-color: var(--warning); }
.btn-warning:hover { background: #d68910; }

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

.btn-sm  { padding: 6px 13px; font-size: 13px; }
.btn-xs  { padding: 4px 9px;  font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }

/* ============================================================
   ALERTES
   ============================================================ */
.alert {
  padding: 12px 16px; border-radius: var(--radius);
  margin-bottom: 16px; font-size: 14px; font-weight: 500;
  display: flex; align-items: center; gap: 8px;
  border: 1px solid transparent;
}
.alert-success { background: #eafaf1; color: #1e8449; border-color: #a9dfbf; }
.alert-error   { background: #fdedec; color: #922b21; border-color: #f5b7b1; }
.alert-warning { background: #fef9e7; color: #7d6608; border-color: #f9e79f; }
.alert-info    { background: #ebf5fb; color: #1a5276; border-color: #aed6f1; }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination-wrapper { padding: 12px 20px; }
.pagination { display: flex; list-style: none; margin: 0; padding: 0; gap: 4px; flex-wrap: wrap; }
.page-item .page-link {
  display: inline-block; padding: 6px 12px; border-radius: 6px;
  border: 1px solid var(--border); color: var(--text);
  font-size: 13px; transition: var(--transition); text-decoration: none;
}
.page-item .page-link:hover { background: var(--bg); border-color: var(--accent); color: var(--accent); }
.page-item.active .page-link { background: var(--primary); color: white; border-color: var(--primary); }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center; padding: 48px 20px; color: var(--text-muted);
}
.empty-state p { font-size: 15px; margin-bottom: 16px; }

/* ============================================================
   TIMELINE (historique)
   ============================================================ */
.timeline { position: relative; padding-left: 24px; }
.timeline::before {
  content: ''; position: absolute; left: 8px; top: 0; bottom: 0;
  width: 2px; background: var(--border);
}
.timeline-item { position: relative; margin-bottom: 20px; }
.timeline-dot {
  position: absolute; left: -20px; top: 4px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); border: 2px solid white;
  box-shadow: 0 0 0 2px var(--accent);
}
.timeline-action { font-weight: 600; font-size: 14px; color: var(--text); }
.timeline-comment {
  font-size: 13px; color: var(--text-muted); margin-top: 4px;
  background: #f7f8fa; padding: 8px 12px; border-radius: 6px;
  border-left: 3px solid var(--accent);
}
.timeline-meta { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ============================================================
   TICKET DETAIL LAYOUT
   ============================================================ */
.ticket-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  align-items: start;
}

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

.info-item label { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.info-item span  { font-size: 14px; font-weight: 500; display: block; margin-top: 2px; }
.info-item small { color: var(--text-muted); font-size: 12px; }

.description-block { margin-top: 16px; }
.description-block label { font-size: 12px; text-transform: uppercase; color: var(--text-muted); letter-spacing: .5px; }
.description-content {
  background: #f7f8fa; padding: 12px; border-radius: 6px;
  font-size: 14px; line-height: 1.6; margin-top: 6px;
  border-left: 3px solid var(--accent);
}
.email-original {
  background: #f7f8fa; padding: 12px; border-radius: 6px;
  font-size: 13px; color: var(--text-muted); margin-top: 6px;
  white-space: pre-wrap; font-family: monospace;
}

.inline-form .form-row { flex-wrap: nowrap; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 20px; }

/* ============================================================
   PAGE LOGIN
   ============================================================ */
.login-body {
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
}

.login-wrapper {
  width: 100%; max-width: 420px; padding: 20px;
}

.login-card {
  background: var(--white);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
  padding: 40px 36px;
}

.login-header { text-align: center; margin-bottom: 28px; }
.login-logo { font-size: 48px; margin-bottom: 8px; }
.login-title { font-size: 24px; font-weight: 700; color: var(--primary); margin: 0; }
.login-subtitle { color: var(--text-muted); font-size: 14px; margin: 4px 0 0; }

.login-form .btn-block { margin-top: 8px; padding: 12px; font-size: 15px; }

/* ============================================================
   MAKE INTEGRATION PAGE
   ============================================================ */
.make-integration .code-block {
  background: #1e2a3a; color: #a8d8b9;
  padding: 14px 18px; border-radius: 8px;
  font-family: 'Courier New', monospace; font-size: 13px;
  overflow-x: auto; position: relative;
}

.make-step {
  display: flex; gap: 16px; align-items: flex-start;
  padding: 14px 0; border-bottom: 1px solid var(--border);
}
.make-step:last-child { border-bottom: none; }
.step-number {
  min-width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary); color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; margin-top: 1px;
}
.step-content h4 { margin: 0 0 4px; font-size: 14px; }
.step-content p  { margin: 0; color: var(--text-muted); font-size: 13px; }

.api-key-display {
  background: #f7f8fa; border: 1px solid var(--border);
  border-radius: 8px; padding: 12px 16px;
  font-family: monospace; font-size: 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  word-break: break-all;
}

.webhook-log-table { font-size: 12px; }
.webhook-log-table td { padding: 8px 12px; }

/* ============================================================
   ADMIN SETTINGS
   ============================================================ */
.settings-section { margin-bottom: 32px; }
.settings-section h3 { font-size: 16px; margin-bottom: 16px; padding-bottom: 8px; border-bottom: 2px solid var(--border); }

/* ============================================================
   IMPORT PAGE
   ============================================================ */
.import-preview table { font-size: 13px; }
.import-stats { display: flex; gap: 16px; flex-wrap: wrap; margin: 16px 0; }
.import-stat-box {
  flex: 1; min-width: 120px; padding: 14px; border-radius: 8px; text-align: center;
}
.import-stat-box.success { background: #eafaf1; color: #1e8449; }
.import-stat-box.error   { background: #fdedec; color: #922b21; }
.import-stat-box.warning { background: #fef9e7; color: #7d6608; }
.import-stat-num { font-size: 28px; font-weight: 700; }
.import-stat-lbl { font-size: 12px; }

/* ============================================================
   MODAL DE CONFIRMATION
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 2000; display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal-box {
  background: white; border-radius: 12px; padding: 28px 32px;
  max-width: 400px; width: 90%; text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
  transform: scale(.95); transition: transform .2s;
}
.modal-overlay.active .modal-box { transform: scale(1); }
.modal-box h3 { margin: 0 0 8px; }
.modal-box p  { color: var(--text-muted); margin: 0 0 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: center; }

/* Sidebar overlay mobile */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 999;
}

/* Utilitaires */
.text-muted  { color: var(--text-muted); }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.flex-grow   { flex: 1; }

/* ============================================================
   RESPONSIVE — Mobile
   ============================================================ */
@media (max-width: 900px) {
  .ticket-layout { grid-template-columns: 1fr; }
  .ticket-sidebar { order: -1; }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-w)));
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay.active { display: block; }

  .main-content  { margin-left: 0; }
  .app-footer    { margin-left: 0; }
  .hamburger     { display: flex; }
  .page-content  { padding: 16px; }

  .stats-grid    { grid-template-columns: repeat(2, 1fr); }
  .form-grid     { grid-template-columns: 1fr; }
  .filter-row    { flex-direction: column; }

  .table-custom thead th,
  .table-custom td { padding: 8px 10px; }

  .login-card    { padding: 28px 24px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
}
