/* =============================== TOKENS + GLOBAL ================================ */
:root{
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --muted-2: #374151;
  --border: #e5e7eb;

  --blue: #2563eb;
  --blue-700:#1d4ed8;

  --red: #dc2626;
  --red-700:#b91c1c;

  --amber:#fbbf24;
  --amber-600:#f59e0b;

  --shadow: 0 10px 22px rgba(0,0,0,0.05);
  --shadow-strong: 0 22px 60px rgba(0,0,0,0.25);

  --r10: 10px;
  --r12: 12px;
  --r16: 16px;
  --r18: 18px;
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; }

body{
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);

  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main{
  flex: 1;
  padding: 22px 16px 40px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.content-container{ width: 100%; }

/* =============================== TOPBAR ================================ */
.topbar{
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.topbar-inner{
  max-width: 1400px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* Left */
.brand{
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 240px;
}

.brand-logo{
  width: 50px;
  height: 50px;
  object-fit: contain;
}

.brand-name{
  font-size: 15px;
  font-weight: 700;
}

/* Center nav */
.topbar-center{
  display: flex;
  gap: 10px;
  justify-content: center;
  flex: 1;
}

.btn-nav{
  padding: 8px 14px;
  border-radius: 10px;
  background: var(--border);
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.2s;
  white-space: nowrap;
}

.btn-nav:hover{ background: #d1d5db; }

.btn-nav.active{
  background: var(--blue);
  color: var(--card);
}

/* MyWeek: blue-ish (even when not active) */
.btn-nav.btn-myweek{
  background: rgba(37, 99, 235, 0.12);
  color: var(--blue-700);
  border: 1px solid rgba(37, 99, 235, 0.25);
}

.btn-nav.btn-myweek:hover{ background: rgba(37, 99, 235, 0.18); }

.btn-nav.btn-myweek.active{
  background: var(--blue);
  color: var(--card);
  border-color: var(--blue);
}

/* Right */
.topbar-right{
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  min-width: 240px;
}

.user-display{
  font-size: 13px;
  font-weight: 600;
  color: var(--muted-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.logout-inline{ margin: 0; }

/* Icon buttons (Create / Settings) */
.btn-create,
.btn-settings{
  width: 38px;
  height: 38px;
  border-radius: var(--r12);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  user-select: none;
  border: 1px solid transparent;
  box-shadow: 0 10px 22px rgba(0,0,0,0.06);
  transition: filter 0.2s, transform 0.15s, box-shadow 0.2s;
}

.btn-create{
  background: var(--red);
  color: var(--card);
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
  border-color: var(--red-700);
}

.btn-create:hover{ filter: brightness(0.95); transform: scale(1.06); }
.btn-create:active{ transform: scale(0.98); }

.btn-settings{
  background: var(--amber);
  color: var(--text);
  font-size: 18px;
  font-weight: 900;
  border-color: var(--amber-600);
}

.btn-settings:hover{ filter: brightness(0.97); transform: rotate(18deg); }
.btn-settings:active{ transform: rotate(18deg) scale(0.98); }

.btn-create:focus,
.btn-settings:focus{ outline: none; }

.btn-create:focus-visible{
  box-shadow: 0 0 0 3px rgba(220,38,38,0.35), 0 10px 22px rgba(0,0,0,0.06);
}

.btn-settings:focus-visible{
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.35), 0 10px 22px rgba(0,0,0,0.06);
}

/* Logout */
.btn-logout{
  padding: 8px 14px;
  border-radius: 10px;
  border: none;
  background: var(--red);
  color: var(--card);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.2s;
  white-space: nowrap;
}

.btn-logout:hover{ filter: brightness(0.95); }

/* =============================== FOOTER ================================ */
.footerbar{
  text-align: center;
  padding: 16px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: var(--card);
}

/* =============================== DASH HEADER (Today/MyWeek) ================================ */
.dash-topbar{
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 12px;
}

.dash-title{
  font-size: 18px;
  font-weight: 800;
}

/* =============================== SHARED BUTTONS (Week/Month headers) ================================ */
.btn-week{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 12px;
  border-radius: var(--r12);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(0,0,0,0.06);
  user-select: none;
}

.btn-week:hover{ background: var(--bg); }

.btn-week-ghost{
  font-weight: 800;
  box-shadow: none;
  background: #f9fafb;
}

.btn-round{
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 900;
  box-shadow: 0 10px 22px rgba(0,0,0,0.06);
  user-select: none;
}

.btn-round:hover{ background: var(--bg); }

/* =============================== WEEK HEADER ================================ */
.week-header{
  display: grid;
  grid-template-columns: 90px 1fr 160px;
  align-items: center;
  gap: 12px;
  margin: 8px 0 12px;
  padding: 0 2px;
}

.week-left,
.week-right{
  display: flex;
  align-items: center;
  gap: 10px;
}

.week-left{ justify-content: flex-start; }
.week-right{ justify-content: flex-end; }
.week-mid{ text-align: center; }

.week-title{
  font-size: 18px;
  font-weight: 700;
}

.week-range{
  margin-top: 2px;
  font-size: 13px;
  color: var(--muted);
}

/* =============================== WEEK GRID ================================ */
.week-grid-wrap{
  background: transparent;
  border-radius: var(--r16);
  box-shadow: var(--shadow);
  overflow-x: auto;               /* ✅ NEW: avoid squeezed columns */
  -webkit-overflow-scrolling: touch;
}

.week-grid-clip{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r16);
  overflow: visible;
  clip-path: inset(0 round 16px);
  position: relative;
  z-index: 1;
  min-width: 980px;               /* ✅ NEW: keep columns readable */
}

.week-grid{
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  overflow: visible;
  position: relative;
  z-index: 1;
}

.week-grid thead th{
  background: #f9fafb;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 10px 10px;
  text-align: left;
  vertical-align: top;
}

.week-grid thead th:last-child{ border-right: none; }

.day-name{
  font-size: 13px;
  font-weight: 800;
}

.day-date{
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}

.week-grid td{
  border-right: 1px solid var(--border);
  vertical-align: top;
  position: relative;
  z-index: 1;
  overflow: visible;
}

.week-grid td:last-child{ border-right: none; }

.day-cell{
  min-height: 520px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  z-index: 1;
  overflow: visible;
}

.day-cell-compact{ gap: 8px; }

.is-today{ background: rgba(37, 99, 235, 0.06); }

.week-grid thead th.is-today{
  background: rgba(37, 99, 235, 0.10);
}

.empty-hint{
  font-size: 12px;
  color: var(--muted);
  padding: 6px 2px;
}

/* =============================== COMPACT TEAM BLOCKS + EVENTS ================================ */
.team-block{
  border-top: 1px dashed var(--border);
  padding-top: 6px;
}

.team-block:first-child{
  border-top: none;
  padding-top: 0;
}

/* ===============================
   TEAM LINE + EFFECTIF BADGES
================================ */
.team-line{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: nowrap;              /* ✅ NEW: keep it on one line */
  font-size: 13px;
  font-weight: 900;
}

.team-line > .team-name{
  min-width: 0;
  overflow: hidden;               /* ✅ NEW: truncate team name if needed */
  text-overflow: ellipsis;
  white-space: nowrap;
}

.eff-badges{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  white-space: nowrap;
}

.eff-badge{
  position: relative;             /* ✅ needed for hover tooltip */
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  color: #374151;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  cursor: help;
}

.eff-badge b{ font-weight: 900; }

.eff-p{ border-color: rgba(16,185,129,.35); background: rgba(16,185,129,.10); }
.eff-a{ border-color: rgba(59,130,246,.35); background: rgba(59,130,246,.10); }
.eff-s{ border-color: rgba(239,68,68,.35); background: rgba(239,68,68,.10); }

/* ✅ NEW: nice tooltip on hover (use data-tip="...") */
.eff-badge[data-tip]:hover::after{
  content: attr(data-tip);
  position: absolute;
  top: 115%;
  right: 0;
  background: #111827;
  color: #fff;
  padding: 6px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
  box-shadow: 0 10px 22px rgba(0,0,0,0.2);
  z-index: 9999;
}

.team-items{
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.event-line{
  position: relative;
  font-size: 12px;
  display: flex;
  gap: 6px;
  align-items: center;
  min-width: 0;
  z-index: 1;
}

.event-line.event-click{ cursor: pointer; }
.event-line.event-click:hover{ filter: brightness(0.985); }

.event-line.event-click:focus{ outline: none; }
.event-line.event-click:focus-visible{
  box-shadow: 0 0 0 3px rgba(37,99,235,0.25);
  border-radius: 10px;
}

/* Type badge */
.event-abbr{
  font-weight: 900;
  font-size: 10px;
  padding: 2px 6px;
  line-height: 1.1;
  border-radius: 7px;
  border: 1px solid transparent;
  display: inline-block;
  min-width: 30px;
  text-align: center;
  flex: 0 0 auto;
}

.event-title{
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1 1 auto;
  font-size: clamp(11px, 1.05vw, 12px);
  font-weight: 700;
}

.event-members{
  color: var(--muted);
  font-weight: 800;
  flex: 0 0 auto;
  font-size: 11px;
}

/* =============================== CLICK MODAL (Event Details) ================================ */
.modal-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
  z-index: 2147483647;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal-backdrop.is-open{ display: flex; }

.modal{
  width: min(720px, 96vw);
  max-height: min(78vh, 760px);
  overflow: auto;
  background: var(--card);
  border-radius: var(--r18);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-strong);
}

.modal-header{
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.modal-title{
  font-size: 16px;
  font-weight: 900;
  margin: 0;
  line-height: 1.2;
}

.modal-sub{
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.modal-badge{
  font-weight: 900;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  display: inline-block;
}

.modal-close{
  border: none;
  background: var(--bg);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
}

.modal-close:hover{ background: var(--border); }

.modal-body{ padding: 14px 16px 16px; }

.modal-grid{
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 10px 12px;
  font-size: 13px;
  line-height: 1.35;
}

.modal-k{
  color: var(--muted);
  font-weight: 800;
}

.modal-v{
  color: var(--text);
  font-weight: 650;
  white-space: pre-wrap;
}

/* =============================== MONTH HEADER + GRID ================================ */
.month-header{
  display: grid;
  grid-template-columns: 220px 1fr 90px;
  align-items: center;
  gap: 12px;
  margin: 8px 0 12px;
  padding: 0 2px;
}

.month-left,
.month-right{
  display: flex;
  align-items: center;
  gap: 10px;
}

.month-left{ justify-content: flex-start; }
.month-right{ justify-content: flex-end; }
.month-mid{ text-align: center; }

.month-title{
  font-size: 18px;
  font-weight: 800;
}

.month-sub{
  margin-top: 2px;
  font-size: 13px;
  color: var(--muted);
}

.month-grid-wrap{
  background: transparent;
  border-radius: var(--r16);
  box-shadow: var(--shadow);
  overflow: visible;
}

.month-grid-clip{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r16);
  overflow: hidden;
}

.month-grid{
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.month-grid thead th{
  background: #f9fafb;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 10px 10px;
  text-align: left;
  font-weight: 800;
  font-size: 13px;
}

.month-grid thead th:last-child{ border-right: none; }

.month-grid td{
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  padding: 8px 10px;
}

.month-grid tr:last-child td{ border-bottom: none; }
.month-grid td:last-child{ border-right: none; }

.month-week-col{ width: 90px; }

.month-week-cell{
  background: #f9fafb;
  text-align: left;
  padding: 10px;
}

.month-week-btn{
  height: 34px;
  padding: 0 10px;
  border-radius: var(--r12);
}

.month-day-cell{
  height: 110px;
  background: var(--card);
}

.month-day-cell.is-outside{
  background: #fafafa;
  color: #9ca3af;
}

.month-day-top{
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.month-daynum{
  font-weight: 900;
  font-size: 13px;
}

.month-day-list{
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.month-count{
  font-size: 12px;
  font-weight: 900;
  padding: 6px 8px;
  border-radius: 10px;
  border-left: 3px solid transparent;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.month-day-cell.is-today{
  background: rgba(37, 99, 235, 0.06);
}

/* =============================== SIMPLE CARDS ================================ */
.simple-card{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r16);
  padding: 22px;
  box-shadow: var(--shadow);
  max-width: 520px;
}

.simple-title{
  font-size: 18px;
  font-weight: 800;
}

.simple-subtitle{
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
}

/* =============================== LOGIN PAGE ================================ */
.login-wrap{
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card{
  width: 100%;
  max-width: 520px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r18);
  padding: 34px 32px;
  box-shadow: 0 12px 28px rgba(0,0,0,0.08);
  text-align: center;
}

.login-logo{
  height: 22vh;
  max-height: 220px;
  max-width: 75%;
  width: auto;
  display: block;
  margin: 0 auto 14px;
  object-fit: contain;
}

.login-title{
  font-size: 22px;
  font-weight: 900;
  margin: 0;
}

.login-subtitle{
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 18px;
}

.login-error{
  text-align: left;
  background: #fee2e2;
  border: 1px solid #fca5a5;
  color: #991b1b;
  padding: 12px;
  border-radius: var(--r12);
  margin: 0 0 14px 0;
  font-size: 14px;
  font-weight: 700;
}

.login-form{ text-align: left; }

.login-label{
  display: block;
  font-size: 13px;
  font-weight: 800;
  color: var(--muted-2);
  margin: 12px 0 6px;
}

.login-input{
  width: 100%;
  height: 44px;
  border-radius: var(--r12);
  border: 1px solid #d1d5db;
  background: #f9fafb;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 700;
  outline: none;
  transition: border 0.2s, box-shadow 0.2s, background 0.2s;
}

.login-input:focus{
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
  background: var(--card);
}

.login-button{
  width: 100%;
  height: 44px;
  margin-top: 16px;
  border: none;
  border-radius: var(--r12);
  background: var(--blue);
  color: var(--card);
  font-weight: 900;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s, transform 0.05s;
}

.login-button:hover{ background: #1e4fd8; }
.login-button:active{ transform: scale(0.99); }

/* =============================== ACTION BUTTON ROW (Event page) ================================ */
.action-row{
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.action-row .login-button,
.action-row .btn-week,
.action-row .btn-week-ghost,
.action-row a.btn-week,
.action-row a.btn-week-ghost{
  height: 44px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r12);
  line-height: 1;
  font-size: 14px;
  font-weight: 900;
}

.action-row .login-button{
  width: auto;
  margin-top: 0;
}

.action-row .btn-week,
.action-row .btn-week-ghost{ height: 44px; }

/* ===============================
   WIDE LAYOUT (pages setting $pageWide=true)
   header.php adds: <main class="main main-wide">
================================ */
.main.main-wide{
  max-width: 1400px; /* keeps global max, but enables wide-card overrides */
}

/* IMPORTANT: event.php should use full width, without changing other pages */
.main.main-wide .simple-card{
  max-width: none;
  width: 100%;
}

/* =============================== RESPONSIVE ================================ */
@media (max-width: 900px){
  .topbar-inner{ flex-wrap: wrap; }

  .brand,
  .topbar-right{ min-width: auto; }

  .topbar-center{
    order: 3;
    width: 100%;
  }

  .user-display{ max-width: 160px; }

  .day-cell{ min-height: 420px; }

  .team-items{ gap: 5px; }

  .event-abbr{
    min-width: 26px;
    font-size: 9px;
    padding: 2px 5px;
    border-radius: 6px;
  }

  .week-header{
    grid-template-columns: 1fr;
    text-align: left;
    padding: 0;
  }

  .week-mid{ text-align: left; }
  .week-left{ order: 2; }
  .week-right{ order: 3; justify-content: flex-start; }

  .month-header{
    grid-template-columns: 1fr;
    text-align: left;
    padding: 0;
  }

  .month-mid{ text-align: left; }
  .month-right{ justify-content: flex-start; }

  .month-day-cell{ height: 100px; }
}

@media (max-width: 520px){
  .modal-grid{ grid-template-columns: 1fr; }
  .modal-k{ margin-top: 8px; }

  .month-week-col{ width: 70px; }
  .month-count{ font-size: 11px; }

  .event-line{ gap: 5px; }
  .event-abbr{
    min-width: 24px;
    font-size: 9px;
    padding: 2px 4px;
  }

  .eff-badges{ gap: 4px; }
  .eff-badge{
    height: 18px;
    padding: 0 6px;
    font-size: 10px;
  }

  .login-card{ padding: 28px 20px; }
  .login-logo{ max-height: 180px; }
}
