/* =========================================================
   WeLink Admin – FINAL CSS (clean single standard)
   - No inner vertical scroll in cards/tables
   - One standard button system
   - Products-style actions everywhere
   - “More” dropdown safe (fixed + icons)
   - Customers legacy compatibility included
   ========================================================= */

/* =========================================================
   Tokens
   ========================================================= */
:root{
  /* Core */
  --bg:#0b1220;
  --card:#121a2c;
  --text:#e7ecff;
  --muted:#a8b3d6;
  --line:rgba(255,255,255,.08);

  /* Accents */
  --primary:#2b59ff;
  --primary2:#1f4cf5;

  --success:#2ecc71;
  --successBg:rgba(46,204,113,.16);
  --successBd:rgba(46,204,113,.34);

  --danger:#e74c3c;
  --dangerBg:rgba(231,76,60,.10);
  --dangerBd:rgba(231,76,60,.24);

  /* Layout */
  --container-max:68rem;
  --pad-x:clamp(12px,3vw,18px);
  --gap:clamp(10px,2.2vw,14px);
  --radius:clamp(12px,2vw,16px);

  /* Buttons */
  --btn-pad-y:clamp(8px,2vw,10px);
  --btn-pad-x:clamp(10px,2.4vw,14px);
  --btn-sm-pad-x:10px;

  /* Effects */
  --focus: rgba(43,89,255,.45);
  --shadow: 0 12px 30px rgba(0,0,0,.25);

  /* Surfaces */
  --surface:#0f1730;
  --surface2:rgba(255,255,255,.03);
}

/* =========================================================
   Base
   ========================================================= */
*{box-sizing:border-box;}
html,body{height:100%;}
html{scroll-behavior:smooth;}
body{
  margin:0;
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  background:var(--bg);
  color:var(--text);
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;

  /* Only page scroll (no weird nested scroll wrappers) */
  overflow-x:hidden;
  overflow-y:auto;
}
a{color:inherit;text-decoration:none;}
img{max-width:100%; height:auto;}

:focus-visible{
  outline:2px solid var(--focus);
  outline-offset:2px;
  border-radius:10px;
}

/* =========================================================
   Layout container
   ========================================================= */
.container{
  width:min(100% - (var(--pad-x) * 2), var(--container-max));
  margin:clamp(14px,3vw,22px) auto;
  height:auto !important;
  min-height:0 !important;
}

/* =========================================================
   Icons / A11y
   ========================================================= */
.icon{ width:18px; height:18px; display:inline-block; fill: currentColor; }
.sr-only{
  position:absolute !important;
  width:1px;height:1px;
  padding:0;margin:-1px;
  overflow:hidden;clip:rect(0,0,0,0);
  white-space:nowrap;border:0;
}

/* =========================================================
   Topbar
   ========================================================= */
.topbar{
  position:sticky;
  top:0;
  z-index:1000;
  background: rgba(0,0,0,.22);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.topbar::after{
  content:"";
  position:absolute;
  left:0; right:0; bottom:0;
  height:1px;
  background: var(--line);
  pointer-events:none;
}
.topbar-inner{
  width: min(100% - (var(--pad-x) * 2), var(--container-max));
  margin:0 auto;
  padding: clamp(10px,2.4vw,14px) 0;

  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
}

.brand{ display:flex; align-items:center; }
.brand-link{
  font-weight:900;
  letter-spacing:.2px;
  color:var(--text);
  padding:6px 10px;
  border-radius:999px;
}
.brand-link:hover{ background: rgba(255,255,255,.04); }

/* Desktop nav */
.nav-desktop{
  display:flex;
  align-items:center;
  gap:10px;
  justify-content:flex-end;
  flex-wrap:wrap;
}
.nav-link{
  display:inline-flex;
  align-items:center;
  gap:8px;

  padding:10px 12px;
  border-radius:999px;

  border:1px solid var(--line);
  background: rgba(255,255,255,.03);

  font-weight:800;
  transition: background .12s ease, border-color .12s ease, transform .08s ease;
  white-space: nowrap;
}
.nav-link:hover{ background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.14); }
.nav-link:active{ transform: translateY(1px); }
.nav-link.is-active{
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.18);
}
.nav-link-danger{
  background: rgba(231,76,60,.10);
  border-color: rgba(231,76,60,.20);
}
.nav-link-danger:hover{
  background: rgba(231,76,60,.14);
  border-color: rgba(231,76,60,.28);
}
.nav-user{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:10px 10px;
  border-radius:999px;
  color:var(--muted);
  border:1px solid transparent;
  max-width:320px;
}
.nav-user span{
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  max-width:240px;
  display:inline-block;
}

/* Mobile nav (details dropdown) */
details.nav-mobile{ display:none; position:relative; }
details.nav-mobile > summary{
  list-style:none;
  cursor:pointer;
  user-select:none;
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:10px 12px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.03);
}
details.nav-mobile > summary::-webkit-details-marker{ display:none; }
details.nav-mobile summary .close-icon{ display:none; }
details.nav-mobile[open] summary .menu-icon{ display:none; }
details.nav-mobile[open] summary .close-icon{ display:inline; }

.nav-mobile-panel{
  position:absolute;
  right:0;
  top: calc(100% + 10px);
  width:280px;
  max-width:min(280px, 90vw);

  background: rgba(18,26,44,.98);
  border:1px solid rgba(255,255,255,.10);
  border-radius:14px;
  box-shadow: 0 16px 34px rgba(0,0,0,.35);

  padding:8px;
  display:flex;
  flex-direction:column;
  gap:8px;

  z-index:1001;
  max-height:min(65vh, 520px);
  overflow:auto;
}
.nav-mobile-panel .nav-link,
.nav-mobile-panel .nav-user{
  width:100%;
  justify-content:flex-start;
}

@media (max-width: 820px){
  .nav-desktop{ display:none; }
  details.nav-mobile{ display:block; }
}

/* =========================================================
   Utilities / Headings
   ========================================================= */
.page-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  margin:10px 0 14px;
}
.page-title{
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing:.2px;
}
.page-subtitle{
  color:var(--muted);
  font-size:.9rem;
  margin-top:2px;
}
.stack{ display:flex; flex-direction:column; gap:8px; }
.sep{ height:1px; background:var(--line); margin:12px 0; }

/* Messages */
.ok, .error, .warn{
  border-radius:14px;
  padding:10px 12px;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.03);
}
.ok{
  border-color: rgba(46,204,113,.26);
  background: rgba(46,204,113,.10);
  color:#b9ffcf;
}
.error{
  border-color: rgba(231,76,60,.26);
  background: rgba(231,76,60,.10);
  color:#ffd0cc;
}
.warn{
  border-color: rgba(255,193,7,.28);
  background: rgba(255,193,7,.10);
  color:#ffe7a3;
}

/* =========================================================
   Cards / Inputs
   ========================================================= */
.cards-grid{
  display:grid;
  gap: var(--gap);
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
}
@media (max-width: 1100px){
  .cards-grid{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px){
  .cards-grid{ grid-template-columns: 1fr; }
}

.card{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:var(--radius);
  padding:clamp(12px,2.4vw,16px);
  box-shadow:var(--shadow);

  /* kill inner scroll */
  height:auto !important;
  max-height:none !important;
  overflow:visible !important;
}

.input{
  width:100%;
  padding:clamp(9px,2vw,10px) clamp(10px,2.2vw,12px);
  border-radius:var(--radius);
  border:1px solid var(--line);
  background:var(--surface);
  color:var(--text);
  outline:none;
}
.input:focus{
  outline:2px solid var(--focus);
  outline-offset:2px;
  border-color:rgba(43,89,255,.25);
}

/* Dropdown option visibility */
select option{
  background:#0f172a;
  color:#e7ecff;
}

/* =========================================================
   Buttons (single system)
   ========================================================= */
.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;

  /* consistent height everywhere */
  height:40px;
  padding: 0 var(--btn-pad-x);

  border-radius:var(--radius);
  border:1px solid var(--line);
  background:var(--primary);
  color:#fff;

  font-weight:800;
  cursor:pointer;
  user-select:none;
  white-space:nowrap;

  line-height:1;
  vertical-align:middle;

  transition:transform .08s ease,filter .12s ease,background .12s ease,border-color .12s ease,opacity .12s ease;
}

/* normalize icons inside buttons */
.btn svg,
.btn .icon{
  width:18px;
  height:18px;
  display:inline-block;
  flex:0 0 18px;
}

/* small button */
.btn.sm{
  height:34px;
  padding: 0 var(--btn-sm-pad-x);
  border-radius:999px;
  font-weight:900;
  font-size:.85rem;
}

.btn:hover{ filter:brightness(1.07); }
.btn:active{ transform:translateY(1px); }

.btn.ghost{
  background:rgba(255,255,255,.03);
  border:1px solid var(--line);
  color:var(--text);
}
.btn.ghost:hover{
  background:rgba(255,255,255,.06);
  border-color:rgba(255,255,255,.14);
}

.btn.success{ background:var(--successBg); border:1px solid var(--successBd); color:#b9ffcf; }
.btn.danger{ background:var(--dangerBg); border:1px solid var(--dangerBd); color:#ffd0cc; }

/* =========================================================
   Table (no inner Y scroll)
   ========================================================= */
.table-wrap{
  margin-top:.9rem;

  /* Horizontal scroll only */
  overflow-x:auto;
  overflow-y:hidden;

  -webkit-overflow-scrolling: touch;

  max-height:none !important;
  height:auto !important;
}
.table{
  border-collapse:collapse;
  width:100%;
  table-layout:auto;
  min-width: 720px;
}
.table th,.table td{
  padding:.75rem .6rem;
  border-bottom:1px solid var(--line);
  vertical-align:middle;
}
.table thead th{
  text-align:left;
  color:var(--muted);
  font-size:.75rem;
  letter-spacing:.4px;
  text-transform:uppercase;
  white-space:nowrap;
}
.table tbody tr:hover td{ background:rgba(255,255,255,.03); }

.cell-ellip{
  max-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

/* Actions column */
th.th-actions, td.actions-cell{
  width:1%;
  white-space:nowrap;
  text-align:right;
  overflow: visible;
  position: relative;
}

/* Sort link */
.table thead th a.th-sort{
  color:inherit;
  text-decoration:none;
  border-bottom:1px dashed rgba(255,255,255,0.18);
}
.table thead th a.th-sort:hover{
  border-bottom-color:rgba(255,255,255,0.35);
}

/* Status badge */
.badge{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:3px 10px;
  border-radius:999px;
  font-size:12px;
  font-weight:900;
  border:1px solid transparent;
}
.badge::before{
  content:"";
  width:6px;height:6px;border-radius:50%;
  display:inline-block;
}
.badge.active{ background:var(--successBg); border:1px solid var(--successBd); color:#b9ffcf; }
.badge.active::before{ background:var(--success); }
.badge.inactive{ background:var(--dangerBg); border:1px solid var(--dangerBd); color:#ffd0cc; }
.badge.inactive::before{ background:var(--danger); }

/* =========================================================
   Action buttons (ONE STANDARD – Products)
   ========================================================= */
.actions-inline{
  display:flex;
  gap:8px;
  align-items:center;
  justify-content:flex-end;
  flex-wrap:nowrap;
}
.actions-inline > *{ flex:0 0 auto; }

.act-btn{
  width:38px;
  height:38px;
  border-radius:10px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border:1px solid rgba(255,255,255,.08);
  background:#1a2236;
  cursor:pointer;
  user-select:none;
  transition: transform .08s ease, background .12s ease, border-color .12s ease;
  padding:0;
}
.act-btn:hover{
  transform: translateY(-1px);
  border-color: rgba(255,255,255,.14);
  background:#222c45;
}
.act-btn:active{ transform: translateY(0); }

.act-btn svg{
  width:18px;
  height:18px;
  fill:#cfd7ff;
}

/* Edit (blue) */
.act-btn.edit{
  background:#2b59ff;
  border-color:#2b59ff;
}
.act-btn.edit svg{ fill:#fff; }

/* Toggle (neutral) */
.act-btn.toggle{
  background:#1a2236;
  border-color: rgba(255,255,255,.08);
}
.act-btn.toggle:hover{
  background:#25304a;
  border-color: rgba(255,255,255,.14);
}

/* Delete (red) */
.act-btn.delete{
  background:#3a1f24;
  border-color:#7a2a33;
}
.act-btn.delete svg{ fill:#ffb3b3; }
.act-btn.delete:hover{
  background:#5a2b33;
  border-color:#a13a45;
}

.act-btn:disabled,
.act-btn.disabled{
  opacity:.45;
  cursor:not-allowed;
  transform:none !important;
}

/* =========================================================
   Business pills / icon pill
   ========================================================= */
.icon-pill{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:34px;
  height:34px;
  border-radius:12px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.10);
}
.icon-pill .icon{ width:18px; height:18px; }

.biz-switcher{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin-bottom:2px;
}

.biz-pill{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:8px 12px;
  border-radius:999px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.10);
  color: var(--text);
  cursor:pointer;
  user-select:none;
  transition: transform .06s ease, background .15s ease, border-color .15s ease;
  font-weight:600;
  font-size:13px;
}

.biz-pill:hover{
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.16);
}
.biz-pill:active{ transform: scale(.98); }

.biz-pill input{ display:none; }

.biz-pill .dot{
  width:10px;
  height:10px;
  border-radius:999px;
  background: rgba(255,255,255,.20);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}

.biz-pill.is-active{
  background: rgba(43,89,255,.18);
  border-color: rgba(43,89,255,.45);
}
.biz-pill.is-active .dot{
  background: rgba(43,89,255,.95);
  box-shadow:none;
}
.biz-pill.is-inactive{ opacity:.72; }
.biz-pill small{ font-weight:600; opacity:.85; }

/* =========================================================
   Kebab menu (details) + dropdown panel
   ========================================================= */
details.more{ position:relative; display:inline-block; }
details.more > summary{ list-style:none; cursor:pointer; }
details.more > summary::-webkit-details-marker{ display:none; }

.more-icon{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:28px;
  height:28px;
  border-radius:8px;
  background:transparent;
  color:var(--muted);
  cursor:pointer;
  border:1px solid transparent;
  transition:background .12s ease, border-color .12s ease, color .12s ease;
}
.more-icon:hover{
  background:rgba(255,255,255,.06);
  border-color:rgba(255,255,255,.12);
  color:var(--text);
}

.more-panel{
  position:absolute;
  right:0;
  top:calc(100% + 8px);
  width: 260px;
  max-width: min(260px, 90vw);

  background: rgba(18,26,44,.98);
  border:1px solid rgba(255,255,255,.10);
  border-radius:14px;
  box-shadow:0 16px 34px rgba(0,0,0,.35);
  padding: 8px;

  z-index: 999;
  display:flex;
  flex-direction:column;
  gap: 6px;

  overflow: visible !important;
  max-height: none !important;
}

.more-panel .menu-item{
  display:flex;
  align-items:center;
  gap:10px;
  width:100%;
  padding: 10px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.03);
  color: var(--text);
  cursor:pointer;
}
.more-panel .menu-item:hover{
  background: rgba(255,255,255,.06);
  border-color: rgba(255,255,255,.14);
}
.more-panel .menu-item.danger{
  background: rgba(231,76,60,.12);
  border-color: rgba(231,76,60,.22);
  color:#ffd0cc;
}
.more-panel .menu-item.success{
  background: rgba(46,204,113,.14);
  border-color: rgba(46,204,113,.26);
  color:#b9ffcf;
}

/* Ensure icons inside “more” dropdown always show */
.more-panel .menu-item svg,
.more-panel .menu-item .icon{
  display:inline-block !important;
  width:18px !important;
  height:18px !important;
  min-width:18px !important;
  min-height:18px !important;
  opacity:1 !important;
  visibility:visible !important;
  flex:0 0 18px !important;
}
.more-panel .menu-item svg,
.more-panel .menu-item svg *{
  fill: currentColor !important;
}

/* =========================================================
   Mobile: table becomes cards
   ========================================================= */
@media (max-width: 900px){
  .table-wrap{
    overflow: visible;
  }
  .table{ min-width: 0; }
  .table thead{display:none;}
  .table, .table tbody, .table tr, .table td{display:block;width:100%;}
  .table tr{
    border:1px solid var(--line);
    border-radius:14px;
    padding:.75rem;
    margin-bottom:.75rem;
    background:rgba(255,255,255,.02);
    cursor: default;
  }
  .table td{
    border-bottom:none;
    padding:.5rem .25rem;

    display:flex;
    gap:.75rem;
    justify-content:space-between;
    align-items:flex-start;

    white-space:normal;
    overflow:visible;
    text-overflow:unset;
  }
  .cell-ellip{
    max-width:none;
    overflow:visible;
    text-overflow:unset;
    white-space:normal;
  }
  .table td::before{
    content:attr(data-label);
    color:var(--muted);
    font-size:.75rem;
    font-weight:900;
    text-transform:uppercase;
    letter-spacing:.35px;
    flex:0 0 42%;
    max-width:42%;
    line-height:1.25;
  }
  .table td > *{ flex:1 1 auto; min-width:0; text-align:right; }

  td.actions-cell{
    margin-top:.4rem;
    padding-top:.65rem !important;
    border-top:1px solid var(--line);
    text-align:left;
  }
  td.actions-cell::before{display:none;}
  .actions-inline{justify-content:flex-start;flex-wrap:wrap;gap:10px;}

  .more-panel{
    position: static;
    width: 100%;
    max-width: none;
    margin-top: .5rem;
  }
}

/* =========================================================
   HARD STOP: kill any generic scroll wrappers
   ========================================================= */
.scroll,
.scroll-y,
.table-scroll,
.card-scroll{
  height:auto !important;
  max-height:none !important;
  overflow:visible !important;
}

/* =========================================================
   HOTFIX: make “more-panel” escape scroll container when open
   (Requires JS to set --mp-top/--mp-left/--mp-w if you use it)
   ========================================================= */
details.more[open] .more-panel{
  position: fixed;
  top: var(--mp-top, 0px);
  left: var(--mp-left, 0px);
  width: var(--mp-w, 240px);
  max-width: min(var(--mp-w, 240px), 90vw);
  right:auto;
  bottom:auto;
  z-index:5000;
}

/* =========================================================
   Customers legacy compatibility (minimal)
   ========================================================= */
.wrap{
  width:min(100% - (var(--pad-x) * 2), var(--container-max));
  margin:clamp(14px,3vw,22px) auto;
  height:auto !important;
  min-height:0 !important;
}

/* customers.php element selectors */
.wrap input[type="text"],
.wrap input[type="number"],
.wrap select{
  width:100%;
  padding:clamp(9px,2vw,10px) clamp(10px,2.2vw,12px);
  border-radius:var(--radius);
  border:1px solid var(--line);
  background:var(--surface);
  color:var(--text);
  outline:none;
}
.wrap input[type="text"]:focus,
.wrap input[type="number"]:focus,
.wrap select:focus{
  outline:2px solid var(--focus);
  outline-offset:2px;
  border-color:rgba(43,89,255,.25);
}

/* customers layout */
.pagehead{display:flex;align-items:flex-start;justify-content:space-between;gap:14px;flex-wrap:wrap;margin-bottom:14px}
.ph-left{min-width:260px}
.ph-title{display:flex;align-items:center;gap:10px}
.ph-title h1{font-size:20px;margin:0}
.ph-sub{margin-top:6px;color:var(--muted);display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.pillrow{margin-top:10px;display:flex;gap:10px;flex-wrap:wrap}

.tablewrap{
  margin-top:.9rem;
  overflow-x:auto;
  overflow-y:hidden;
  max-height:none !important;
  height:auto !important;
  -webkit-overflow-scrolling: touch;
  border-radius:12px;
}
.tablewrap table{
  border-collapse:collapse;
  width:100%;
  table-layout:auto;
  min-width: 720px;
}
.tablewrap th,.tablewrap td{
  padding:.75rem .6rem;
  border-bottom:1px solid var(--line);
  vertical-align:middle;
}
.tablewrap thead th{
  color:var(--muted);
  font-size:.78rem;
  letter-spacing:.2px;
  text-transform:none;
  white-space:nowrap;
}

/* Customers table wrapping */
.customers-table{
  table-layout:auto;
}
.customers-table td{
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: unset !important;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.customers-table .cell-ellip{
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: unset !important;
}
.customers-table thead th{
  white-space: nowrap !important;
}
.customers-table .actions-cell,
.customers-table th.th-actions{
  white-space: nowrap !important;
  width: 1%;
}
.customers-table .actions-inline{
  flex-wrap: nowrap;
}

/* Customers form responsive grid */
.customers-form-grid{
  display:grid;
  gap:10px;
  grid-template-columns: 1fr;
}
@media (min-width: 640px){
  .customers-form-grid{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1100px){
  .customers-form-grid{ grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.hint{
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
  opacity: .9;
}

/* =========================================================
   Helper text spacing
   ========================================================= */
.form-hint{
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
  margin-bottom: 14px;   /* ← key spacing */
  line-height: 1.4;
}


