@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root{
  /* Core palette – Rebel Sporting Arena (paper + ink + rebel red) */
  --bg: #f3f3f3;
  --paper: #ffffff;
  --paper2: rgba(255,255,255,.86);
  --text: #0b0f17;
  --muted: #556070;
  --line: rgba(11,15,23,.14);
  --line2: rgba(11,15,23,.09);
  --shadow: 0 18px 50px rgba(11,15,23,.08);

  --accent: #c61e2e;      /* Rebel red */
  --accent2: #a01421;

  --ok: #166534;
  --bad: #991b1b;
  --warn: #b45309;

  --radius: 14px;
  --radius2: 18px;
  --pad: 16px;

  --btn: #0b0f17;
  --btnText: #ffffff;
}

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

/* Subtle paper grain */
body::before{
  content:"";
  position:fixed;
  inset:0;
  pointer-events:none;
  opacity:.22;
  mix-blend-mode:multiply;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.75' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)' opacity='.38'/%3E%3C/svg%3E");
}

/* APP */
.app{ min-height:100%; display:flex; flex-direction:column; }

/* TOPBAR */
.topbar{
  position:sticky;
  top:0;
  z-index:50;
  background: var(--paper2);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line2);
}

.topbar{
  height:76px;
  padding:0 22px;
  display:flex;
  align-items:center;
  justify-content:space-between;
}

.brand-logo{ display:flex; align-items:center; text-decoration:none; color:inherit; }
.brand-logo-img{
  height:38px;
  width:auto;
  display:block;
}

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

.topbar-loginas{
  font-size:13px;
  color: var(--muted);
  display:flex;
  align-items:center;
  gap:8px;
  white-space:nowrap;
}
.topbar-email{
  color: var(--text);
  font-weight:700;
}

.topbar-user{
  display:flex;
  align-items:center;
  gap:10px;
  padding:8px 10px;
  border-radius: 999px;
  border: 1px solid var(--line2);
  background: rgba(255,255,255,.65);
}

.avatar-circle{
  width:36px;
  height:36px;
  border-radius:999px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:800;
  font-size:12px;
  letter-spacing:.04em;
  color: var(--text);
  background: rgba(11,15,23,.06);
  border: 1px solid rgba(11,15,23,.10);
}

.topbar-user-meta{ line-height:1.05; }
.topbar-name{
  font-weight:800;
  font-size:13px;
  letter-spacing:-.01em;
}
.topbar-logout{
  display:inline-block;
  margin-top:2px;
  font-size:12px;
  color: var(--accent2);
  text-decoration:none;
  font-weight:700;
}
.topbar-logout:hover{ text-decoration:underline; }

/* LAYOUT */
.layout{
  flex:1;
  display:grid;
  grid-template-columns:240px 1fr;
}

/* SIDEBAR */
.sidebar{
  padding:18px 14px;
  border-right:1px solid var(--line2);
  background: rgba(255,255,255,.55);
  display:flex;
  flex-direction:column;
}

.sidebar-title{
  font-weight:900;
  letter-spacing:-.02em;
  font-size:18px;
  margin: 4px 10px 12px;
}

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

.nav-spacer{ flex:1; }

.nav-divider{ border-top:1px solid var(--line2); margin:10px 8px; }

.nav-group{ position:relative; }
.nav-sub{ display:none; padding-left:6px; margin-top:6px; }
.nav-item.sub{ padding-left: 18px; }
.nav-group.open .nav-sub{ display:block; }
.nav-group:hover .nav-sub{ display:block; }
.nav-parent .caret{ margin-left:auto; opacity:.55; }
.nav-group:hover .nav-parent .caret{ opacity:.75; }
.nav-group.open .nav-parent .caret{ transform:rotate(180deg); }

.nav-item{
  position:relative;
  display:flex;
  align-items:center;
  gap:10px;
  padding: 11px 12px 11px 12px;
  border-radius: 10px;
  color: var(--text);
  text-decoration:none;
  font-size:14px;
  font-weight:700;
}

.nav-item svg{ width:18px; height:18px; }

.nav-item:hover{
  background: rgba(11,15,23,.04);
}

.nav-item.active{
  background: var(--text);
  color:#fff;
}
.nav-item.active svg{ stroke:#fff; }

/* Rebel red stripe on active */
.nav-item.active::before{
  content:"";
  position:absolute;
  left:-14px;
  top:6px;
  bottom:6px;
  width:10px;
  border-radius: 6px;
  background: var(--accent);
}

/* CONTENT */
.content{
  padding: 22px 22px 40px;
}

h1{
  margin: 0 0 6px 0;
  font-size: 24px;
  letter-spacing: -.03em;
}

h3{
  margin: 0 0 10px 0;
  font-size: 15px;
  letter-spacing: -.01em;
}

.muted{ color: var(--muted); font-size: 13px; }

/* GRID */
.grid{ display:grid; gap:14px; }
.grid.kpis{ grid-template-columns:repeat(auto-fit,minmax(200px,1fr)); margin:16px 0; }
.grid.two{ grid-template-columns:1fr 1fr; }

@media(max-width:900px){
  .layout{ grid-template-columns:1fr; }
  .sidebar{ border-right:0; border-bottom:1px solid var(--line2); }
  .sidebar-nav{ flex-direction:row; flex-wrap:wrap; }
  .nav-item.active::before{ left:6px; width:8px; }
  .grid.two{ grid-template-columns:1fr; }
  .topbar{ height:auto; padding:10px 14px; }
  .topbar-right{ flex-wrap:wrap; justify-content:flex-end; }
}

/* CARDS */
.card{
  position:relative;
  background: rgba(255,255,255,.78);
  border: 1px solid var(--line2);
  border-radius: var(--radius2);
  box-shadow: var(--shadow);
  padding: var(--pad);
}

/* KPI cards – left accent + icon to the right like the mock */
.card.kpi{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  padding: 14px 16px 14px 22px; /* tighter like concept */
}

.card.kpi::before{
  content:"";
  position:absolute;
  left:10px;
  top:10px;
  bottom:10px;
  width:5px;
  border-radius: 6px;
  background: var(--accent);
}

.kpi i, .kpi svg{ width:22px; height:22px; stroke: var(--muted); flex:0 0 auto; opacity:.9; }
/* New KPI text layout (index.php) */
.kpi-text{ min-width:0; }
.kpi-value{ font-size:32px; font-weight:800; letter-spacing:-.04em; line-height:1; }
.kpi-label{ margin-top:4px; font-size:12.5px; color: var(--muted); font-weight:600; line-height:1.2; }
/* Back-compat (older markup) */
.kpi strong{ display:block; font-size:32px; font-weight:800; letter-spacing:-.04em; line-height:1; }
.kpi span{ display:block; margin-top:4px; font-size:12.5px; color: var(--muted); font-weight:600; line-height:1.2; }

/* NOTICE */
.notice{
  display:flex;
  align-items:center;
  gap:10px;
  padding: 12px 14px;
  border-radius: var(--radius2);
  background: rgba(255,255,255,.78);
  border: 1px solid var(--line2);
}

.notice svg{ width:18px; height:18px; }

.notice.warning{
  border-color: rgba(198,30,46,.28);
  background: rgba(198,30,46,.06);
}

/* LISTS */
.training-item{ display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:8px; }
.list{ padding-left:18px; margin:8px 0; }
.list li{ font-size:13px; color: var(--muted); }

/* TABLE */
.table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
  font-size:13px;
  overflow:hidden;
}

/* Responsive tables (wrap table in .table-wrap) */
.table-wrap{ width:100%; overflow-x:auto; -webkit-overflow-scrolling:touch; }

.table th{
  text-align:left;
  font-weight:800;
  padding:10px 10px;
  border-bottom:1px solid var(--line2);
  color: var(--muted);
  text-transform:none;
}

.table td{
  padding:10px 10px;
  border-bottom:1px solid rgba(11,15,23,.08);
}

.table tr:last-child td{ border-bottom:0; }

/* Training group rows (used in training create form) */
.group-grid{ display:grid; grid-template-columns: 180px 1fr 90px 44px; gap:10px; align-items:center; }
@media (max-width:900px){
  .table-wrap .table{ min-width:720px; }
  .group-grid{ grid-template-columns: 1fr; }
  .group-grid button{ width:100%; }
}

.ok{ color: var(--ok); font-weight:800; }
.bad{ color: var(--bad); font-weight:800; }

/* BUTTONS */
button,
.pill{
  appearance:none;
  border:0;
  border-radius:999px;
  padding:8px 14px;
  font-size:12px;
  font-weight:800;
  background: var(--btn);
  color: var(--btnText);
  cursor:pointer;
}

button:hover,
.pill:hover{ filter: brightness(1.06); }

button.secondary,
.pill.secondary{
  background: rgba(255,255,255,.85);
  color: var(--text);
  border:1px solid var(--line2);
}

.link{
  display:inline-block;
  margin-top:10px;
  font-size:13px;
  color: var(--text);
  text-decoration:none;
  font-weight:800;
}
.link:hover{ text-decoration:underline; }

/* FORMS */
label{
  display:block;
  font-size:12px;
  font-weight:800;
  color: #2b3442;
  margin-bottom:6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea{
  width:100%;
  border:1px solid var(--line2);
  border-radius: 14px;
  padding: 11px 12px;
  font-size:14px;
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: rgba(255,255,255,.85);
  color: var(--text);
  outline:none;
}

textarea{ resize:vertical; min-height:110px; }

input:focus, select:focus, textarea:focus{
  border-color: rgba(198,30,46,.35);
  box-shadow: 0 0 0 4px rgba(198,30,46,.14);
}

.help{ margin-top:6px; font-size:12px; color: var(--muted); }

details{
  border:1px solid var(--line2);
  border-radius: var(--radius2);
  padding:10px 12px;
  background: rgba(255,255,255,.78);
}

details summary{ cursor:pointer; font-weight:800; font-size:13px; }

.pill{ text-decoration:none; }

/* =========================
   Mobile hamburger sidebar
========================= */
.burger{
  display:none;
  align-items:center;
  justify-content:center;
  width:42px;
  height:42px;
  border-radius:14px;
  border:1px solid var(--line2);
  background: rgba(255,255,255,.85);
  cursor:pointer;
  color:#0f172a;
}
.burger svg{ width:18px; height:18px; display:block; stroke:currentColor; }

.sidebar-overlay{
  display:none;
  position:fixed;
  inset:0;
  background: rgba(15,23,42,.35);
  backdrop-filter: blur(2px);
  z-index: 60;
}

.sidebar-footer{
  margin: 14px 0 0;
  padding:12px 14px 14px;
  border-top:1px solid var(--line2);
  color: rgba(15, 23, 42, .55);
  font-size:12px;
  line-height: 1.35;
}
.sidebar-footer .brand{
  color: rgba(15, 23, 42, .75);
  font-weight: 600;
}
.sidebar-footer .brand{ color: rgba(15, 23, 42, .78); font-weight:600; }

.nav-section{
  margin:14px 12px 6px;
  font-size:11px;
  text-transform:uppercase;
  letter-spacing:.08em;
  color: rgba(51,65,85,.55);
}
.nav-sub{ padding-left: 18px; }

.arena-badge{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:7px 10px;
  border-radius:999px;
  border:1px solid var(--line2);
  background: rgba(255,255,255,.78);
  font-size:12px;
  color:#0f172a;
}
.arena-badge .dot{ width:8px; height:8px; border-radius:999px; background: var(--red); }

/* Toast */
#toast-container{
  position:fixed;
  right:16px;
  bottom:16px;
  display:flex;
  flex-direction:column;
  gap:10px;
  z-index: 120;
}
.toast{
  min-width: 220px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(15,23,42,.92);
  color: #fff;
  box-shadow: 0 16px 40px rgba(0,0,0,.25);
  font-size: 13px;
  line-height: 1.35;
}
.toast.ok{ background: rgba(20, 83, 45, .92); }
.toast.warn{ background: rgba(127, 29, 29, .92); }

@media (max-width: 900px){
  .burger{ display:flex; }

  /* turn sidebar into off-canvas */
  .layout{ grid-template-columns: 1fr; }
  .sidebar{
    position:fixed;
    top: 72px; /* below topbar */
    left:0;
    bottom:0;
    width: 280px;
    max-width: 85vw;
    transform: translateX(-105%);
    transition: transform .2s ease;
    z-index: 80;
  }
  body.sidebar-open .sidebar{ transform: translateX(0); }
  body.sidebar-open .sidebar-overlay{ display:block; }

  .content{ padding: 18px 16px 40px; }
  .topbar{ padding: 12px 12px; }
  .topbar-left{ gap:10px; }
  .brand-logo-img{ height: 34px; }

  /* hide long login text on narrow screens */
  .topbar-loginas{ display:none; }

  /* sidebar groups */
  .nav-spacer, .nav-divider{ display:none; }
}
