/* Sigma Partner Panel -- Dark Blue Technology theme
   Shared by all agent/* and admin_* pages (per the project spec, section 3). */

:root {
  --bg: #0B1220;
  --card: #111A2E;
  --primary: #3B82F6;
  --accent: #60A5FA;
  --text: #E5E7EB;
  --muted: #8b95a7;
  --border: rgba(255,255,255,0.08);
  --danger: #f87171;
  --success: #34d399;
  --warn: #fbbf24;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  background: radial-gradient(circle at 20% -10%, #16234a 0%, var(--bg) 45%);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--accent); }

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 230px;
  flex-shrink: 0;
  background: rgba(17, 26, 46, 0.85);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  backdrop-filter: blur(10px);
}
.sidebar .brand { font-weight: 700; font-size: 1.05rem; padding: 0 10px 18px; letter-spacing: .3px; }
.sidebar .brand span { color: var(--accent); }
.sidebar nav a {
  display: block; padding: 10px 12px; border-radius: 10px; color: var(--text);
  text-decoration: none; font-size: .9rem; margin-bottom: 4px; transition: background .15s;
}
.sidebar nav a:hover { background: rgba(59,130,246,.12); }
.sidebar nav a.active { background: rgba(59,130,246,.22); color: #fff; box-shadow: 0 0 0 1px rgba(96,165,250,.35) inset; }
.sidebar .who { font-size: .78rem; color: var(--muted); padding: 0 10px 14px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }

.main { flex: 1; padding: 26px 30px; max-width: 1400px; }
.main h1 { margin: 0 0 4px; font-size: 1.4rem; }
.main .sub { color: var(--muted); margin: 0 0 22px; font-size: .9rem; }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1000px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }

/* ---- Mobile hamburger menu (admin + agent panels) ----
   Above 768px the sidebar stays exactly as it was: a normal, always-visible
   column. At or below 768px it becomes an off-canvas panel toggled by the
   hamburger button in the new .mobile-topbar (see admin_layout_header.php /
   agent_layout_header.php + assets/nav-toggle.js). */
.mobile-topbar { display: none; }
.menu-toggle {
  width: 38px; height: 34px; flex-shrink: 0; border-radius: 10px; border: 1px solid var(--border);
  background: rgba(255,255,255,.04); cursor: pointer; padding: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
}
.menu-toggle span { display: block; width: 18px; height: 2px; background: var(--text); border-radius: 2px; }
.menu-toggle:hover { background: rgba(255,255,255,.08); }
.sidebar-backdrop { display: none; }

@media (max-width: 768px) {
  .layout { flex-direction: column; }
  .mobile-topbar {
    display: flex; align-items: center; gap: 12px; padding: 12px 16px;
    background: rgba(17,26,46,.92); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 90; backdrop-filter: blur(10px);
  }
  .mobile-topbar-brand { font-weight: 700; font-size: 1rem; letter-spacing: .3px; }
  .mobile-topbar-brand span { color: var(--accent); }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 250px; max-width: 82vw;
    z-index: 110; transform: translateX(-100%); transition: transform .25s ease;
    overflow-y: auto; box-shadow: 0 0 40px rgba(0,0,0,.55);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    display: block; position: fixed; inset: 0; background: rgba(5,9,18,.6); z-index: 105;
    opacity: 0; pointer-events: none; transition: opacity .25s ease;
  }
  .sidebar-backdrop.open { opacity: 1; pointer-events: auto; }
}

.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0)) , var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}

.stat .label { color: var(--muted); font-size: .8rem; margin-bottom: 6px; }
.stat .value { font-size: 1.6rem; font-weight: 700; }
.stat .value.glow { color: var(--accent); text-shadow: 0 0 18px rgba(96,165,250,.45); }

.section-title { font-size: 1.05rem; margin: 28px 0 12px; }

.table-wrap { overflow-x: auto; border-radius: 16px; border: 1px solid var(--border); background: var(--card); }
table { width: 100%; border-collapse: collapse; font-size: .87rem; white-space: nowrap; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
tr:hover td { background: rgba(255,255,255,.02); }
td.wrap { white-space: normal; min-width: 200px; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 100px; font-size: .74rem; font-weight: 600; }
.badge-pending { background: rgba(251,191,36,.15); color: var(--warn); }
.badge-approved { background: rgba(52,211,153,.15); color: var(--success); }
.badge-rejected { background: rgba(248,113,113,.15); color: var(--danger); }
.badge-profit { background: rgba(52,211,153,.15); color: var(--success); }
.badge-loss { background: rgba(248,113,113,.15); color: var(--danger); }
.badge-apply { background: rgba(59,130,246,.15); color: var(--accent); }
.badge-offer { background: rgba(52,211,153,.15); color: var(--success); }
.badge-message { background: rgba(251,191,36,.15); color: var(--warn); }
.badge-agent_register { background: rgba(167,139,250,.15); color: #a78bfa; }

.btn {
  display: inline-block; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--border);
  background: rgba(255,255,255,.04); color: var(--text); font-size: .85rem; cursor: pointer;
  text-decoration: none; font-weight: 600; transition: background .15s, box-shadow .15s;
}
.btn:hover { background: rgba(255,255,255,.08); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: #2f6fe0; box-shadow: 0 0 20px rgba(59,130,246,.4); }
.btn-approve { background: rgba(52,211,153,.15); border-color: rgba(52,211,153,.4); color: var(--success); }
.btn-approve:hover { background: rgba(52,211,153,.28); }
.btn-reject { background: rgba(248,113,113,.15); border-color: rgba(248,113,113,.4); color: var(--danger); }
.btn-reject:hover { background: rgba(248,113,113,.28); }
.btn-sm { padding: 5px 11px; font-size: .78rem; }

form.filters, form.panel-form {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-bottom: 20px;
}
form.panel-form { flex-direction: column; align-items: stretch; max-width: 460px; }
form.panel-form.wide { max-width: 720px; }
.field { display: flex; flex-direction: column; gap: 5px; }
label { font-size: .78rem; font-weight: 600; color: var(--muted); }
input, select, textarea {
  padding: 8px 10px; border-radius: 9px; border: 1px solid var(--border);
  background: rgba(255,255,255,.03); color: var(--text); font-size: .85rem; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,.25); }
textarea { resize: vertical; min-height: 60px; }

/* Native <select> popups otherwise fall back to the browser/OS default
   (often light text on a light background until hovered) since most
   browsers won't inherit page CSS into the dropdown popup unless the
   <option> elements are styled directly. */
select { color-scheme: dark; }
select option {
  background-color: #111A2E;
  color: #E5E7EB;
}

.field-span-2 { grid-column: 1 / -1; }
.preview-line { font-size: .82rem; color: var(--muted); }
.preview-line .amount { font-weight: 700; font-size: 1rem; color: var(--text); }

.msg { padding: 10px 14px; border-radius: 10px; font-size: .85rem; margin-bottom: 16px; }
.msg-err { background: rgba(248,113,113,.12); color: #fecaca; border: 1px solid rgba(248,113,113,.3); }
.msg-ok { background: rgba(52,211,153,.12); color: #bbf7d0; border: 1px solid rgba(52,211,153,.3); }
.msg-info { background: rgba(59,130,246,.12); color: #bfdbfe; border: 1px solid rgba(59,130,246,.3); }

.pager { display: flex; gap: 8px; align-items: center; margin-top: 16px; }
.pager span { color: var(--muted); font-size: .85rem; }

.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background:
    radial-gradient(circle at 12% 15%, rgba(59,130,246,.35), transparent 42%),
    radial-gradient(circle at 88% 20%, rgba(96,165,250,.22), transparent 40%),
    radial-gradient(circle at 80% 85%, rgba(52,211,153,.20), transparent 45%),
    radial-gradient(circle at 15% 90%, rgba(251,191,36,.12), transparent 40%),
    var(--bg);
}
.auth-card { width: 100%; max-width: 420px; position: relative; overflow: hidden; border-color: rgba(96,165,250,.35); box-shadow: 0 24px 60px rgba(0,0,0,.5); }
.auth-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 5px; background: linear-gradient(90deg, #3B82F6, #60A5FA, #34d399, #fbbf24); }
.auth-card h2 { margin: 0 0 4px; text-align: center; }
.auth-card .sub { color: var(--muted); margin: 0 0 20px; font-size: .88rem; text-align: center; }
.auth-card .foot { margin-top: 16px; font-size: .85rem; color: var(--muted); text-align: center; }

.auth-help { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); text-align: center; }
.auth-help p { margin: 0 0 10px; font-size: .8rem; color: var(--muted); }
.auth-social { display: flex; justify-content: center; gap: 14px; }
.auth-social-btn {
  width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(0,0,0,.28); transition: transform .2s ease, box-shadow .2s ease;
}
.auth-social-btn:hover { transform: scale(1.08); box-shadow: 0 6px 18px rgba(0,0,0,.32); }
.auth-social-btn svg { width: 24px; height: 24px; fill: #fff; }
.auth-social-btn.wa { background: #25D366; }
.auth-social-btn.tg { background: #229ED9; }

.auth-brand { text-align: center; margin-bottom: 18px; }
.auth-logo {
  width: 62px; height: 62px; object-fit: contain; margin-bottom: 10px;
  filter: drop-shadow(0 6px 18px rgba(59,130,246,.55));
}
.auth-brand-name { font-weight: 800; letter-spacing: .07em; font-size: 1.2rem; }
.auth-brand-name span { color: var(--accent); }
.auth-brand-tag {
  color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .1em; margin-top: 3px;
}

.chart-card canvas { max-width: 100%; }
.chart-card { position: relative; height: 260px; }
.chart-card canvas { height: 100% !important; }

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.tab-btn {
  padding: 10px 16px; border: none; background: none; color: var(--muted); font-size: .88rem;
  font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
  font-family: inherit;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

@media (max-width: 640px) {
  .main { padding: 16px 14px; }
  .card { padding: 14px 16px; }
  .stat .value { font-size: 1.3rem; }
  .chart-card { height: 220px; }
  form.filters { flex-direction: column; align-items: stretch; }
}

tr.entry-row { cursor: pointer; }
tr.entry-row:hover td { background: rgba(59,130,246,.08); }
tr.entry-row-deposit td { border-bottom: none; }
tr.entry-pair-end td { border-bottom: 2px solid var(--border); }

.modal-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(5,9,18,.65);
  align-items: center; justify-content: center; padding: 20px; z-index: 100;
}
.modal-backdrop.open { display: flex; }
.modal {
  width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto;
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 22px 24px; box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.modal h3 { margin: 0 0 4px; }
.modal .sub { margin: 0 0 16px; }
.modal-row {
  display: flex; justify-content: space-between; gap: 12px; padding: 9px 0;
  border-bottom: 1px solid var(--border); font-size: .9rem;
}
.modal-row:last-of-type { border-bottom: none; }
.modal-row .k { color: var(--muted); }
.modal-row .v { font-weight: 600; text-align: right; }
.modal-close { margin-top: 16px; width: 100%; }

/* Searchable agent picker -- replaces long <select> dropdowns once there
   are too many agents to scroll through. */
.agent-picker { position: relative; }
.agent-results {
  display: none; position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 60;
  background: #111A2E; border: 1px solid var(--border); border-radius: 10px;
  max-height: 240px; overflow-y: auto; box-shadow: 0 14px 34px rgba(0,0,0,.45);
}
.agent-results.open { display: block; }
.agent-result-item { padding: 9px 12px; font-size: .85rem; cursor: pointer; color: var(--text); }
.agent-result-item:hover, .agent-result-item.hi { background: rgba(59,130,246,.18); }
.agent-result-empty { padding: 9px 12px; font-size: .85rem; color: var(--muted); }
.agent-picker-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--muted); cursor: pointer; font-size: 1rem;
  padding: 2px 6px; display: none;
}
.agent-picker-clear.show { display: block; }
