/* =========================================================================
   IBIS Admin PWA v4 — Native Mobile / Galaxy Z Fold / Desktop Command UI
   Glass Switches, 2x2 Balanced KPIs, Mail/Social Hub, Floating AI Nuvoleta
   ========================================================================= */
:root {
  --bg: #05070c;
  --border: rgba(255, 255, 255, 0.11);
  --border-hi: rgba(255, 255, 255, 0.22);
  --text: #f8fafc;
  --muted: #94a3b8;
  --cyan: #38bdf8;
  --indigo: #818cf8;
  --green: #34d399;
  --red: #f87171;
  --gold: #eab308;
  --radius: 18px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.45;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.adm-bg-glow {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 75% 45% at 15% 5%, rgba(56, 189, 248, 0.16), transparent 60%),
    radial-gradient(ellipse 65% 45% at 85% 90%, rgba(129, 140, 248, 0.14), transparent 60%),
    radial-gradient(ellipse 50% 40% at 55% 45%, rgba(234, 179, 8, 0.06), transparent 68%);
}

/* HEADER */
.adm-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: calc(56px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 14px 0;
  background: rgba(6, 9, 16, 0.84);
  backdrop-filter: blur(24px) saturate(170%);
  -webkit-backdrop-filter: blur(24px) saturate(170%);
  border-bottom: 1px solid var(--border);
}
.adm-brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.adm-brand img { border-radius: 50%; object-fit: cover; border: 1.5px solid rgba(250, 204, 21, 0.55); flex-shrink: 0; }
.adm-title { font-weight: 700; font-size: 0.96rem; white-space: nowrap; letter-spacing: -0.02em; }
.adm-pill-live {
  font-family: var(--mono);
  font-size: 0.64rem;
  font-weight: 700;
  color: #a7f3d0;
  background: rgba(52, 211, 153, 0.14);
  border: 1px solid rgba(52, 211, 153, 0.35);
  padding: 2px 7px;
  border-radius: 999px;
}
@media (max-width: 340px) { .adm-pill-live { display: none; } }

.adm-header-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  text-decoration: none;
  flex-shrink: 0;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.12); }
.icon-btn.active { border-color: var(--cyan); color: var(--cyan); background: rgba(56, 189, 248, 0.16); }
.icon-btn-danger { border-color: rgba(248, 113, 113, 0.38); color: #fecaca; background: rgba(248, 113, 113, 0.12); }
.notif-btn { position: relative; }
.notif-badge {
  position: absolute;
  top: -4px; right: -4px;
  min-width: 17px; height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  border: 1.5px solid #05070c;
}

/* CARDS */
.glass-card {
  position: relative;
  z-index: 1;
  background: linear-gradient(155deg, rgba(22, 31, 52, 0.68), rgba(10, 14, 24, 0.82));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.11), 0 14px 36px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(22px) saturate(155%);
  -webkit-backdrop-filter: blur(22px) saturate(155%);
}
.glass-card h2 { font-size: 0.96rem; margin-bottom: 12px; letter-spacing: -0.01em; }
.card-head-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card-head-row h2 { margin-bottom: 0; }
.mt-12 { margin-top: 12px; }
.mb-10 { margin-bottom: 10px; }

/* LOGIN */
.adm-login-wrap { padding: 36px 14px; position: relative; z-index: 2; }
.adm-login-card { max-width: 420px; margin: 0 auto; padding: 22px; }
.login-brand-hero { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.login-brand-hero img { border-radius: 50%; object-fit: cover; border: 1.5px solid rgba(250, 204, 21, 0.55); }
.login-brand-hero h1 { font-size: 1.35rem; line-height: 1.15; }

/* SHELL */
.adm-shell {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  min-height: calc(100dvh - 56px);
}
.adm-nav {
  padding: 16px 10px;
  border-right: 1px solid var(--border);
  background: rgba(8, 12, 22, 0.62);
  backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.nav-item {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-family: var(--font);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
}
.nav-item svg { flex-shrink: 0; }
.nav-item.active {
  color: #ffffff;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.22), rgba(129, 140, 248, 0.18));
  border-color: rgba(56, 189, 248, 0.45);
}
.adm-content {
  padding: 20px 18px 96px;
  max-width: 1040px;
  width: 100%;
  margin: 0 auto;
  min-width: 0;
}

@media (max-width: 839px) {
  .adm-shell { display: block; }
  .adm-content { padding: 14px 12px calc(134px + env(safe-area-inset-bottom)); }
  .adm-nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 40;
    flex-direction: row;
    border-right: none;
    border-top: 1px solid var(--border-hi);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: rgba(7, 10, 18, 0.94);
    backdrop-filter: blur(26px) saturate(180%);
    -webkit-backdrop-filter: blur(26px) saturate(180%);
    gap: 2px;
  }
  .nav-item {
    flex: 1 1 0;
    min-width: 0;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    padding: 6px 2px;
    font-size: 0.64rem;
    border-radius: 10px;
  }
  .nav-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
}

.panel-head { margin-bottom: 14px; }
.panel-head h1 { font-size: 1.3rem; letter-spacing: -0.025em; }
.muted { color: var(--muted); font-size: 0.8rem; }

/* SUBTABS */
.subtab-bar {
  display: flex;
  gap: 6px;
  padding: 4px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  margin-bottom: 14px;
}
.subtab-btn {
  flex: 1 1 0;
  min-height: 38px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.subtab-btn.active {
  color: #fff;
  background: rgba(56, 189, 248, 0.18);
  border-color: rgba(56, 189, 248, 0.42);
}

/* 4 RADIAL PERCENTAGE RINGS */
.rings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
@media (min-width: 980px) { .rings-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 310px) { .rings-grid { grid-template-columns: 1fr; } }

.ring-card {
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 14px 8px;
}
.ring-wrap { position: relative; width: 84px; height: 84px; }
.ring-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(255, 255, 255, 0.08); stroke-width: 8; }
.ring-fg { fill: none; stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 0.7s cubic-bezier(0.22, 1, 0.36, 1); }
.ring-gold { stroke: var(--gold); filter: drop-shadow(0 0 6px rgba(234, 179, 8, 0.55)); }
.ring-green { stroke: var(--green); filter: drop-shadow(0 0 6px rgba(52, 211, 153, 0.55)); }
.ring-cyan { stroke: var(--cyan); filter: drop-shadow(0 0 6px rgba(56, 189, 248, 0.55)); }
.ring-indigo { stroke: var(--indigo); filter: drop-shadow(0 0 6px rgba(129, 140, 248, 0.55)); }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-center strong { font-size: 1rem; line-height: 1.1; }
.ring-center span { font-size: 0.62rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.ring-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; width: 100%; }
.ring-title { font-size: 0.72rem; color: var(--muted); font-weight: 600; }
.ring-meta strong { font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* SYMMETRIC 2x2 KPI GRID (NO ORPHAN CARDS!) */
.kpi-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
@media (min-width: 760px) { .kpi-grid-2 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi-mini { margin-bottom: 0; padding: 13px; }
.kpi-lbl { display: block; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.kpi-mini strong { display: block; font-size: 1.2rem; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-green { color: var(--green); }
.c-cyan { color: var(--cyan); }
.c-gold { color: var(--gold); }
.c-red { color: var(--red); }

/* MOBILE CARD LISTS */
.mobile-list { display: flex; flex-direction: column; gap: 10px; }
.item-card {
  padding: 13px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.item-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.item-code { font-family: var(--mono); font-size: 0.76rem; color: #7dd3fc; word-break: break-all; }
.item-sub { font-size: 0.78rem; color: var(--muted); word-break: break-word; }
.item-actions { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; }

/* FORMS, GLASS SWITCHES & SLIDER */
.adm-form { display: flex; flex-direction: column; gap: 12px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 600px) { .settings-grid { grid-template-columns: 1fr; } }
.form-col-full, .form-actions { grid-column: 1 / -1; }

.field-lbl { display: block; font-size: 0.78rem; color: var(--muted); margin-bottom: 5px; font-weight: 500; }
.field {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(6, 9, 16, 0.82);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.88rem;
}
.field:focus { outline: none; border-color: rgba(56, 189, 248, 0.65); }
.field-area { min-height: 84px; resize: vertical; line-height: 1.45; }
.field-compact { width: 74px; flex-shrink: 0; text-align: center; }
.inline-presets { display: flex; gap: 6px; align-items: center; }
.range-row { display: flex; align-items: center; gap: 10px; }
.range-slider { flex: 1; accent-color: var(--cyan); height: 6px; cursor: pointer; }

/* SLEEK iOS/GLASS PILL SWITCHES */
.switch-list {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  cursor: pointer;
}
.switch-row-danger { border-color: rgba(248, 113, 113, 0.28); background: rgba(248, 113, 113, 0.05); }
.switch-info { display: flex; flex-direction: column; min-width: 0; }
.switch-info strong { font-size: 0.86rem; font-weight: 600; }
.switch-info small { font-size: 0.72rem; }

.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid var(--border-hi);
  transition: background 0.22s ease;
}
.slider::before {
  content: "";
  position: absolute;
  width: 20px; height: 20px;
  left: 2px; top: 2px;
  border-radius: 50%;
  background: #f8fafc;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}
.switch input:checked + .slider { background: linear-gradient(135deg, #38bdf8, #818cf8); border-color: transparent; }
.switch input:checked + .slider-danger { background: linear-gradient(135deg, #ef4444, #f97316); border-color: transparent; }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* CHIPS & CHECKABLE PILLS */
.chips-grid { display: flex; flex-wrap: wrap; gap: 7px; }
.status-pill { padding: 5px 11px; border-radius: 999px; font-size: 0.74rem; font-weight: 600; border: 1px solid var(--border); background: rgba(255, 255, 255, 0.04); }
.status-pill.on { border-color: rgba(52, 211, 153, 0.45); color: #a7f3d0; background: rgba(52, 211, 153, 0.12); }
.status-pill.off { color: var(--muted); }
.chip-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.76rem;
  cursor: pointer;
}
.chip-check input { accent-color: var(--cyan); }

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
}
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 0.75rem; }
.btn-full { width: 100%; }
.btn-primary { background: #f8fafc; color: #05070c; }
.btn-secondary { background: rgba(255, 255, 255, 0.08); color: var(--text); border-color: var(--border); }
.btn-danger { background: rgba(248, 113, 113, 0.16); color: #fecaca; border-color: rgba(248, 113, 113, 0.45); }

.pill-ok { color: var(--green); font-weight: 600; font-size: 0.76rem; }
.pill-bad { color: var(--red); font-weight: 600; font-size: 0.76rem; }
.status-msg { font-size: 0.82rem; min-height: 18px; margin-top: 6px; }
.status-msg.err { color: var(--red); }
.status-msg.ok { color: var(--green); }

.adm-banner {
  padding: 11px 14px;
  border-radius: 12px;
  margin-bottom: 14px;
  border: 1px solid rgba(52, 211, 153, 0.45);
  background: rgba(52, 211, 153, 0.14);
  color: #a7f3d0;
  font-size: 0.84rem;
}
.adm-banner.err { border-color: rgba(248, 113, 113, 0.45); background: rgba(248, 113, 113, 0.14); color: #fecaca; }

/* FLOATING IBIS AI AGENT NUVOLETA & DRAWER */
.agent-fab {
  position: fixed;
  right: 14px;
  bottom: calc(74px + env(safe-area-inset-bottom));
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 48px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid rgba(56, 189, 248, 0.55);
  background: linear-gradient(135deg, rgba(14, 27, 48, 0.94), rgba(30, 41, 74, 0.94));
  color: #e0f2fe;
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(56, 189, 248, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(18px);
  cursor: pointer;
}
@media (min-width: 840px) { .agent-fab { bottom: 22px; right: 22px; } }

.agent-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(2, 4, 10, 0.65);
  backdrop-filter: blur(6px);
}
.agent-drawer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 70;
  max-width: 520px;
  margin: 0 auto;
  height: min(82dvh, 640px);
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(14, 20, 36, 0.97), rgba(6, 9, 16, 0.99));
  border: 1px solid var(--border-hi);
  border-bottom: none;
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.72);
  padding: 14px 14px calc(12px + env(safe-area-inset-bottom));
}
.agent-drawer[hidden], .agent-backdrop[hidden] { display: none; }

.agent-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.agent-head-l { display: flex; align-items: center; gap: 10px; }
.agent-head-r { display: flex; gap: 6px; }
.agent-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 10px var(--cyan); }

.agent-modes { display: flex; gap: 6px; margin-bottom: 8px; overflow-x: auto; }
.mode-pill {
  flex: 1 0 auto;
  min-height: 32px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
}
.mode-pill.active { color: #fff; background: rgba(56, 189, 248, 0.22); border-color: rgba(56, 189, 248, 0.55); }

.agent-quick-row { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 6px; }
.quick-chip {
  flex: 0 0 auto;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: #cbd5e1;
  font-size: 0.72rem;
  cursor: pointer;
}

.agent-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 6px 2px;
}
.msg-bubble {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 0.82rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-user { align-self: flex-end; background: linear-gradient(135deg, rgba(56, 189, 248, 0.25), rgba(129, 140, 248, 0.25)); border: 1px solid rgba(56, 189, 248, 0.4); }
.msg-bot { align-self: flex-start; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border); }
.msg-img { max-width: 180px; border-radius: 10px; margin-bottom: 6px; display: block; border: 1px solid var(--border); }

.agent-preview-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  margin-bottom: 8px;
}
.agent-preview-bar img { width: 36px; height: 36px; object-fit: cover; border-radius: 6px; }

.agent-input-bar { display: flex; align-items: center; gap: 6px; padding-top: 8px; border-top: 1px solid var(--border); }
.agent-text-field { min-height: 40px; padding: 8px 12px; border-radius: 999px; }
.btn-send { min-height: 40px; width: 42px; padding: 0; flex-shrink: 0; }

/* SMARTPHONE-STYLE PHOTO GALLERY FOR DEMO SCREENSHOTS */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
@media (max-width: 340px) { .gallery-grid { grid-template-columns: 1fr; } }
.gallery-tile {
  border-radius: 14px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.gallery-tile-img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: #05070c;
  display: block;
}
.gallery-tile-body {
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.gallery-tile-title { font-size: 0.76rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gallery-tile-btns { display: flex; gap: 6px; }
.gallery-tile-btns .btn { flex: 1; min-height: 32px; padding: 4px 8px; font-size: 0.72rem; }
