/* ============================================
   Dashboard aria-if-rh — v2.0
   INITIAFOOD branding : magenta #A61740 + lime #A3C41B
   Aligné sur aria-if-dsi : sidebar, vues séparées, modale complète
   ============================================ */

:root {
  --magenta: #A61740;
  --lime: #A3C41B;
  --black: #000000;
  --bg-0: #0a0a0a;
  --bg-1: #111113;
  --bg-2: #18181c;
  --bg-3: #222226;
  --text-0: #f5f5f7;
  --text-1: #d0d0d8;
  --text-2: #a0a0a8;
  --text-3: #6b6b75;
  --border: #2a2a2e;
  --radius: 10px;
  --shadow: 0 4px 12px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; }

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

button { font-family: inherit; cursor: pointer; }
input, select, textarea {
  font-family: inherit;
  background: var(--bg-2);
  color: var(--text-0);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--magenta);
}

.hidden { display: none !important; }
.muted { color: var(--text-2); font-size: 12px; }

/* ============================================
   LOGIN VIEW
   ============================================ */
.view-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 30% 30%, rgba(166,23,64,0.08) 0%, transparent 50%),
    radial-gradient(circle at 70% 70%, rgba(163,196,27,0.08) 0%, transparent 50%),
    var(--bg-0);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 32px;
  box-shadow: var(--shadow);
}

.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 24px;
}
.brand-logo-login {
  max-width: 240px;
  width: 100%;
  height: auto;
  margin-bottom: 8px;
}
.login-tagline {
  color: var(--text-2);
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-style: italic;
}
.login-title {
  margin: 8px 0 4px;
  text-align: center;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -0.5px;
  color: var(--text-0);
}
.login-subtitle {
  margin: 0 0 24px;
  text-align: center;
  color: var(--text-2);
  font-size: 13px;
}

.login-form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: 11px;
  color: var(--text-2);
  letter-spacing: 1px;
  text-transform: uppercase;
  font-weight: 600;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 8px;
  border: none;
  font-weight: 600;
  font-size: 13px;
  transition: all 0.15s ease;
}
.btn-primary { background: var(--magenta); color: white; }
.btn-primary:hover { background: #c81d4a; transform: translateY(-1px); }
.btn-secondary { background: var(--bg-3); color: var(--text-0); }
.btn-secondary:hover { background: #2d2d33; }
.btn-ghost { background: transparent; color: var(--text-1); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-2); border-color: var(--text-3); }
.btn-success { background: var(--lime); color: var(--bg-0); }
.btn-success:hover { background: #b8d620; }
.btn-danger { background: #6b2020; color: white; }
.btn-danger:hover { background: #8a2828; }
.btn-block { width: 100%; justify-content: center; }

.login-error {
  background: rgba(166,23,64,0.15);
  color: #ff8aab;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  border: 1px solid rgba(166,23,64,0.3);
}

.login-success {
  background: rgba(163,196,27,0.12);
  color: #c5e36e;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  border: 1px solid rgba(163,196,27,0.35);
}

/* ============ Modale change-password ============ */
.modal-password {
  max-width: 460px;
}

.modal-intro {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--text-dim, #9ca3af);
  line-height: 1.5;
}

.field-hint {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-dim, #6b7280);
  font-weight: normal;
}

.login-footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot-pink { background: var(--magenta); }
.dot-lime { background: var(--lime); }
.footer-text { color: var(--text-2); font-size: 11px; letter-spacing: 1px; }

/* ============================================
   APP LAYOUT : header + sidebar + content
   ============================================ */
.view-app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.app-header-left { display: flex; align-items: center; gap: 16px; }
.app-logo { height: 36px; width: auto; }
.app-header-divider { width: 1px; height: 24px; background: var(--border); }
.app-header-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: 0.5px;
}
.app-header-right { display: flex; align-items: center; gap: 12px; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 4px;
  background: var(--bg-2);
  border-radius: 100px;
  border: 1px solid var(--border);
}
.user-chip-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--magenta);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
}
.user-chip-name { font-size: 13px; font-weight: 600; }

.app-main {
  display: grid;
  grid-template-columns: 220px 1fr;
  flex: 1;
}

/* Sidebar */
.sidebar {
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 6px;
  background: transparent;
  color: var(--text-1);
  border: none;
  text-align: left;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s ease;
}
.sidebar-link:hover { background: var(--bg-2); color: var(--text-0); }
.sidebar-link.active {
  background: var(--magenta);
  color: white;
}
.sidebar-link.active svg { stroke: white; }

.sidebar-footer { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
.sidebar-link-mini {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  text-decoration: none;
  font-size: 12px;
}
.sidebar-link-mini:hover { color: var(--text-0); background: var(--bg-2); }

/* Content */
.content {
  padding: 24px;
  overflow-y: auto;
  max-width: 100%;
}
.view-header { margin-bottom: 24px; }
.view-header h2 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.3px;
}
.view-subtitle {
  margin: 0;
  color: var(--text-2);
  font-size: 13px;
}

/* ============================================
   DASHBOARD VIEW
   ============================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent-color, transparent);
  opacity: 0.05;
}
.kpi-open    { --accent-color: #A61740; }
.kpi-progress { --accent-color: #fb923c; }
.kpi-waiting { --accent-color: #fbbf24; }
.kpi-resolved { --accent-color: #A3C41B; }
.kpi-closed  { --accent-color: #808080; }
.kpi-total   { --accent-color: #3b82f6; }

.kpi-value {
  font-size: 32px;
  font-weight: 900;
  line-height: 1;
  margin-bottom: 4px;
  position: relative;
}
.kpi-label {
  font-size: 11px;
  color: var(--text-2);
  letter-spacing: 1px;
  text-transform: uppercase;
  font-weight: 600;
  position: relative;
}

.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
.chart-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.chart-card h3 {
  margin: 0 0 16px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-0);
}
.chart-card h3 .muted { font-weight: 400; }

.bar-list { display: flex; flex-direction: column; gap: 10px; }
.bar-row {
  display: grid;
  grid-template-columns: 100px 1fr 30px;
  align-items: center;
  gap: 10px;
}
.bar-label { font-size: 12px; color: var(--text-1); }
.bar-track {
  height: 8px;
  background: var(--bg-3);
  border-radius: 4px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}
.bar-count {
  text-align: right;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-0);
}

.recent-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.recent-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.recent-header h3 { margin: 0; font-size: 14px; font-weight: 700; }
.btn-link {
  background: transparent;
  border: none;
  color: var(--lime);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

/* ============================================
   TASK ROW (réutilisé partout)
   ============================================ */
.task-list { display: flex; flex-direction: column; gap: 8px; }

.task-row {
  display: flex;
  align-items: stretch;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.15s ease;
}
.task-row:hover {
  border-color: var(--text-3);
  transform: translateX(2px);
}
.task-row.overdue { border-color: #fb923c; }
.task-priority-strip {
  width: 4px;
  flex-shrink: 0;
}
.task-main { padding: 14px 16px; flex: 1; }
.task-title-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.task-icon { font-size: 16px; }
.task-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-0);
}
.badge-overdue {
  background: rgba(251,146,60,0.2);
  color: #fb923c;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--text-2);
}
.meta-tag {
  background: var(--bg-3);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-1);
}

/* ============================================
   TICKETS VIEW : Filters
   ============================================ */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  background: var(--bg-1);
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.filters input { flex: 1; min-width: 200px; }
.filters select { min-width: 140px; }

/* ============================================
   NEW TASK FORM
   ============================================ */
.form-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 700px;
}
.form-card .row { display: flex; gap: 12px; }
.form-card .col { flex: 1; }
.form-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ============================================
   MODAL TASK DETAIL
   ============================================ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-content {
  background: var(--bg-1);
  border-radius: 12px;
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
}
.modal-header {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}
.modal-header-left { display: flex; gap: 8px; align-items: center; }
.modal-category {
  background: var(--bg-3);
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
}
.modal-priority {
  font-size: 11px;
  font-weight: 700;
}
.modal-status {
  padding: 4px 10px;
  border-radius: 100px;
  color: white;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.modal-close {
  background: transparent;
  border: none;
  color: var(--text-2);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  padding: 0 8px;
}
.modal-close:hover { color: var(--text-0); }

.modal-body { padding: 20px; overflow-y: auto; }
.modal-body h2 {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.3px;
}
.modal-body h3 {
  margin: 24px 0 12px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-2);
}
.mt-description {
  background: var(--bg-2);
  padding: 12px 14px;
  border-radius: 8px;
  white-space: pre-wrap;
  color: var(--text-1);
  font-size: 13px;
  line-height: 1.6;
}

.mt-edit {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-2);
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 16px;
}

.status-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.status-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 100px;
  background: var(--bg-3);
  color: var(--text-1);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  transition: all 0.15s ease;
}
.status-btn:hover:not(:disabled) {
  background: var(--bg-2);
  border-color: var(--text-3);
  color: var(--text-0);
}
.status-btn.active {
  background: var(--magenta);
  color: white;
  border-color: var(--magenta);
}
.status-btn:disabled { cursor: default; opacity: 0.8; }
.status-btn .dot {
  width: 8px; height: 8px; border-radius: 50%;
}

.mt-validate, .mt-delete {
  background: var(--bg-2);
  padding: 12px;
  border-radius: 8px;
  display: flex;
  gap: 8px;
  align-items: center;
}
.mt-validate h3, .mt-delete h3 { margin: 0 0 8px; flex: 1; }
.mt-validate { flex-direction: row; flex-wrap: wrap; }
.mt-delete { flex-direction: column; align-items: stretch; }

.timeline {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}
.timeline-item {
  display: flex;
  gap: 12px;
}
.timeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}
.timeline-content { flex: 1; }
.timeline-header {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: baseline;
  font-size: 13px;
  margin-bottom: 4px;
}
.timeline-change {
  font-size: 12px;
  color: var(--text-1);
  background: var(--bg-3);
  padding: 2px 8px;
  border-radius: 4px;
  margin-top: 4px;
  display: inline-block;
}
.timeline-note {
  background: var(--bg-2);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  white-space: pre-wrap;
  color: var(--text-1);
  margin-top: 4px;
}

.mt-comment { display: flex; flex-direction: column; gap: 8px; }
.mt-comment textarea { resize: vertical; min-height: 60px; }
.mt-comment .btn { align-self: flex-start; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .charts-row { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .app-main { grid-template-columns: 1fr; }
  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 8px;
    flex-direction: row;
    overflow-x: auto;
  }
  .sidebar-nav { flex-direction: row; }
  .sidebar-footer { display: none; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .form-card .row { flex-direction: column; }
}