/* ──────────────────────────────────────────────
   Fantasy Footy — Custom Sidebar Layout
   ────────────────────────────────────────────── */

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

/* ── Design tokens ── */
:root {
  --sidebar-width:      240px;
  --sidebar-bg:         #0f172a;
  --sidebar-text:       #94a3b8;
  --sidebar-hover-bg:   rgba(255,255,255,0.05);
  --sidebar-active:     #38bdf8;
  --sidebar-active-bg:  rgba(56,189,248,0.1);
  --accent:             #38bdf8;
  --accent-dark:        #0284c7;
  --body-bg:            #f1f5f9;
  --surface:            #ffffff;
  --text-primary:       #0f172a;
  --text-secondary:     #64748b;
  --border:             #e2e8f0;
  --radius:             10px;
}

/* ── Base ── */
body,
body * {
  font-family: 'Inter', system-ui, -apple-system, sans-serif !important;
}
body {
  background: var(--body-bg) !important;
}

/* ════════════════════════════════════════════
   SIDEBAR
   ════════════════════════════════════════════ */
#sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.08) transparent;
}

/* Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  height: 58px;
  min-height: 58px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  text-decoration: none;
}
.sidebar-logo-mark {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #38bdf8, #818cf8);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; font-size: 13px;
  flex-shrink: 0;
  overflow: hidden;
}
.sidebar-logo-mark img {
  width: 100%; height: 100%; object-fit: cover;
}
.sidebar-logo-text {
  font-size: 14px;
  font-weight: 700;
  color: #f8fafc;
  letter-spacing: -0.3px;
  white-space: nowrap;
}

/* Section labels */
.sidebar-section-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #475569;
  padding: 16px 18px 4px;
}

/* Nav links */
.sidebar-nav {
  list-style: none;
  margin: 0;
  padding: 0;
}
.sidebar-nav a,
.sidebar-nav button {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 18px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-nav a:hover,
.sidebar-nav button:hover {
  background: var(--sidebar-hover-bg);
  color: #e2e8f0;
}
.sidebar-nav a.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active);
}
.sidebar-nav .bi {
  font-size: 14px;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}

/* League group (name label + sub-links) */
.sidebar-league-name {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  color: #64748b;
  padding: 10px 18px 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-subnav {
  list-style: none;
  margin: 0;
  padding: 0;
}
.sidebar-subnav a {
  padding-left: 34px;
  font-size: 13px;
  font-weight: 400;
}

/* Parent league / cup name links */
.sidebar-nav a.sidebar-league-link {
  font-weight: 600;
  color: #cbd5e1;
}
.sidebar-nav a.sidebar-league-link:hover {
  color: #f1f5f9;
}
.sidebar-nav a.sidebar-league-link.active {
  color: var(--sidebar-active);
  background: var(--sidebar-active-bg);
}

/* Divider */
.sidebar-divider {
  border-color: rgba(255,255,255,0.07);
  margin: 6px 16px;
}

/* Active league badge */
.sidebar-active-badge {
  display: inline-block;
  background: rgba(56,189,248,0.15);
  color: #38bdf8;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 99px;
  margin-left: auto;
  flex-shrink: 0;
}

/* User section */
.sidebar-user {
  margin-top: auto;
  padding: 12px 14px;
  border-top: 1px solid rgba(255,255,255,0.07);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #818cf8, #38bdf8);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}
.sidebar-user-name {
  font-size: 12.5px;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.sidebar-icon-btn {
  color: #475569;
  font-size: 15px;
  flex-shrink: 0;
  text-decoration: none;
  transition: color 0.12s;
}
.sidebar-icon-btn:hover { color: #94a3b8; }

/* ════════════════════════════════════════════
   MAIN CONTENT AREA
   ════════════════════════════════════════════ */
#main {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
#main.no-sidebar {
  margin-left: 0;
}

/* Restyle the container-fluid that each page uses */
#main .container-fluid {
  padding: 28px 32px !important;
  margin-top: 0 !important;
  flex: 1;
}

/* ── Breadcrumb ── */
#main .breadcrumb {
  background: none;
  padding: 0;
  margin-bottom: 20px;
  font-size: 13px;
}
#main .breadcrumb-item + .breadcrumb-item::before {
  color: #cbd5e1;
}
#main .breadcrumb-item a {
  color: var(--accent-dark);
  text-decoration: none;
  font-weight: 500;
}
#main .breadcrumb-item a:hover { text-decoration: underline; }
#main .breadcrumb-item.active { color: var(--text-secondary); font-weight: 500; }

/* ── Alerts ── */
#main .alert {
  border-radius: var(--radius);
  font-size: 13.5px;
  margin-bottom: 20px;
}

/* ── Section headings — fallback for pages without the JS wrapper ── */
#main h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 32px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.2px;
}

/* ════════════════════════════════════════════
   SECTION CARDS  (built by custom.js at runtime)
   ════════════════════════════════════════════ */
.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 20px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.section-header {
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.section-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  background: #f1f5f9;
  color: var(--text-secondary);
}

/* ── Tables ──
   The page views use flat <tr> directly inside <table> — no <thead>/<tbody>.
   JS strips table-sm / table-light / table-striped / table-bordered from every
   table in the content area, then these rules take over.                      */

#main .table {
  font-size: 13.5px;
  margin-bottom: 0;
  /* Reset Bootstrap CSS variables so variant classes don't bleed through */
  --bs-table-bg:            #ffffff;
  --bs-table-color:         var(--text-primary);
  --bs-table-border-color:  #f1f5f9;
  --bs-table-striped-bg:    #ffffff;
  --bs-table-hover-bg:      #f0f9ff;
  --bs-table-accent-bg:     transparent;
}

/* Header cells */
#main .table th {
  font-size: 11px !important;
  font-weight: 700 !important;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary) !important;
  background: #f8fafc !important;
  padding: 10px 16px !important;
  border-top: none !important;
  border-left: none !important;
  border-right: none !important;
  border-bottom: 1px solid var(--border) !important;
  white-space: nowrap;
  box-shadow: none !important;
}

/* Body cells */
#main .table td {
  padding: 13px 16px !important;
  color: var(--text-primary) !important;
  background: #ffffff !important;
  vertical-align: middle;
  border-top: none !important;
  border-left: none !important;
  border-right: none !important;
  border-bottom: 1px solid #f1f5f9 !important;
  box-shadow: none !important;
}

.section-card .table-card {
  margin-bottom: 0px;
  border-radius: 0px;
}

/* Standalone table wrapper — same look as section-card but no header bar */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  margin-bottom: 20px;
}

/* No separator under the last data row inside a card */
.section-card .table tr:last-child td,
.table-card .table tr:last-child td {
  border-bottom: none !important;
}

/* Row hover */
#main .table tr:hover td {
  background: #f0f9ff !important;
}

/* Empty-state paragraph inside a card */
.section-card > p {
  padding: 20px 18px;
  color: var(--text-secondary);
  font-size: 13.5px;
  margin: 0;
}

/* ── Position badges (injected by custom.js) ── */
.pos-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  line-height: 1.3;
}
.pos-badge.pos-FW { background: #fff7ed; color: #ea580c; }
.pos-badge.pos-MF { background: #eff6ff; color: #1d4ed8; }
.pos-badge.pos-DF { background: #f0fdf4; color: #15803d; }
.pos-badge.pos-GK { background: #faf5ff; color: #7c3aed; }

/* ── Action buttons promoted to section header ── */
.section-action {
  margin-left: auto;
}
.section-action .btn {
  font-size: 12.5px !important;
  padding: 5px 14px !important;
  border-radius: 7px !important;
}

/* ── Buttons ── */
#main .btn-primary {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  padding: 7px 18px;
}
#main .btn-primary:hover {
  background: #0369a1;
  border-color: #0369a1;
}
#main .btn-secondary,
#main .btn-outline-secondary {
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  padding: 7px 18px;
}
#main .btn-danger {
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
}

/* ── Forms ── */
#main .form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
#main .form-control,
#main .form-select {
  border-radius: 8px;
  font-size: 13.5px;
  border-color: var(--border);
}
#main .form-control:focus,
#main .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56,189,248,0.15);
}

/* ── DataTables overrides (DataTables 2.x + Bootstrap 5 styling) ── */
#main .dt-length,
#main .dt-search,
#main .dt-info,
#main .dt-paging {
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text-secondary);
}
#main .dt-length select,
#main .dt-search input {
  font-size: 13.5px;
}
#main .dt-paging .page-link {
  border-radius: 6px !important;
  font-size: 13px !important;
}

/* ── Fixture difficulty pills ── */
.fixture {
  border-radius: 6px !important;
  border: none !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  padding: 3px 8px !important;
  min-width: 60px !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
}

/* ════════════════════════════════════════════
   MOBILE — collapse sidebar
   ════════════════════════════════════════════ */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 199;
}
#sidebar-toggle {
  display: none;
  position: fixed;
  top: 14px; left: 14px;
  z-index: 201;
  background: var(--sidebar-bg);
  color: #94a3b8;
  border: none;
  border-radius: 8px;
  width: 36px; height: 36px;
  align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 18px;
}

@media (max-width: 768px) {
  #sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  #sidebar.open {
    transform: translateX(0);
  }
  #sidebar-overlay.open {
    display: block;
  }
  #sidebar-toggle {
    display: flex;
  }
  #main {
    margin-left: 0;
  }
  #main .container-fluid {
    padding: 28px 16px 16px;
  }
}
