/* =========================================================
   EaglePay — Professional White & Blue Theme
   ========================================================= */
:root {
  --blue-deep: #0b3faa;
  --blue: #1d63e8;
  --blue-light: #eaf2ff;
  --gold: #1d63e8;        /* kept name for compatibility with existing inline styles */
  --gold-light: #0b3faa;  /* kept name — used as heading/accent color everywhere */
  --ink: #1b2437;
  --ink-dim: #5b6b85;
  --card-bg: #ffffff;
  --glass: #ffffff;              /* kept name — cards are solid white now */
  --glass-border: #e1e9f7;
  --danger: #e0332f;
  --success: #17a865;
  --radius: 14px;
  --shadow: 0 4px 18px rgba(19, 46, 110, 0.08);
  --shadow-lg: 0 12px 34px rgba(19, 46, 110, 0.14);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: 'Segoe UI', Roboto, -apple-system, sans-serif;
  color: var(--ink);
}

body {
  background: linear-gradient(180deg, #f4f8ff 0%, #eef3fc 45%, #eaf1fb 100%);
  background-attachment: fixed;
  position: relative;
}

.app-shell, .center-shell {
  position: relative;
  z-index: 1;
}

/* ---------- Cards ---------- */
.glass-card {
  background: var(--card-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}

/* ---------- Auth (login/signup-style admin-create) center layout ---------- */
.center-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-box { width: 100%; max-width: 420px; text-align: center; }
.brand {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: .3px;
  color: var(--blue-deep);
  margin-bottom: 4px;
}
.brand-logo {
  max-width: 220px;
  max-height: 84px;
  margin: 0 auto 6px;
  display: block;
  object-fit: contain;
}
.topbar .brand-logo { max-height: 38px; max-width: 180px; margin: 0; }
.brand-sub { color: var(--ink-dim); font-size: 13px; margin-bottom: 28px; }

/* ---------- Form elements ---------- */
label { display: block; text-align: left; font-size: 13px; color: var(--ink-dim); margin: 14px 0 6px; font-weight: 600; }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=file], select, textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--glass-border);
  background: #fbfdff;
  color: var(--ink);
  font-size: 14px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(29,99,232,0.12); background: #fff; }

.btn {
  display: inline-block;
  width: 100%;
  margin-top: 22px;
  padding: 13px 18px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--blue), var(--blue-deep));
  color: #ffffff;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: .3px;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s, opacity .15s;
  text-align: center;
  text-decoration: none;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(29,99,232,0.3); opacity: .96; }
.btn.secondary { background: #fff; color: var(--blue-deep); border: 1.5px solid var(--glass-border); }
.btn.secondary:hover { border-color: var(--blue); box-shadow: none; }
.btn.danger { background: linear-gradient(135deg,#f0605c,#c62a26); color: #fff; }
.btn.small { width: auto; padding: 8px 14px; font-size: 12px; margin-top: 0; }

.alert { padding: 12px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 16px; text-align: left; }
.alert.error   { background: #fdecec; border: 1px solid #f6c4c2; color: #a3231f; }
.alert.success { background: #e9f9f1; border: 1px solid #b9ecd2; color: #0e7a49; }

/* ---------- Dashboard shell ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 14px 28px;
  background: #ffffff;
  border-bottom: 1px solid var(--glass-border);
  box-shadow: 0 1px 0 rgba(19,46,110,0.03);
  position: relative; z-index: 50;
}
.topbar .brand { margin: 0; font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .user-chip {
  font-size: 13px; color: var(--ink-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45vw;
}

/* IMPORTANT: no position/z-index on .layout — see mobile-drawer stacking
   note further down; keeping .layout unpositioned lets .sidebar and
   #sidebarBackdrop compare directly in the same stacking context. */
.layout { display: flex; min-height: calc(100vh - 62px); }
.sidebar {
  width: 230px; flex-shrink: 0;
  background: linear-gradient(180deg, #0b3faa 0%, #123d94 100%);
  padding: 20px 0;
}
.sidebar a {
  display: block; padding: 12px 24px; color: rgba(255,255,255,0.78);
  text-decoration: none; font-size: 14px; border-left: 3px solid transparent;
}
.sidebar a:hover, .sidebar a.active {
  color: #ffffff; background: rgba(255,255,255,0.12); border-left-color: #ffffff;
}
.content { flex: 1; padding: 28px; min-width: 0; }

.grid { display: grid; gap: 18px; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

.stat-card { padding: 20px; border-top: 3px solid var(--blue); }
.stat-card .label { font-size: 12px; color: var(--ink-dim); text-transform: uppercase; letter-spacing: .6px; font-weight: 700; }
.stat-card .value { font-size: 26px; font-weight: 800; color: var(--blue-deep); margin-top: 6px; }

.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; min-width: 560px; border-collapse: collapse; font-size: 13px; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--glass-border); }
th { color: var(--blue-deep); font-weight: 700; text-transform: uppercase; font-size: 11px; letter-spacing: .5px; white-space: nowrap; background: var(--blue-light); }
tr:hover td { background: #f7fafe; }

.badge { padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge.success { background: #e9f9f1; color: var(--success); }
.badge.pending { background: #eaf2ff; color: var(--blue-deep); }
.badge.failed  { background: #fdecec; color: var(--danger); }

/* ---------- Toggle switch (feature permissions) ---------- */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; cursor: pointer; inset: 0;
  background: #cdd9ee; transition: .2s; border-radius: 24px;
}
.switch .slider::before {
  position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px;
  background: #fff; transition: .2s; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.switch input:checked + .slider { background: var(--blue); }
.switch input:checked + .slider::before { transform: translateX(18px); }

.feature-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 4px; border-bottom: 1px solid var(--glass-border); }
.feature-row:last-child { border-bottom: none; }
.panel-tabs { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.panel-tabs a {
  padding: 8px 16px; border-radius: 20px; font-size: 13px; font-weight: 600; text-decoration: none;
  color: var(--ink-dim); background: var(--blue-light); border: 1px solid var(--glass-border);
}
.panel-tabs a.active, .panel-tabs a:hover { background: var(--blue); color: #fff; border-color: var(--blue); }

/* ---------- Mobile menu toggle (hidden on desktop) ---------- */
.menu-toggle {
  display: none;
  background: var(--blue-light);
  border: 1px solid var(--glass-border);
  color: var(--blue-deep);
  width: 44px; height: 44px;
  border-radius: 10px;
  font-size: 18px;
  cursor: pointer;
  position: relative;
  z-index: 10000;
  touch-action: manipulation;
}

/* =========================================================
   RESPONSIVE — tablets and phones
   ========================================================= */
@media (max-width: 900px) {
  .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .glass-card { padding: 22px; }
}

@media (max-width: 900px) {
  .topbar { padding: 12px 16px; }
  .topbar .brand { font-size: 16px; }
  .content { padding: 18px; }

  .menu-toggle { display: block; }

  /* sidebar becomes a slide-in drawer on tablets + phones */
  .sidebar {
    display: block;
    position: fixed;
    top: 62px; left: 0; bottom: 0;
    width: 260px;
    max-width: 80vw;
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 9999;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-top: 8px;
    touch-action: manipulation;
    pointer-events: auto;
    /* Solid + opaque while open so page content underneath never shows
       through or overlaps the menu text. */
    background: linear-gradient(180deg, #0b3faa 0%, #123d94 100%);
  }
  .sidebar.open { transform: translateX(0); box-shadow: 10px 0 40px rgba(11,63,170,0.35); }
  .sidebar a {
    padding: 14px 24px; font-size: 15px;
    position: relative; z-index: 1;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(255,255,255,0.25);
    pointer-events: auto;
  }

  .sidebar-backdrop {
    display: none;
    position: fixed; top: 62px; left: 0; right: 0; bottom: 0; z-index: 9998;
    background: rgba(11,25,58,0.45);
  }
  .sidebar-backdrop.open { display: block; }

  /* Belt-and-braces: while the drawer is open, make everything behind it
     completely un-clickable (not just visually covered). */
  body.menu-open .content,
  body.menu-open .topbar .user-chip {
    pointer-events: none;
  }

  .layout { display: block; }
  .content { width: 100%; }

  body { background-attachment: scroll; }

  /* Belt-and-braces: the support bubble is position:fixed at the root level
     (outside .app-shell), so on very narrow phones its bottom-right corner
     can sit over the bottom of the drawer. Hide it while the drawer is open. */
  body.menu-open .tg-support-btn { display: none; }
}

@media (min-width: 901px) {
  .sidebar-backdrop { display: none !important; }
}

@media (max-width: 640px) {
  .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .glass-card { padding: 18px; border-radius: 12px; }
  .content { padding: 16px; }

  /* forms/grids that used a fixed side column stack full width */
  .grid[style*="grid-template-columns"] { grid-template-columns: 1fr !important; }

  input[type=text], input[type=password], input[type=email], input[type=number], select, textarea, .btn {
    font-size: 16px; /* prevents iOS auto-zoom on focus */
  }

  .stat-card .value { font-size: 21px; }

  .tg-support-btn { bottom: 16px; right: 16px; width: 50px; height: 50px; font-size: 22px; }

  .auth-box { max-width: 100%; }
  .qr-box img { width: 160px; height: 160px; }
}

/* ---------- Telegram support floating button ---------- */
.tg-support-btn {
  position: fixed; bottom: 24px; right: 24px; z-index: 50;
  background: linear-gradient(135deg,#34a8e0,#1c7fc4);
  color: #fff; text-decoration: none;
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
  box-shadow: 0 6px 22px rgba(28,127,196,0.35);
  transition: transform .15s;
}
.tg-support-btn:hover { transform: scale(1.08); }

.qr-box { background: #fff; padding: 14px; border-radius: 12px; display: inline-block; margin: 16px 0; border: 1px solid var(--glass-border); }
.mono { font-family: 'Courier New', monospace; letter-spacing: .5px; }

/* ---------- API documentation page ---------- */
.docs-shell { max-width: 980px; margin: 0 auto; padding: 32px 20px 80px; }
.docs-hero { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.docs-nav { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 28px; }
.docs-nav a {
  font-size: 12.5px; padding: 7px 13px; border-radius: 20px; text-decoration: none;
  color: var(--ink-dim); background: var(--blue-light); border: 1px solid var(--glass-border);
}
.docs-nav a:hover { color: #fff; background: var(--blue); border-color: var(--blue); }
.endpoint { margin-bottom: 34px; scroll-margin-top: 20px; }
.endpoint h3 { color: var(--blue-deep); margin-bottom: 6px; }
.method-badge {
  display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .5px;
  padding: 3px 10px; border-radius: 6px; margin-right: 8px; vertical-align: middle;
}
.method-badge.post { background: #e9f9f1; color: var(--success); }
.method-badge.get  { background: #eaf2ff; color: var(--blue-deep); }
pre.code-block {
  background: #0f2b63; border: 1px solid var(--glass-border); border-radius: 12px;
  padding: 16px 18px; overflow-x: auto; font-size: 12.5px; line-height: 1.6;
  font-family: 'Courier New', monospace; color: #dbe9ff;
}
pre.code-block .k { color: #8fc4ff; }
.params-table th, .params-table td { font-size: 12.5px; }
.download-row { display: flex; gap: 10px; flex-wrap: wrap; }
.download-row .btn { width: auto; }
