/* WL Remesas — Mobile-native PWA CSS
   Based on super-app.css patterns from remesas-gateway
   --wl-accent overridden per agency via inline style
*/

:root {
  --wl-bg0:    #f4f5f7;
  --wl-bg1:    #ffffff;
  --wl-ink:    #0f1b2d;
  --wl-muted:  #6b7a90;
  --wl-accent: #f07800;       /* overridden by agency color_accent */
  --wl-accent2:#c45f00;
  --wl-aink:   #ffffff;
  --wl-line:   rgba(15,27,45,.10);
  --wl-danger: #d9382b;
  --wl-ok:     #1a9f5c;
  --wl-warn:   #c47f00;
  --wl-font:   "Outfit", system-ui, -apple-system, "Segoe UI", sans-serif;
  --wl-radius: 14px;
  --wl-pad:    max(16px, env(safe-area-inset-left));
  --wl-pad-r:  max(16px, env(safe-area-inset-right));
  --wl-pad-b:  max(92px, calc(76px + env(safe-area-inset-bottom)));
  --wl-shadow: 0 4px 16px rgba(15,27,45,.06);
}

html.wl-dark {
  --wl-bg0:   #0c1218;
  --wl-bg1:   #161e28;
  --wl-ink:   #f2f5f8;
  --wl-muted: #9aa8b8;
  --wl-line:  rgba(242,245,248,.12);
  --wl-shadow:0 4px 18px rgba(0,0,0,.35);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }

/* ── App shell ─────────────────────────────────────────────── */
body.wl-app {
  font-family: var(--wl-font);
  color: var(--wl-ink);
  background: var(--wl-bg0);
  padding: 0 var(--wl-pad-r) var(--wl-pad-b) var(--wl-pad);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* iOS / Android platform tweaks */
body.is-ios  { --wl-radius: 14px; }
body.is-android { --wl-radius: 12px; --wl-shadow: 0 2px 8px rgba(15,27,45,.10); }

/* ── Ambient background ────────────────────────────────────── */
.wl-ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 70% 40% at 0% 0%, color-mix(in srgb, var(--wl-accent) 10%, transparent), transparent 55%),
    linear-gradient(180deg, #f7f8fa 0%, #eef0f4 100%);
}
html.wl-dark .wl-ambient {
  background:
    radial-gradient(ellipse 70% 40% at 0% 0%, color-mix(in srgb, var(--wl-accent) 14%, transparent), transparent 55%),
    linear-gradient(180deg, #0c1218 0%, #0a1016 100%);
}

/* ── Header ─────────────────────────────────────────────────── */
.wl-top {
  position: relative; z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: max(18px, env(safe-area-inset-top)) 0 12px;
  gap: 12px;
  animation: wl-in .4s ease both;
}
.wl-top-brand {
  display: flex; align-items: center; gap: 10px;
  flex: 1;
  min-width: 0;
}
.wl-top-logo {
  width: 36px; height: 36px;
  object-fit: contain;
  border-radius: 8px;
  flex-shrink: 0;
}
.wl-top-name {
  font-weight: 700;
  font-size: 1.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--wl-ink);
}
.wl-top-actions {
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
.wl-btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px;
  border-radius: 999px;
  border: 1px solid var(--wl-line);
  background: var(--wl-bg1);
  color: var(--wl-ink);
  font-size: 1.05rem;
  cursor: pointer;
  box-shadow: var(--wl-shadow);
}
.wl-btn-icon:active { transform: scale(.96); }

/* ── Tab Bar ─────────────────────────────────────────────────── */
.wl-tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  background: var(--wl-bg1);
  border-top: 1px solid var(--wl-line);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -4px 16px rgba(15,27,45,.06);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
html.wl-dark .wl-tabbar {
  background: rgba(22,30,40,.95);
}
body.is-android .wl-tabbar {
  box-shadow: 0 -2px 8px rgba(0,0,0,.18);
}
.wl-tab {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  min-height: 54px;
  padding: 8px 4px 6px;
  font-size: .68rem;
  font-weight: 500;
  color: var(--wl-muted);
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: none;
  transition: color .15s;
}
.wl-tab .wl-tab-icon { font-size: 1.3rem; line-height: 1; }
.wl-tab.active,
.wl-tab:hover { color: var(--wl-accent); }
.wl-tab.active .wl-tab-icon { font-size: 1.45rem; }

/* ── Cards ───────────────────────────────────────────────────── */
.wl-card {
  background: var(--wl-bg1);
  border-radius: var(--wl-radius);
  box-shadow: var(--wl-shadow);
  border: 1px solid var(--wl-line);
  padding: 20px;
  margin-bottom: 14px;
  position: relative; z-index: 1;
  animation: wl-in .4s ease both;
}
.wl-card-title {
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--wl-muted);
  margin-bottom: 8px;
}
.wl-big-num {
  font-size: 2rem;
  font-weight: 800;
  color: var(--wl-accent);
  line-height: 1.1;
}

/* ── Flash ───────────────────────────────────────────────────── */
.wl-flash {
  position: relative; z-index: 1;
  border-radius: 10px;
  padding: 11px 16px;
  font-size: .88rem;
  font-weight: 500;
  margin-bottom: 12px;
  animation: wl-in .3s ease both;
}
.wl-flash.ok   { background: #d4f4e3; color: #0d5c34; }
.wl-flash.err  { background: #fde8e6; color: #8b1a12; }
.wl-flash.warn { background: #fef3cd; color: #7a4f00; }
.wl-flash.info { background: #e8f0fe; color: #1a3c8a; }
html.wl-dark .wl-flash.ok   { color: #8fd9b0; background: rgba(143,217,176,.12); }
html.wl-dark .wl-flash.err  { color: #ffb0a8; background: rgba(255,176,168,.12); }
html.wl-dark .wl-flash.warn { color: #ffc28a; background: rgba(255,194,138,.12); }

/* ── Forms ───────────────────────────────────────────────────── */
.wl-field { margin-bottom: 16px; }
.wl-label {
  display: block;
  font-size: .8rem; font-weight: 600;
  color: var(--wl-muted);
  margin-bottom: 5px;
}
.wl-input, .wl-select {
  width: 100%;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--wl-line);
  background: var(--wl-bg0);
  color: var(--wl-ink);
  font-size: .95rem;
  font-family: var(--wl-font);
  transition: border-color .15s;
  outline: none;
}
.wl-input:focus, .wl-select:focus {
  border-color: var(--wl-accent);
  background: var(--wl-bg1);
}
html.wl-dark .wl-input, html.wl-dark .wl-select {
  background: #0f1a24; border-color: rgba(242,245,248,.12);
}

/* ── Buttons ─────────────────────────────────────────────────── */
.wl-btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 10px;
  border: none;
  background: var(--wl-accent);
  color: var(--wl-aink);
  font-size: .95rem;
  font-weight: 700;
  font-family: var(--wl-font);
  cursor: pointer;
  transition: transform .12s, opacity .12s;
  text-decoration: none;
}
.wl-btn:active { transform: scale(.97); opacity: .9; }
.wl-btn.full   { width: 100%; }
.wl-btn.secondary {
  background: var(--wl-bg1);
  color: var(--wl-ink);
  border: 1.5px solid var(--wl-line);
}
.wl-btn.danger { background: var(--wl-danger); }
.wl-btn.sm     { padding: 8px 14px; font-size: .82rem; }

/* ── Bottom sheet ────────────────────────────────────────────── */
.wl-sheet-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.35);
  backdrop-filter: blur(2px);
}
.wl-sheet-overlay.open { display: block; }
.wl-sheet {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 201;
  background: var(--wl-bg1);
  border-radius: var(--wl-radius) var(--wl-radius) 0 0;
  padding: 20px var(--wl-pad) max(28px, calc(16px + env(safe-area-inset-bottom)));
  transform: translateY(110%);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  max-height: 85dvh;
  overflow-y: auto;
}
.wl-sheet.open { transform: translateY(0); }
.wl-sheet-handle {
  width: 36px; height: 4px;
  border-radius: 999px;
  background: var(--wl-line);
  margin: 0 auto 16px;
}
.wl-sheet-title {
  font-size: 1.1rem; font-weight: 700;
  margin-bottom: 16px;
  color: var(--wl-ink);
}

/* ── List rows ───────────────────────────────────────────────── */
.wl-list { list-style: none; }
.wl-list-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 0;
  border-bottom: 1px solid var(--wl-line);
  gap: 10px;
}
.wl-list-row:last-child { border-bottom: none; }
.wl-list-label { font-weight: 600; font-size: .9rem; }
.wl-list-sub   { font-size: .78rem; color: var(--wl-muted); margin-top: 2px; }
.wl-list-val   { font-size: .9rem; color: var(--wl-muted); flex-shrink: 0; }

/* ── Status pills ────────────────────────────────────────────── */
.wl-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .72rem; font-weight: 700;
  letter-spacing: .03em;
}
.wl-pill.ok       { background: #d4f4e3; color: #0d5c34; }
.wl-pill.pending  { background: #fef3cd; color: #7a4f00; }
.wl-pill.failed   { background: #fde8e6; color: #8b1a12; }
html.wl-dark .wl-pill.ok      { background: rgba(143,217,176,.18); color: #8fd9b0; }
html.wl-dark .wl-pill.pending { background: rgba(255,194,138,.14); color: #ffc28a; }
html.wl-dark .wl-pill.failed  { background: rgba(255,176,168,.14); color: #ffb0a8; }

/* ── Admin / Agency panel ───────────────────────────────────── */
.wl-panel {
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 28px 60px;
  font-family: var(--wl-font);
  color: var(--wl-ink);
  background: transparent;
  min-height: 0;
  flex: 1;
  min-width: 0;
}
.wl-panel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-bottom: 24px; }
.wl-stat-card {
  background: var(--wl-bg1);
  border-radius: var(--wl-radius);
  border: 1px solid var(--wl-line);
  padding: 18px 20px;
  box-shadow: var(--wl-shadow);
}
.wl-stat-card .label { font-size: .78rem; color: var(--wl-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.wl-stat-card .value { font-size: 1.7rem; font-weight: 800; color: var(--wl-ink); }
.wl-stat-card .value.accent { color: var(--wl-accent); }
.wl-h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 14px; }
.wl-table-wrap { overflow-x: auto; }
.wl-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.wl-table th { text-align: left; padding: 10px 12px; background: var(--wl-bg0); font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--wl-muted); border-bottom: 1px solid var(--wl-line); }
.wl-table td { padding: 11px 12px; border-bottom: 1px solid var(--wl-line); vertical-align: middle; }
.wl-table tr:last-child td { border-bottom: none; }
.wl-section { background: var(--wl-bg1); border-radius: var(--wl-radius); border: 1px solid var(--wl-line); padding: 20px 24px; margin-bottom: 20px; box-shadow: var(--wl-shadow); }

/* ── Login page ──────────────────────────────────────────────── */
.wl-login-wrap {
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: var(--wl-bg0);
  font-family: var(--wl-font);
}
.wl-login-box {
  width: 100%; max-width: 380px;
  background: var(--wl-bg1);
  border-radius: 20px;
  padding: 36px 28px 28px;
  box-shadow: 0 8px 40px rgba(15,27,45,.12);
  text-align: center;
}
.wl-login-logo {
  width: 72px; height: 72px;
  object-fit: contain;
  border-radius: 16px;
  margin-bottom: 14px;
}
.wl-login-name {
  font-size: 1.3rem; font-weight: 800; margin-bottom: 6px;
}
.wl-login-sub {
  font-size: .85rem; color: var(--wl-muted); margin-bottom: 24px;
}
.wl-login-box .wl-field { text-align: left; }

/* ── Animations ──────────────────────────────────────────────── */
@keyframes wl-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Responsive: tablet/desktop panel ───────────────────────── */
@media (min-width: 640px) {
  .wl-panel-grid { grid-template-columns: repeat(4, 1fr); }
  .wl-login-box  { padding: 44px 40px 36px; }
}

/* ── Agency panel body / sidebar layout ─────────────────────── */
body.wl-panel-body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--wl-font);
  background: var(--wl-bg0);
  color: var(--wl-ink);
}
.wl-layout {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}
.wl-topbar {
  display: none;
}
.wl-sidebar {
  width: 220px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background: var(--wl-bg1);
  border-right: 1px solid var(--wl-line);
  z-index: 60;
}
.wl-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 14px;
  padding-top: max(18px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--wl-line);
  min-width: 0;
}
.wl-sidebar-brand .wl-nav-logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: 8px;
  flex-shrink: 0;
}
.wl-nav-logo-fallback {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--wl-accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.wl-sidebar-brand .wl-nav-title {
  font-weight: 700;
  font-size: .95rem;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.wl-sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 10px;
  flex: 1;
}
.wl-sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: .88rem;
  font-weight: 500;
  color: var(--wl-muted);
  text-decoration: none;
  transition: background .12s, color .12s;
}
.wl-sidebar-nav a i {
  width: 1.1em;
  text-align: center;
  flex-shrink: 0;
}
.wl-sidebar-nav a:hover {
  background: color-mix(in srgb, var(--wl-accent) 10%, transparent);
  color: var(--wl-accent);
}
.wl-sidebar-nav a.active {
  background: color-mix(in srgb, var(--wl-accent) 14%, transparent);
  color: var(--wl-accent);
  font-weight: 600;
}
.wl-sidebar-footer {
  margin-top: auto;
  padding: 12px 10px max(14px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--wl-line);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.wl-sidebar-footer .wl-theme-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  justify-content: flex-start;
  padding: 10px 14px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--wl-muted);
  font-family: var(--wl-font);
  font-size: .88rem;
  font-weight: 500;
  cursor: pointer;
}
.wl-sidebar-footer .wl-theme-toggle:hover {
  background: color-mix(in srgb, var(--wl-accent) 10%, transparent);
  color: var(--wl-accent);
}
.wl-sidebar-footer a.wl-nav-logout {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: .88rem;
  font-weight: 500;
  color: var(--wl-danger);
  text-decoration: none;
}
.wl-sidebar-footer a.wl-nav-logout:hover {
  background: rgba(217, 56, 43, .08);
}
.wl-sidebar-overlay {
  display: none;
}
.wl-page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.wl-page-title {
  font-size: 1.35rem;
  font-weight: 800;
  margin: 0 0 4px;
}
.wl-page-sub {
  margin: 0;
  font-size: .88rem;
  color: var(--wl-muted);
}
.wl-page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.wl-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.wl-section-head .wl-h2 { margin-bottom: 0; }
.wl-stat-meta {
  font-size: .75rem;
  color: var(--wl-muted);
  margin-top: 4px;
}
.wl-kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.wl-kv-label {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--wl-muted);
  margin-bottom: 4px;
}
.wl-kv-value { font-size: 1.05rem; font-weight: 700; }
.wl-empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--wl-muted);
}
.wl-empty i { font-size: 2.2rem; margin-bottom: 10px; display: block; }
.wl-muted-cell { font-size: .8rem; color: var(--wl-muted); }
.wl-row-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.wl-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.wl-form-grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.wl-form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.wl-field-hint {
  font-size: .73rem;
  color: var(--wl-muted);
  margin-top: 4px;
}
.wl-hr {
  border: none;
  border-top: 1px solid var(--wl-line);
  margin: 20px 0;
}
.wl-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}
.wl-filters .wl-field { min-width: 140px; flex: 1; }
.wl-filters-actions { display: flex; gap: 8px; padding-bottom: 2px; }
.wl-radio-row { display: flex; gap: 14px; margin-top: 6px; flex-wrap: wrap; }
.wl-radio { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.wl-color-row { display: flex; align-items: center; gap: 10px; }
.wl-color-row input[type=color] {
  width: 52px; height: 38px;
  border-radius: 8px;
  border: 1.5px solid var(--wl-line);
  padding: 2px;
  cursor: pointer;
  background: var(--wl-bg0);
}
.wl-color-swatch {
  width: 28px; height: 28px;
  border-radius: 8px;
  border: 1px solid var(--wl-line);
}
.wl-logo-preview {
  margin-bottom: 10px;
}
.wl-logo-preview img {
  max-width: 140px;
  max-height: 64px;
  object-fit: contain;
  border-radius: 8px;
  background: var(--wl-bg0);
  padding: 6px;
  border: 1px solid var(--wl-line);
}
.wl-calc-box {
  background: var(--wl-bg0);
  border-radius: 10px;
  padding: 14px 16px;
  margin: 16px 0;
  font-size: .85rem;
  border: 1px solid var(--wl-line);
}
.wl-calc-title { font-weight: 700; margin-bottom: 8px; }

@media (max-width: 820px) {
  .wl-layout { display: block; }
  .wl-topbar {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 80;
    align-items: center;
    gap: 10px;
    height: 56px;
    padding: 0 12px;
    padding-top: env(safe-area-inset-top);
    height: calc(56px + env(safe-area-inset-top));
    background: var(--wl-bg1);
    border-bottom: 1px solid var(--wl-line);
    box-shadow: var(--wl-shadow);
  }
  .wl-drawer-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    border: 1px solid var(--wl-line);
    background: var(--wl-bg0);
    color: var(--wl-ink);
    cursor: pointer;
    flex-shrink: 0;
  }
  .wl-topbar-title {
    flex: 1;
    min-width: 0;
    font-weight: 700;
    font-size: 1rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .wl-topbar .wl-theme-toggle {
    flex-shrink: 0;
  }
  .wl-sidebar {
    position: fixed;
    left: -260px;
    top: 0;
    width: 240px;
    height: 100vh;
    height: 100dvh;
    z-index: 200;
    transition: left .25s ease;
    box-shadow: none;
    border-right: 1px solid var(--wl-line);
  }
  .wl-sidebar.open {
    left: 0;
    box-shadow: 4px 0 24px rgba(0, 0, 0, .18);
  }
  .wl-sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 199;
    background: rgba(0, 0, 0, .35);
    display: none;
  }
  .wl-sidebar-overlay.open { display: block; }
  .wl-sidebar-footer .wl-theme-toggle { display: none; }
  .wl-panel {
    padding: 20px 16px 48px;
    max-width: none;
  }
  .wl-form-grid { grid-template-columns: 1fr; }
  .wl-panel-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .wl-panel-grid { grid-template-columns: 1fr; }
  .wl-page-head { flex-direction: column; }
}
