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

:root {
  --bg-app: #F8FAFC;
  --sidebar-bg: #FFFFFF;
  --card-bg: #FFFFFF;
  --border-light: #E2E8F0;
  
  --primary-orange: #FF6B35;
  --primary-pink: #FF3366;
  --gradient-orange-pink: linear-gradient(135deg, #FF6B35 0%, #FF3366 100%);
  
  --gradient-hero: linear-gradient(135deg, #FF6B35 0%, #FF3366 50%, #8B5CF6 100%);
  --gradient-card-orange: linear-gradient(135deg, #FFF7ED 0%, #FFEDD5 100%);
  --gradient-card-pink: linear-gradient(135deg, #FDF2F8 0%, #FCE7F3 100%);
  --gradient-card-purple: linear-gradient(135deg, #F3E8FF 0%, #E9D5FF 100%);
  --gradient-card-teal: linear-gradient(135deg, #CCFBF1 0%, #99F6E4 100%);
  --gradient-card-blue: linear-gradient(135deg, #E0F2FE 0%, #BAE6FD 100%);
  
  --text-dark: #0F172A;
  --text-body: #334155;
  --text-muted: #64748B;
  
  --green: #10B981;
  --blue: #2563EB;
  --red: #EF4444;
  --amber: #F59E0B;
  
  --shadow-card: 0 10px 25px -5px rgba(255, 107, 53, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.03);
  --shadow-hover: 0 20px 35px -10px rgba(255, 51, 102, 0.2), 0 10px 15px -5px rgba(0, 0, 0, 0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg-app);
  color: var(--text-body);
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Animations */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulseGlow {
  0% { box-shadow: 0 0 0 0 rgba(255, 107, 53, 0.4); }
  70% { box-shadow: 0 0 0 12px rgba(255, 107, 53, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 107, 53, 0); }
}

.animate-fade-in {
  animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Sidebar Layout */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 270px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-light);
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 24px rgba(0,0,0,0.02);
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  /* With this many sections (Markets/Results/Admin/Sync/Betting etc.) the
     nav list is regularly taller than the viewport — without a scroll here,
     anything past the fold (the isolated Betting section included) is
     completely invisible with no way to reach it. */
  overflow-y: auto;
}

.sidebar-logo {
  font-size: 22px;
  font-weight: 900;
  background: var(--gradient-hero);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 36px;
  display: flex;
  align-items: center;
  gap: 12px;
  letter-spacing: 0.5px;
}

.sidebar-menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  border-radius: 14px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-link:hover {
  background: var(--gradient-card-orange);
  color: var(--primary-orange);
  transform: translateX(6px);
}

.sidebar-link.active {
  background: var(--gradient-hero);
  color: #FFFFFF;
  box-shadow: 0 10px 20px -5px rgba(255, 51, 102, 0.4);
}

.main-content {
  margin-left: 270px;
  flex: 1;
  padding: 32px 40px;
}

.topbar-light {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-light);
}

.topbar-light h1 {
  font-size: 26px;
  font-weight: 900;
  color: var(--text-dark);
  margin: 0;
  letter-spacing: -0.5px;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #FFFFFF;
  padding: 10px 20px;
  border-radius: 40px;
  border: 1px solid var(--border-light);
  box-shadow: 0 4px 14px rgba(0,0,0,0.04);
  font-size: 14px;
  font-weight: 700;
}

/* Laravel-style Premium Vibrant Gradient Stats Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
  margin-bottom: 36px;
}

.stat-card-gradient {
  padding: 24px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-card);
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  overflow: hidden;
}

.stat-card-gradient:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: var(--shadow-hover);
}

.stat-card-orange { background: var(--gradient-card-orange); border-color: #FED7AA; }
.stat-card-pink { background: var(--gradient-card-pink); border-color: #FBCFE8; }
.stat-card-purple { background: var(--gradient-card-purple); border-color: #E9D5FF; }
.stat-card-teal { background: var(--gradient-card-teal); border-color: #99F6E4; }
.stat-card-blue { background: var(--gradient-card-blue); border-color: #BAE6FD; }

.stat-card-gradient .label {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.stat-card-gradient .val {
  font-size: 32px;
  font-weight: 900;
  color: var(--text-dark);
  margin-top: 10px;
  letter-spacing: -0.5px;
}

.card-light {
  background: var(--card-bg);
  border-radius: 24px;
  border: 1px solid var(--border-light);
  padding: 28px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-card);
}

.card-light-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.card-light-header h2 {
  font-size: 20px;
  font-weight: 900;
  color: var(--text-dark);
  margin: 0;
}

/* Action Buttons & Badges */
.btn-vibrant {
  background: var(--gradient-hero);
  color: #FFFFFF;
  font-weight: 800;
  padding: 12px 24px;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  font-size: 13px;
  box-shadow: 0 8px 16px -4px rgba(255, 51, 102, 0.35);
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.btn-vibrant:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px -6px rgba(255, 51, 102, 0.5);
}

.btn-light-secondary {
  background: #F1F5F9;
  color: var(--text-dark);
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 12px;
  border: 1px solid var(--border-light);
  cursor: pointer;
  text-decoration: none;
  font-size: 13px;
  transition: all 0.2s ease;
}

.btn-light-secondary:hover { background: #E2E8F0; }

.btn-danger-light {
  background: #FEE2E2;
  color: var(--red);
  font-weight: 800;
  padding: 8px 14px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s ease;
}

.btn-danger-light:hover { background: #FCA5A5; color: #7F1D1D; }

/* Table Styling */
table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  text-align: left;
  padding: 16px 14px;
  border-bottom: 1px solid var(--border-light);
  font-size: 14px;
}

th {
  color: var(--text-muted);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.8px;
}

.badge-light {
  padding: 6px 14px;
  border-radius: 30px;
  font-size: 11px;
  font-weight: 900;
  display: inline-block;
  letter-spacing: 0.5px;
}

.badge-UPCOMING { background: #E0F2FE; color: var(--blue); }
.badge-OPEN { background: #D1FAE5; color: var(--green); }
.badge-RESULT_DECLARED { background: #FEF3C7; color: var(--amber); }
.badge-CLOSED { background: #FEE2E2; color: var(--red); }
.badge-ACTIVE { background: #D1FAE5; color: var(--green); }
.badge-BLOCKED { background: #FEE2E2; color: var(--red); }
.badge-OFF_TODAY { background: #F1F5F9; color: var(--text-muted); }
.badge-INACTIVE { background: #F1F5F9; color: var(--text-muted); }

.form-field {
  display: block;
  margin-bottom: 16px;
}
.form-field label {
  font-weight: 800;
  display: block;
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 13px;
}
.form-field input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-light);
  font-size: 14px;
}

.info-box-light {
  background: var(--gradient-card-orange);
  border: 1px solid #FED7AA;
  color: var(--primary-orange);
  padding: 16px 20px;
  border-radius: 16px;
  margin-bottom: 24px;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

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

/* Sidebar sections / submenu */
.sidebar-section-label {
  font-size: 10px;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 14px 18px 4px;
}
.sidebar-link.sub {
  padding: 10px 18px 10px 34px;
  font-size: 13px;
  font-weight: 600;
}

/* Collapsible sidebar groups (native <details>/<summary> — no JS needed).
   The group whose page is currently open renders with the `open` attribute
   from the server, so navigating into a section keeps it expanded. */
.sidebar-group {
  margin: 2px 0;
}
.sidebar-group summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  transition: all 0.2s ease;
}
.sidebar-group summary::-webkit-details-marker { display: none; }
.sidebar-group summary:hover {
  background: var(--gradient-card-orange);
  color: var(--primary-orange);
}
.sidebar-group summary .sidebar-group-label {
  display: flex;
  align-items: center;
  gap: 14px;
}
.sidebar-group summary .chevron {
  font-size: 11px;
  transition: transform 0.2s ease;
  opacity: 0.6;
}
.sidebar-group[open] > summary .chevron {
  transform: rotate(90deg);
}
.sidebar-group[open] > summary {
  color: var(--primary-orange);
}
.sidebar-group-body {
  display: flex;
  flex-direction: column;
  padding: 4px 0 4px 0;
}

/* Extra status badges */
.badge-HEALTHY { background: #D1FAE5; color: var(--green); }
.badge-WARNING { background: #FEF3C7; color: var(--amber); }
.badge-ERROR { background: #FEE2E2; color: var(--red); }
.badge-STALE { background: #F1F5F9; color: var(--text-muted); }
.badge-PUBLISHED { background: #D1FAE5; color: var(--green); }
.badge-DRAFT { background: #F1F5F9; color: var(--text-muted); }

.error-box-light {
  background: #FEE2E2;
  border: 1px solid #FCA5A5;
  color: var(--red);
  padding: 14px 18px;
  border-radius: 12px;
  margin-bottom: 20px;
  font-weight: 700;
  font-size: 13px;
}

/* Pagination */
.pagination {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 18px;
  font-size: 13px;
}
.pagination a, .pagination span {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-light);
  text-decoration: none;
  color: var(--text-dark);
  font-weight: 700;
}
.pagination .current { background: var(--gradient-hero); color: #fff; border-color: transparent; }
.pagination .disabled { color: var(--text-muted); opacity: 0.5; }

/* Filter bar */
.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.filter-bar input, .filter-bar select {
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-light);
  font-size: 13px;
}

.form-field textarea, .form-field select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-light);
  font-size: 14px;
  font-family: inherit;
}

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border-light);
  flex-wrap: wrap;
}
.tabs a {
  padding: 10px 16px;
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 13px;
  border-bottom: 2px solid transparent;
}
.tabs a.active { color: var(--primary-orange); border-color: var(--primary-orange); }

.permission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin: 16px 0;
}
.permission-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  background: #F8FAFC;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-light);
}

/* Full-page centered card — login, 403/404/500 error pages */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg-app);
}

.auth-card-light {
  background: var(--card-bg);
  border-radius: 24px;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-card);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.auth-mark {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--gradient-hero);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 18px;
  margin: 0 auto 16px;
}

.auth-card-light h1 {
  font-size: 20px;
  font-weight: 900;
  color: var(--text-dark);
  margin: 0 0 4px;
}

.auth-card-light .form-field {
  text-align: left;
}

/* Bookie Rapid Bidding — quick-entry widgets */
.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.pill {
  padding: 9px 16px;
  border-radius: 30px;
  border: 1.5px solid var(--border-light);
  background: #fff;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.pill:hover { border-color: var(--primary-orange); color: var(--primary-orange); }
.pill.active {
  background: var(--gradient-hero);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 14px -4px rgba(255, 51, 102, 0.4);
}

.tap-pad {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.tap-btn {
  aspect-ratio: 1;
  border-radius: 12px;
  border: 1.5px solid var(--border-light);
  background: #fff;
  font-size: 20px;
  font-weight: 900;
  color: var(--text-dark);
  cursor: pointer;
  transition: all 0.15s ease;
}
.tap-btn:hover { border-color: var(--primary-orange); transform: translateY(-2px); }
.tap-btn.active {
  background: var(--gradient-hero);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 14px -4px rgba(255, 51, 102, 0.4);
}

.quick-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 20px;
  margin-bottom: 10px;
}
.chip {
  background: var(--gradient-card-orange);
  color: var(--primary-orange);
  border: 1px solid #FED7AA;
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.chip-x {
  cursor: pointer;
  opacity: 0.6;
  font-size: 11px;
}
.chip-x:hover { opacity: 1; }

.tap-btn-sm {
  aspect-ratio: auto;
  padding: 8px 4px;
  font-size: 13px;
}

.pana-chart {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 12px;
  background: #fff;
}
.pana-ank-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border-light);
}
.pana-ank-row:last-child { border-bottom: none; }
.pana-ank-label {
  flex: 0 0 60px;
  font-size: 11px;
  font-weight: 900;
  color: var(--text-muted);
  text-transform: uppercase;
  padding-top: 8px;
}
.pana-ank-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}
.pana-ank-chips .tap-btn-sm {
  min-width: 44px;
}

#jodiFullGrid {
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 10px;
}

/* Bookie Rapid Bidding — multi-select user checklist */
.user-check-list {
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  background: #fff;
}
.user-check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 700;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
}
.user-check-row:last-child { border-bottom: none; }
.user-check-row:hover { background: var(--gradient-card-orange); }
.user-check-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary-orange);
  flex-shrink: 0;
}
.user-check-row span:last-child {
  margin-left: auto;
  font-weight: 800;
  color: var(--green);
  font-size: 12px;
}

/* Bookie Rapid Bidding — grouped batch preview */
.batch-summary-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-muted);
}
.batch-summary-bar strong { color: var(--text-dark); font-size: 15px; }

.user-group-block {
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 14px;
}
.user-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 900;
  font-size: 14px;
  color: var(--text-dark);
  margin-bottom: 10px;
}
.user-group-header span {
  font-weight: 700;
  font-size: 12px;
  color: #8B5CF6;
}

.preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.preview-panel {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 28px;
  max-width: 800px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-hover);
}

/* ===== Mobile responsiveness =====
   Sidebar is fixed + full-height on desktop; below the breakpoint it
   becomes an off-canvas drawer toggled by the hamburger button (see
   partials/nav.ejs), and main-content drops its 270px reserved margin. */

.sidebar-toggle-btn {
  display: none;
}

.sidebar-overlay {
  display: none;
}

@media (max-width: 900px) {
  .sidebar-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 14px;
    left: 14px;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 1px solid var(--border-light);
    background: var(--card-bg);
    box-shadow: var(--shadow-card);
    font-size: 20px;
    z-index: 200;
    cursor: pointer;
  }

  .sidebar-overlay.visible {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 150;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    width: 260px;
    z-index: 180;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
    padding: 24px 16px 32px;
    padding-top: 72px; /* clears the fixed hamburger button */
    /* .app-wrapper is a flex row; a flex item's default min-width:auto lets
       its content (the wide table below) push it past the viewport instead
       of shrinking, which defeats .card-light's own overflow-x:auto and
       makes the WHOLE PAGE scroll horizontally. min-width:0 is the standard
       fix — it lets this flex item actually shrink to the viewport, so the
       overflow gets contained inside .card-light where it belongs. */
    min-width: 0;
  }

  .topbar-light {
    flex-wrap: wrap;
    gap: 12px;
  }

  .topbar-light h1 {
    font-size: 21px;
  }

  .card-light {
    padding: 18px;
    border-radius: 16px;
  }

  /* Tables don't reflow on narrow screens; scope the scroll to the card so
     the page itself never gains horizontal scroll (see body overflow rule
     in artifact-authoring conventions — same principle applies here). */
  .card-light {
    overflow-x: auto;
  }

  table {
    min-width: 560px;
  }

  .tap-pad {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }

  .pana-chart {
    overflow-x: auto;
  }

  .stats-grid {
    gap: 14px;
  }
}

@media (max-width: 480px) {
  .main-content {
    padding-left: 12px;
    padding-right: 12px;
  }

  .card-light {
    padding: 14px;
  }

  .tap-pad {
    grid-template-columns: repeat(3, 1fr);
  }
}
