/* reports.css — small add-ons for Reports
   NOTE: partner.css must be loaded first (this file depends on its variables).
*/

/* partner.css — Kolorowey UI
   - Enhanced left nav colors aligned to logo
   - Bigger logo
   - No Rev Share column styles needed
*/

/* ====== THEME ====== */
:root{
  /* Brand palette tuned to the logo (violet → indigo → azure) */
  --brand:#6c59ff;          /* primary violet */
  --brand-2:#5668ff;        /* indigo */
  --brand-3:#2e90c9;        /* azure */
  --brand-grad: linear-gradient(140deg, #6c59ff 0%, #5668ff 52%, #2e90c9 100%);

  /* Sidebar glass gradient built from brand palette */
  --side-a:#e9e6ff;   /* soft violet wash */
  --side-b:#e6f3ff;   /* soft azure wash */
  --side-glow-1:#b6a7ff;
  --side-glow-2:#8ecbff;

  --bg:#f6f8fc;
  --card:#ffffff;
  --muted:#5f7180;
  --text:#0b1b22;
  --accent:#0d2a4a;
  --accent-2:#537b98;
  --danger:#e05b5b;

  --radius:16px;
  --shadow: 0 10px 30px rgba(10,20,30,0.08);
  --sidebar-w:258px; /* a bit wider to breathe */

  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
}

/* ====== BASE ====== */
*{box-sizing:border-box}
.hidden{display:none !important}
html,body{height:100%}
body{
  margin:0;
  background:var(--bg);
  color:var(--text);
  font-family:Inter,Arial,Helvetica,sans-serif
}
.app{display:flex;min-height:100vh}

/* ====== LEFT SIDEBAR ====== */
.sidebar{
  position:relative;
  width:var(--sidebar-w);
  background:
    radial-gradient(140% 140% at -10% -20%, #ffffff 0%, var(--side-a) 55%, var(--side-b) 100%);
  padding:22px 20px;
  border-right:1px solid rgba(15,25,30,0.08);
  display:flex;flex-direction:column;gap:18px;overflow:hidden;
}
/* soft aurora glow */
.sidebar-bg{
  position:absolute;inset:-42% -60% auto auto;height:320px;width:320px;border-radius:50%;
  background:
    conic-gradient(from 210deg, var(--side-glow-1) 0%, #9fb6ff 25%, var(--side-glow-2) 55%, #d6b6ff 85%, var(--side-glow-1) 100%);
  filter: blur(42px) saturate(120%); opacity:.28; pointer-events:none;
}

.sidebar-top{padding:6px 0 6px}
.logo-wrap{text-align:center}
.logo-img{
  max-width:240px;  /* bigger logo */
  width:100%;
  height:auto;
  display:block;margin:0 auto;
  filter: drop-shadow(0 12px 28px rgba(108,89,255,.28));
}

/* ====== NAV LIST ====== */
.nav-list{display:flex;flex-direction:column;gap:10px;margin-top:8px}

.nav-item{
  display:flex;align-items:center;gap:12px;
  padding:12px 12px;
  border-radius:14px;
  color:var(--accent);
  text-decoration:none;
  font-weight:800;
  cursor:pointer;
  transition: transform .12s ease, background .12s ease, box-shadow .2s ease, color .12s ease;
}

/* icon container picks up brand gradient border + subtle glossy bg */
.nav-item .nav-icon{
  width:42px;height:42px;border-radius:13px;
  background:linear-gradient(180deg,#ffffff, #f3f5ff);
  display:flex;align-items:center;justify-content:center;
  color:#3b5bff;
  box-shadow:
    inset 0 0 0 1px rgba(86,104,255,.22),
    0 6px 14px rgba(86,104,255,.14);
}
.nav-item .nav-icon svg{width:22px;height:22px;stroke-width:1.9}

.nav-item:hover{
  background:linear-gradient(180deg, #f1f3ff 0%, #eaf4ff 100%);
  transform:translateX(6px);
  color:#102b50;
}

.nav-item.active{
  background:
    linear-gradient(180deg,#eef0ff 0%, #e7f2ff 100%);
  box-shadow:
    inset 0 0 0 1px rgba(38,56,120,0.10),
    0 10px 22px rgba(86,104,255,.18);
  border-left:6px solid rgba(86,104,255,.50);
  color:#0e2a48;
}

/* Sidebar footer */
.sidebar-bottom{margin-top:auto;text-align:center}
.btn-ghost{
  background:#fff;border:1px solid #e2eef6;
  padding:8px 10px;border-radius:10px;color:var(--accent);
  font-weight:700
}

/* New Logout Button Styling */
.btn-logout {
  background-color: #e63946;   /* Red background */
  color: #ffffff;             /* White text */
  font-weight: 700;
  padding: 12px 20px;         /* Slightly bigger than Collapse button */
  border: none;
  border-radius: 10px;
  cursor: pointer;
  display: inline-block;
  transition: background 0.2s ease;
}

.btn-logout:hover {
  background-color: #d62828;   /* Darker red when hovered */
}


/* ====== BADGES & TEXT SIZES ====== */
.small{font-size:13px}
.tiny{font-size:12px}
.muted{color:var(--muted)}
.chip{
  display:inline-block;margin-left:6px;padding:2px 8px;
  border-radius:999px;background:#eef5ff;border:1px solid #e2ecff;
  color:#1c3550;font-weight:700;font-size:11px
}
.chip.tz{margin-left:12px}

/* ====== TOP BAR ====== */
.main{flex:1;display:flex;flex-direction:column}
.topbar{
  display:flex;justify-content:space-between;align-items:center;
  padding:22px 28px;border-bottom:1px solid rgba(8,15,20,0.06);
  background:
    linear-gradient(180deg,#ffffff,#f6f9ff);
}
.title{margin:0;font-size:22px;font-weight:800;letter-spacing:.2px}
.subtitle{color:var(--muted);font-size:13px;margin-top:6px}
.actions{display:flex;gap:12px}

.btn{
  background:var(--accent);color:#fff;padding:10px 14px;border-radius:12px;border:none;cursor:pointer;font-weight:800;
  transition:transform .08s ease, box-shadow .12s ease
}
.btn:hover{transform:translateY(-1px);box-shadow:0 8px 22px rgba(16,42,72,.12)}
.btn.ghost{background:#fff;color:var(--accent);border:1px solid #e3f0f7}
.btn.small{padding:6px 10px;font-size:13px}
.btn.primary{background:var(--brand-grad);box-shadow: 0 8px 22px rgba(86,104,255,.28)}
.btn.danger{background:var(--danger);color:#fff}

/* ====== LAYOUT ====== */
.container{display:grid;grid-template-columns:420px 1fr;gap:22px;padding:26px 32px}
.panel{background:var(--card);border-radius:var(--radius);padding:18px;box-shadow:var(--shadow)}
.left-panel{min-height:60vh}
.right-panel{min-height:60vh}

/* ====== PARTNERS LIST ====== */
.search-header{display:flex;flex-direction:column;gap:10px}
.search-count{font-weight:800;color:var(--accent-2)}
.input{
  padding:10px;border-radius:12px;border:1px solid #e2f0f8;background:#fbfeff;width:100%;
  outline:none
}
.input:focus{border-color:#cfe3ff; box-shadow:0 0 0 3px rgba(86,104,255,.12)}

.partners-list{margin-top:12px;max-height:66vh;overflow:auto;padding-right:6px}
.partner-item{
  display:grid;grid-template-columns:1fr auto;gap:8px;
  padding:14px;border-radius:16px;border:1px solid #e9f0fb;
  background:linear-gradient(180deg,#fff,#fbfeff);margin-bottom:12px
}
.partner-item .name{font-weight:800;font-size:16px;letter-spacing:.1px}
.partner-item .meta{color:var(--muted);font-size:13px;margin-top:2px;font-weight:500}
.partner-item .created{color:#5d7287;font-size:12px;margin-top:8px}
.openBtn{
  background:#0e2a48;color:#fff;padding:10px 14px;border-radius:12px;border:none;align-self:center;font-weight:800
}

/* ====== DETAILS ====== */
.placeholder{
  padding:30px;border-radius:12px;
  background:linear-gradient(180deg,#fff,#fbfdff);
  border:1px dashed #eef7fb;color:var(--muted)
}
.partner-head{display:flex;justify-content:space-between;align-items:flex-start;margin-bottom:14px}
.partner-head h2{margin:0;font-weight:800}
.partner-actions{display:flex;gap:8px;flex-wrap:wrap}

/* ====== DOMAINS TABLE ====== */
.domains-section{margin-top:14px}
.domains-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:10px}
.domains-controls{display:flex;gap:8px;align-items:center}
.table-frame{overflow:auto;border-radius:10px;border:1px solid #eef6fb}
.table{width:100%;border-collapse:collapse}
.table thead th{
  padding:12px;background:#fbfdff;text-align:left;border-bottom:1px solid #eef6fb;font-weight:800
}
.table tbody td{padding:12px;border-top:1px solid #f5f9fb;vertical-align:middle}
.domain-chip{font-weight:800;color:var(--accent-2)}
.table select,
.table input[type=number],
.table input[type=password]{padding:8px;border-radius:10px;border:1px solid #e2f0f8;background:#fff}
.table select:focus,
.table input:focus{border-color:#cfe3ff; box-shadow:0 0 0 3px rgba(86,104,255,.12)}

.cut-pill{
  display:inline-block;padding:4px 8px;border-radius:999px;border:1px solid #e4ecf8;background:#f6fbff;
  font-weight:800;font-size:12px;color:#0c2a44;margin-right:6px
}
.cut-pill.over{
  background:var(--brand-grad);border-color:transparent;color:#fff;font-weight:900
}

/* ====== DEFAULTS BOX ====== */
.defaults{
  margin-top:8px;background:#fbfdff;padding:12px;border-radius:10px;border:1px solid #eef7fb
}

/* ====== MODAL ====== */
.modal{position:fixed;inset:0;display:none;align-items:center;justify-content:center;background:rgba(8,12,16,0.45);z-index:300}
.modal.open{display:flex}
.modal-panel{width:840px;background:var(--card);border-radius:18px;padding:16px;box-shadow:0 24px 60px rgba(6,12,20,0.45)}
.modal-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:12px}
.modal-body{max-height:64vh;overflow:auto}
.code-pre{background:#0b1620;color:#fff;padding:12px;border-radius:8px}

/* ====== Metrics tabs ====== */
.tabs{display:flex;gap:10px;margin-bottom:12px;flex-wrap:wrap}
.tab-btn{
  border:1px solid #e3eef7;background:#fff;border-radius:999px;padding:8px 14px;cursor:pointer;
  font-weight:800;color:var(--accent);letter-spacing:.2px
}
.tab-btn.active{background:#eef2ff;border-color:#d1e0ff}
.tab-panel{display:none}
.tab-panel.active{display:block}
.metrics-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(240px,1fr));gap:12px}

/* Switch in tabs */
.switch{position:relative;display:inline-block;width:52px;height:30px;margin-right:10px}
.switch input{display:none}
.switch span{position:absolute;cursor:pointer;inset:0;background:#e5edf6;border-radius:20px;transition:all .2s;}
.switch span:before{
  content:"";position:absolute;height:24px;width:24px;left:3px;top:3px;background:#fff;border-radius:50%;
  transition:.2s;box-shadow:0 2px 6px rgba(0,0,0,.15)
}
.switch input:checked + span{background:var(--brand-grad)}
.switch input:checked + span:before{transform:translateX(22px)}
.tab-toggle{display:flex;align-items:center;gap:10px;margin:6px 0 12px 0;font-weight:800;color:#1a2b3e}

/* ====== Allowed Menus — checkboxes in Create/Edit ====== */
.checkbox-grid{
  display:grid;
  grid-template-columns:repeat(2, minmax(0,1fr));
  gap:8px;
  margin-top:8px
}
.checkbox-grid label{
  display:flex;align-items:center;gap:8px;
  padding:8px 10px;border:1px solid #e8eef7;border-radius:10px;background:#fff;
  font-weight:700;color:#17324b
}
.checkbox-grid input[type=checkbox]{accent-color:#596dff}

/* ====== RESPONSIVE ====== */
@media (max-width:1100px){
  .container{grid-template-columns:1fr; padding:16px}
}
@media (max-width:980px){
  .sidebar{display:none}
}

/* --- Fix results panel stretching --- */
.container { overflow: hidden; }            /* grid doesn't expand */
.panel { min-width: 0; }                    /* allow grid child to shrink */
.right-panel { position: relative; min-width: 0; }

/* The frame must scroll horizontally if table is wider */
.table-frame {
  display: block;
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

/* Make table size only its content (so container scrolls instead of page) */
#reportTable {
  table-layout: auto;          /* let columns size naturally */
  width: max-content;          /* grow only as needed */
  min-width: 100%;             /* but never smaller than container */
  white-space: nowrap;         /* prevent wrapping that increases height massively */
}

/* Optional: make header sticky for long horizontal scrolls */
#reportTable thead th {
  position: sticky;
  top: 0;
  background: #fbfdff;
  z-index: 2;
}

/* Clear button placement inside Results header */
.panel.metrics-panel .panel-header {
  display: flex;
  justify-content: space-between; /* Text left, button right */
  align-items: center;
  margin-bottom: 8px;
}

.panel.metrics-panel .panel-header .report-clear-btn {
  position: static; /* naturally placed inside flex container */
  margin-left: auto;
}

/* ====== MODAL (shared) ====== */
.modal{
  position: fixed;
  inset: 0;
  display: none;                  /* hidden by default */
  align-items: center;
  justify-content: center;
  background: rgba(8, 12, 16, 0.45);
  z-index: 300;                   /* above panels and header */
}
.modal.open{                      /* JS toggles this */
  display: flex;
}
.modal-panel{
  width: 840px;
  max-width: calc(100vw - 40px);
  background: var(--card);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 24px 60px rgba(6, 12, 20, 0.45);
}
.modal-header{
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.modal-body{
  max-height: 64vh;
  overflow: auto;
}


/* ========== UTILITIES ========== */
.hidden { display: none !important; }

/* ========== FILTERS ========== */
.filter-block {
  margin-bottom: 14px;
}

.range-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

/* Segmented control (Format / Date presets) */
.segmented {
  display: inline-flex;
  background: #fff;
  border: 1px solid #e6eef7;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(14, 28, 50, 0.04);
}
.segmented.multi { flex-wrap: wrap; gap: 8px; border: none; box-shadow: none; background: transparent; }

.seg-btn {
  border: none;
  background: transparent;
  padding: 10px 14px;
  font-weight: 800;
  color: var(--accent);
  cursor: pointer;
  transition: all .15s ease;
}
.seg-btn.small { padding: 7px 12px; }

.segmented .seg-btn + .seg-btn {
  border-left: 1px solid #e6eef7;
}

.seg-btn:hover {
  background: #f3f7ff;
}

.seg-btn.active,
.seg-btn[aria-pressed="true"] {
  background: var(--brand-grad);
  color: #fff;
  box-shadow: 0 6px 16px rgba(86, 104, 255, 0.22);
}

/* Chip-style checkbox row (Group by) */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #e6eef7;
  font-weight: 700;
  color: #17324b;
  cursor: pointer;
  user-select: none;
  transition: box-shadow .15s ease, background .15s ease, border-color .15s ease;
}
.chip-check input {
  accent-color: #596dff;
}
.chip-check:hover {
  background: #f6f9ff;
  border-color: #d9e6ff;
  box-shadow: 0 4px 12px rgba(20, 45, 80, 0.06);
}

/* ========== KPI SUMMARY ========== */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.kpi-card {
  background: #fff;
  border: 1px solid #eaf1fb;
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 10px 26px rgba(10, 18, 28, 0.06);
}

.kpi-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .3px;
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
}

.kpi-diff {
  margin-top: 4px;
  font-size: 12px;
  font-weight: 700;
}
.kpi-diff.up { color: #14b36f; }
.kpi-diff.down { color: #e05b5b; }

/* ========== REPORT TABLE ========== */
#reportTable thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}

#reportTable th, #reportTable td {
  white-space: nowrap;
}

@media (min-width: 1100px) {
  /* widen first columns a bit */
  #reportHead th:nth-child(1) { min-width: 140px; }
  #reportHead th:nth-child(2) { min-width: 120px; }
}

/* ========== MODAL adjustments (schedule) ========== */
.schedule-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 640px) {
  .schedule-grid { grid-template-columns: 1fr; }
}

/* =====================
   REPORTS PAGE STYLING
   ===================== */

/* Ensure page never overflows horizontally */
html, body {
  overflow-x: hidden;
}

.main {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.container.vertical-layout {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 26px 32px;
  min-height: 0;
}

.filters-panel {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.metrics-panel {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  min-width: 0;
  overflow: hidden; /* prevent horizontal overflow */
}

.results-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.table-frame {
  display: block;
  overflow: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

#reportTable {
  table-layout: auto;
  width: max-content;
  min-width: 0;
  white-space: nowrap;
}

#reportTable thead th {
  position: sticky;
  top: 0;
  background: #fbfdff;
  z-index: 2;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
@media (min-width: 1280px) {
  .metric-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
}

.metric-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid #e6eef7;
  border-radius: 10px;
  background: #fff;
  font-weight: 700;
  color: #17324b;
}
.metric-pill input { accent-color: #596dff; }

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 8px;
}
.kpi-card {
  background: #fff;
  border: 1px solid #eaf1fb;
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 10px 26px rgba(10, 18, 28, 0.06);
}
/* =========================================================
   FINAL ANTI-STRETCH FIXES (add to the bottom of reports.css)
   ========================================================= */

/* Prevent the entire page from getting wider than the viewport */
html, body {
  overflow-x: hidden;
}

/* Ensure the page main area and container don't propagate overflow */
.main,
.container.vertical-layout,
.metrics-panel {
  min-width: 0;      /* allow shrinking within flex/grid */
  overflow: hidden;  /* clip anything that tries to overflow */
}

/* Only this area should scroll vertically */
.results-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;    /* vertical (and also horizontal if needed by inner frame) */
  max-width: 100%;
}

/* The table frame is the only place allowed to scroll horizontally */
.table-frame {
  display: block;
  overflow: auto;     /* both axes allowed inside frame */
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

/* The table sizes to its contents but does not force parent width */
#reportTable {
  table-layout: auto;
  width: max-content; /* let columns decide width */
  /* IMPORTANT: remove any min-width here so it doesn't push container wider */
  min-width: 0;
  white-space: nowrap;
}

/* Keep header visible when scrolling inside the frame */
#reportTable thead th {
  position: sticky;
  top: 0;
  background: #fbfdff;
  z-index: 2;
}

/* Minimal modal styling */
.modal{
  position: fixed;
  inset: 0;
  display: none;                 /* hidden by default */
  align-items: center;
  justify-content: center;
  background: rgba(8,12,16,.45);
  z-index: 9999;                 /* above everything */
}
.modal.open{ display: flex; }

.modal-panel{
  width: 840px;
  max-width: calc(100vw - 40px);
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 24px 60px rgba(0,0,0,.45);
}
.modal-header{
  display:flex;justify-content:space-between;align-items:center;margin-bottom:10px;
}
.modal-body{ max-height: 64vh; overflow:auto; }

/* Make sure header/panels don't sit above modal */
.topbar,.filters-panel,.metrics-panel{ position:relative; z-index:1; }
