:root{
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #0f172a;
  --muted: rgba(15, 23, 42, .65);
  --border: rgba(15, 23, 42, .10);
  --shadow: 0 10px 30px rgba(15,23,42,.08);

  --brand: #ff0000;
  --brand2: #ff0000;

  --pill: #ffffff;
  --pillBorder: rgba(15, 23, 42, .12);

  --success: #0ea5e9;
  --ok: #16a34a;
  --warn: #f59e0b;
  --danger: #ef4444;

  --radius: 16px;
  --radius2: 14px;
}

*{ box-sizing: border-box; }
html, body{ height: 100%; }
body{
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a{ color: inherit; }
code{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: .92em;
}

.app{
  min-height: 100vh;
  display: flex;
}

/* ================= Sidebar ================= */
.sidebar{
  width: 280px;
  background: linear-gradient(180deg, var(--brand2), var(--brand));
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 16px 14px;
  gap: 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-top{ display:flex; flex-direction:column; gap:14px; }

.brand{
  display:flex;
  align-items:center;
  gap: 12px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.18);
  padding: 12px;
  border-radius: var(--radius2);
}

.brand-logo{
  width: 100%;
  height: auto;
  display:block;
}

.nav{
  display:flex;
  flex-direction: column;
  gap: 10px;
}

.nav-item{
  display:flex;
  gap: 10px;
  align-items:center;
  padding: 12px 12px;
  border-radius: 14px;
  text-decoration:none;
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.14);
  cursor: pointer;
}
.nav-item:hover{ background: rgba(255,255,255,.16); }
.nav-item.active{
  background: rgba(255,255,255,.22);
  border-color: rgba(255,255,255,.28);
}
.nav-ico{ width: 22px; text-align:center; }
.nav-text{ font-weight: 700; }

.nav-item-expand{ justify-content:flex-start; }
.nav-caret{
  margin-left: auto;
  transition: transform .15s ease;
}
.nav-item-expand.open .nav-caret{ transform: rotate(180deg); }

.nav-submenu{
  display:none;
  flex-direction: column;
  gap: 6px;
  padding: 2px 0 2px 34px;
}
.nav-submenu.open{ display:flex; }
.nav-subitem{
  text-decoration:none;
  color:#fff;
  opacity: .9;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255,255,255,.08);
  font-weight: 700;
  font-size: .9rem;
}
.nav-subitem:hover{ background: rgba(255,255,255,.16); }

.sidebar-bottom{
  margin-top:auto;
  margin-bottom: 20px;
  display:flex;
  flex-direction:column;
  gap: 14px;
}

.sidebar-support{
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: var(--radius2);
  padding: 12px;
}
.sidebar-support-title{
  font-weight: 800;
  margin-bottom: 10px;
}
.sidebar-support-item{
  display:flex;
  align-items:flex-start;
  gap: 10px;
  padding: 8px 0;
}
.sidebar-support-ico{ width: 22px; text-align:center; opacity:.95; }
.sidebar-support-label{ font-size: .85rem; opacity:.85; }
.sidebar-support-value{ font-weight: 700; }

.sidebar-logo{
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 0;
  background: transparent;
  border: none;
}
.sidebar-logo img{
  width: 260px;
  max-width: 100%;
  height: auto;
  display:block;
}

/* ================= Main / Topbar ================= */
.main{
  flex: 1;
  display:flex;
  flex-direction: column;
  min-width: 0;
}

.topbar{
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 14px 18px;
  display:flex;
  align-items:center;
  gap: 14px;
}

.icon-btn{
  display:flex;
  align-items:center;
  justify-content:center;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 12px;
  padding: 9px;
  cursor: pointer;
  color: var(--text);
}
.icon-btn:hover{ background: rgba(15,23,42,.03); }

.icon{
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display:block;
}

#burgerBtn{ display:none; }

.topbar-left h1{
  margin: 0;
  font-size: 1.15rem;
  font-weight: 900;
}
.topbar-left p{
  margin: 3px 0 0;
  color: var(--muted);
  font-size: .92rem;
}

.topbar-right{
  margin-left: auto;
  display:flex;
  align-items:center;
  gap: 10px;
}

.search{
  display:flex;
  align-items:center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  min-width: 360px;
}
.search-ico{ opacity: .7; }
.search input{
  border: none;
  outline: none;
  width: 100%;
  font-size: .95rem;
  color: var(--text);
}

/* ================= Content ================= */
.content{
  padding: 18px;
  width: 100%;
  max-width: none;
}

.section{ display:none; }
.section.active{ display:block; }

.section-head {
  border-bottom: 1px solid rgba(255,255,255,0.05);
  padding-bottom: 0.75rem;
}

.section-head.row{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap: 12px;
}
.section-head h2{
  margin: 0;
  font-size: 1.25rem;
  font-weight: 900;
}
.muted{ color: var(--muted); }

/* ================= Cards / Buttons ================= */
.card{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  min-width: 0;
}

.card-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap: 10px;
}
.card-actions{
  display:flex;
  gap: 8px;
  align-items:center;
  flex-wrap: wrap;
}
.card h3{
  margin: 0;
  font-size: 1.05rem;
  font-weight: 900;
}

.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap: 8px;
  border-radius: 999px;
  padding: 9px 12px;
  border: 1px solid rgba(15,23,42,.14);
  background: #fff;
  color: var(--text);
  text-decoration:none;
  cursor:pointer;
  font-weight: 800;
  font-size: .92rem;
}
.btn:hover{ background: rgba(15,23,42,.03); }
.btn.ghost{
  background: transparent;
}
.btn.small{
  padding: 7px 10px;
  font-size: .90rem;
}

.badge{
  display:inline-flex;
  align-items:center;
  border-radius: 999px;
  padding: 6px 10px;
  font-weight: 900;
  font-size: .80rem;
  border: 1px solid rgba(15,23,42,.12);
  background: rgba(15,23,42,.04);
}
.badge.success{
  border-color: rgba(14,165,233,.25);
  background: rgba(14,165,233,.10);
  color: #075985;
}
.badge.success::before{ content:""; }

.badge.success,
.badge.success *{ color: #075985; }

.badge.success{
  position: relative;
}
.badge.success::before{
  content:"";
  width: 8px; height: 8px;
  border-radius: 99px;
  background: var(--success);
  display:inline-block;
  margin-right: 8px;
}
.badge.success{
  gap: 8px;
}

.badge.success { padding-left: 10px; }

/* API badge success style from JS */
.badge.success,
#apiBadge.success{
  border-color: rgba(22,163,74,.25);
  background: rgba(22,163,74,.10);
  color: #14532d;
}
#apiBadge.success::before{
  content:"";
  width: 8px; height: 8px;
  border-radius: 99px;
  background: var(--ok);
  display:inline-block;
  margin-right: 8px;
}

/* ================= Grid cards (résumé tickets, etc.) ================= */
.home-row{
  display:grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.home-span-3{ grid-column: span 3; }
.home-span-2{ grid-column: span 2; }
.home-span-1{ grid-column: span 1; }

.tickets-summary{ margin-bottom: 14px; }
.stat-value{
  font-size: 2.4rem;
  font-weight: 900;
  line-height: 1;
  margin-top: 8px;
}

/* ================= Tickets (résumé compact) ================= */
.ticket-mini{
  display:block;
  padding: 10px;
  border: 1px solid rgba(15,23,42,.10);
  border-radius: 14px;
  text-decoration:none;
  color:inherit;
  margin-bottom: 10px;
  background: rgba(15,23,42,.015);
}
.ticket-mini:hover{ background: rgba(15,23,42,.03); }
.ticket-mini-top{
  display:flex;
  gap: 10px;
  align-items:flex-start;
  justify-content:space-between;
}
.ticket-mini-title{
  font-weight: 600;
  font-size: .98rem;
  line-height: 1.2;
}
.ticket-mini-meta{ margin-top: 6px; font-size: .92rem; }
.ticket-mini-body{ margin-top: 8px; font-size: .92rem; opacity: .9; }
.ticket-sites{ margin-top: 4px; font-weight: 500; font-style: italic; }

/* Ticket tags */
.tag{
  display:inline-flex;
  align-items:center;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 900;
  font-size: .80rem;
  border: 1px solid rgba(15,23,42,.12);
  background: rgba(15,23,42,.04);
}
.tag.open{ background: rgba(14,165,233,.10); border-color: rgba(14,165,233,.25); color: #075985; }
.tag.in_progress{ background: rgba(245,158,11,.12); border-color: rgba(245,158,11,.30); color: #92400e; }
.tag.closed{ background: rgba(15,23,42,.06); border-color: rgba(15,23,42,.14); color: rgba(15,23,42,.75); }

/* ================= Docs strip + docs grid ================= */
.docs-strip{
  display:flex;
  gap: 10px;
  flex-wrap: wrap;
}
.doc-chip{
  display:block;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(15,23,42,.10);
  background: rgba(15,23,42,.02);
  text-decoration:none;
  min-width: 220px;
}
.doc-chip:hover{ background: rgba(15,23,42,.04); }
.doc-chip-title{ font-weight: 900; }
.doc-chip-sub{ margin-top: 4px; color: var(--muted); font-size: .90rem; }

.docs-grid{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 14px;
}
.doc-card{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  display:flex;
  gap: 12px;
  align-items:flex-start;
}
.doc-ico{
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(15,23,42,.06);
  border: 1px solid rgba(15,23,42,.10);
  color: var(--text);
}
.doc-ico .icon{ width: 20px; height: 20px; }
.doc-title{ font-weight: 900; }
.doc-meta{ margin-top: 4px; color: var(--muted); font-size: .90rem; }

/* ================= Tickets table ================= */
.tickets-toolbar{
  display:flex;
  gap: 12px;
  align-items:center;
  margin: 12px 0;
  flex-wrap: wrap;
}
.tickets-search{ min-width: 520px; }

.select{
  border: 1px solid rgba(15,23,42,.12);
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 800;
  color: var(--text);
}

.tickets-table{
  border: 1px solid rgba(15,23,42,.10);
  border-radius: var(--radius);
  overflow:hidden;
  background:#fff;
}
.table-row{
  display:grid;
  grid-template-columns: 150px 1fr 220px 120px;
  gap: 0;
  border-bottom: 1px solid rgba(15,23,42,.08);
  padding: 12px;
  text-decoration:none;
  color: inherit;
}
.table-row:hover{ background: rgba(15,23,42,.02); }
.table-row.head{
  background: rgba(15,23,42,.03);
  font-weight: 900;
}
.table-cell{ padding: 2px 8px; }
.table-title{ font-weight: 600; }
.table-sites{ margin-top: 4px; font-weight: 500; font-style: italic; }
.table-sub{ margin-top: 6px; color: var(--muted); font-size: .92rem; }

.table-pill{
  display:inline-flex;
  align-items:center;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 900;
  font-size: .82rem;
  border: 1px solid rgba(15,23,42,.12);
  background: rgba(15,23,42,.04);
}
.table-pill.open{ background: rgba(14,165,233,.10); border-color: rgba(14,165,233,.25); color: #075985; }
.table-pill.in_progress{ background: rgba(245,158,11,.12); border-color: rgba(245,158,11,.30); color: #92400e; }
.table-pill.closed{ background: rgba(15,23,42,.06); border-color: rgba(15,23,42,.14); color: rgba(15,23,42,.75); }

.tickets-footer{
  display:flex;
  align-items:center;
  justify-content:center;
  gap: 10px;
  margin-top: 12px;
}

/* ================= Overlay ================= */
.loading-overlay{
  position: fixed;
  inset: 0;
  display:none;
  align-items:center;
  justify-content:center;
  background: rgba(255,255,255,.6);
  backdrop-filter: blur(6px);
  z-index: 999;
}
.loading-overlay.show{ display:flex; }

/* ================= Ticket detail modal ================= */
.modal-overlay{
  position: fixed;
  inset: 0;
  display:none;
  align-items:center;
  justify-content:center;
  background: rgba(15,23,42,.45);
  backdrop-filter: blur(3px);
  z-index: 1000;
  padding: 24px;
}
.modal-overlay.show{ display:flex; }

.modal{
  width: min(960px, 100%);
  height: min(820px, 100%);
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display:flex;
  flex-direction:column;
  overflow:hidden;
}

.modal-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3{ margin:0; font-size: 1rem; }

.modal-body{ flex: 1; min-height:0; }
.modal-body iframe{
  width: 100%;
  height: 100%;
  border: 0;
  display:block;
}

.spinner{
  width: 46px;
  height: 46px;
  border-radius: 999px;
  border: 4px solid rgba(15,23,42,.15);
  border-top-color: var(--brand);
  animation: spin 1s linear infinite;
}
@keyframes spin{ to { transform: rotate(360deg); } }

/* ================= Responsive ================= */
@media (max-width: 1150px){
  .search{ min-width: 240px; }
  .tickets-search{ min-width: 260px; }
  .home-row{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-span-3, .home-span-2, .home-span-1{ grid-column: span 2; }
  .sidebar{ width: 250px; }
}

@media (max-width: 820px){
  #burgerBtn{ display:flex; }

  .sidebar{
    position: fixed;
    left: 0; top: 0; bottom: 0;
    transform: translateX(-105%);
    transition: transform .22s ease;
    z-index: 200;
    overflow-y: auto;
  }
  .sidebar.open{ transform: translateX(0); }
  .search{ display:none; }
  .table-row{ grid-template-columns: 140px 1fr; }
  .table-cell:nth-child(3),
  .table-cell:nth-child(4){ display:none; }
}

@media (max-width: 600px){
  .sidebar{ width: 100vw; }
}
