/* static/smsex.css — FINAL revision with single glowing "S" loader
   - Only the logo (".logo.small" inside .loading-box) pulses/glows during loading.
   - Removed rotating ring and three-dot animations.
   - No JS/HTML changes required; uses existing .loading-overlay/.loading-box markup.
   - All other functionality and layout rules kept as before.
*/

/* Theme & width tokens ---------------------------------------------------- */
:root{
  --bg:#0a0f1e;
  --panel-bg: linear-gradient(180deg, rgba(16,22,44,.92), rgba(10,16,30,.92));
  --text:#e7ecf7;
  --muted:#9fb0c9;
  --border:rgba(255,255,255,.08);
  --brand:#8ab4ff;
  --brand2:#8effe1;
  --glass: rgba(255,255,255,0.02);

  /* layout */
  --nav-height:64px;
  --right-col-width:360px;
  --gutter:20px;

  /* Table sizing variables YOU CAN EDIT:
     - --table-cell-min-width: the minimum width considered for each column (only used when resizing, not forcing)
     - --table-cell-max-width: default max width before wrapping
     - --table-row-padding: padding used to compute row height (px)
     - --table-row-line-height: line-height inside cells
  */
  --table-cell-min-width: 80px;
  --table-cell-max-width: 520px;
  --table-row-padding: 10px;      /* vertical padding inside each cell (px) */
  --table-row-line-height: 1.3;   /* line height for cells */

  /* Loading animation tokens */
  --loader-size: 48px;
  --loader-accent: var(--brand);
  --loader-accent-2: var(--brand2);
  --loader-duration: 1.4s;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Prevent page horizontal scroll; internal app-shell handles scroll */
body {
  overflow-x: hidden;
  overflow-y: hidden;
}

/* container uses nearly full viewport width to reduce side whitespace */
.container {
  width: calc(100% - 48px);
  max-width: none;
  margin: 0 auto;
  padding: 0 24px;
}

/* decorative background */
.bg { position: fixed; inset: 0; z-index: -60; pointer-events: none; }
.mesh, .grid, .blob, .spark { pointer-events: none; user-select: none; }

/* ---------- NAV ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 90;
  background: linear-gradient(180deg, rgba(10,15,30,.95), rgba(10,15,30,.45));
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  height: var(--nav-height);
  display:flex;
  align-items:center;
  justify-content:space-between;
  width: 100%;
  margin: 0 auto;
  padding: 0 12px;
}
.brand { display:flex; align-items:center; gap:12px; text-decoration:none; color:var(--text); }
.logo { width:36px; height:36px; border-radius:12px; display:grid; place-items:center;
        background: linear-gradient(135deg, var(--brand), var(--brand2)); color:#06101a; font-weight:900; box-shadow: 0 6px 12px #8ab4ff33; }

/* Back link restored & styled */
.links { display:flex; gap:12px; align-items:center; }
.links a {
  color: #b48aff;
  text-decoration: none;
  font-weight:700;
  font-size:14px;
  padding:6px 8px;
  border-radius:8px;
}
.links a:hover {
  color:#fff;
  background: rgba(138,180,255,0.03);
  text-decoration: underline;
}

/* ---------- APP SHELL ---------- */
.app-shell {
  height: calc(100vh - var(--nav-height));
  padding-top: 12px;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* ---------- GRID ---------- */
.app-grid {
  display: grid;
  grid-template-columns: 1fr var(--right-col-width);
  gap: var(--gutter);
  align-items: start;
  padding: 12px 12px 36px;
  width: calc(100% - 48px);
  margin: 0 auto;
}

/* Prevent children from forcing layout expansion */
.app-grid, .left-col, .right-col { min-width: 0; }

/* ---------- PANELS ---------- */
.panel {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 26px rgba(0,0,0,0.45);
  overflow: hidden;
}
.panel-inner { padding: 16px; }

/* ---------- HEADINGS ---------- */
.badge { display:inline-block; padding:6px 10px; border-radius:999px; font-weight:800; font-size:12px; color:#08121a; background:linear-gradient(135deg,var(--brand),var(--brand2)); margin-bottom:10px; }
h1 { margin:6px 0 8px; font-size:20px; }
.sub { margin:0 0 12px; color:var(--muted); font-size:13px; }

/* ---------- LEFT COLUMN ---------- */
.left-col { display:flex; flex-direction:column; gap:12px; }

/* Textarea */
.textarea {
  width: 100%;
  max-width: 100%;
  min-height: 170px;
  border-radius: 10px;
  padding: 14px;
  background: var(--glass);
  border: 1px solid var(--border);
  color: var(--text);
  resize: vertical;
  font-size:14px;
  line-height:1.45;
  outline:none;
}
.textarea:focus { box-shadow: 0 6px 22px rgba(138,180,255,0.06); border-color: rgba(138,180,255,0.18); }

/* controls & buttons */
.controls { display:flex; gap:10px; margin-top:12px; align-items:center; flex-wrap:wrap; }
.muted-box { color:var(--muted); font-size:13px; }
.btn { position:relative; padding:10px 14px; border-radius:10px; text-decoration:none; border:1px solid var(--border); font-weight:800; color:var(--text); background:transparent; cursor:pointer; }
.btn.primary { background: linear-gradient(135deg,var(--brand),var(--brand2)); color:#06101a; border:none; box-shadow: 0 8px 20px rgba(138,180,255,0.06); }
.btn.ghost { background: rgba(255,255,255,0.02); }
.btn.small { padding:7px 10px; font-size:13px; border-radius:9px; }

/* error & raw output */
.error-panel { border:1px solid rgba(255,120,120,0.08); background: linear-gradient(180deg, rgba(32,10,10,0.18), rgba(18,8,8,0.06)); padding:12px; border-radius:8px; }
.raw-output { white-space: pre-wrap; background: rgba(255,255,255,0.02); padding:10px; border-radius:8px; border:1px solid rgba(255,255,255,0.03); color:var(--text); font-family: ui-monospace, Menlo, Monaco, "Roboto Mono", monospace; font-size:13px; }

/* ---------- TABLE AREA (VARIABLES + HELPERS) ----------
   YOU CAN CONTROL:
     - global default via CSS variables at :root (above)
     - per-column via helper classes below (e.g. add class 'col-w-150' on a <th> or <td>)
     - per-column min/max via 'col-min-###' or 'col-max-###'
     - per-row via 'row-tall' or the CSS variable --table-row-padding
*/

/* table wrapper */
.table-wrap { margin-top:14px; border-radius:10px; overflow:visible; border:1px solid var(--border); background: linear-gradient(180deg, rgba(16,22,44,.6), rgba(10,16,30,.45)); padding:12px; }

/* local scroll region (both axes) */
.table-scroll {
  max-height: 52vh;
  overflow-y: auto;
  overflow-x: auto;
  border-radius:8px;
  padding-right:6px;
  background: transparent;
  -webkit-overflow-scrolling: touch;
}

/* table: natural width (per header/data), will be scrollable inside .table-scroll */
.table-scroll table {
  width: max-content;
  min-width: 100%;
  table-layout: auto;
  border-collapse: collapse;
}

/* HEADERS: single-line (no wrap) */
.table-scroll thead th {
  white-space: nowrap;
  padding: calc(var(--table-row-padding) * 0.9) 12px;
  text-align:left;
  color:var(--muted);
  font-size:13px;
  background: rgba(10,12,18,0.6);
  position: sticky;
  top: 0;
  z-index: 3;
  border-bottom: 1px solid rgba(255,255,255,0.02);
  /* ensure header is positioned relative so resizer can be absolute */
  position: sticky;
  top: 0;
  z-index: 4;
}

/* resizer handle: positioned at right edge of th */
.table-scroll thead th { position: relative; }
.col-resizer {
  position: absolute;
  right: 0;
  top: 0;
  width: 10px;
  height: 100%;
  cursor: col-resize;
  z-index: 6;
  /* visual handle: subtle transparent stripe with hover highlight */
  background: linear-gradient(90deg, transparent 40%, rgba(255,255,255,0.03) 50%, transparent 60%);
}
.col-resizer:hover { background: linear-gradient(90deg, transparent 30%, rgba(255,255,255,0.06) 50%, transparent 70%); }

/* While resizing, show custom cursor */
body.col-resizing { cursor: col-resize !important; user-select: none; }

/* BODY CELLS: allow content to wrap, set padding/line-height from variables */
.table-scroll tbody td {
  white-space: normal;
  overflow-wrap: anywhere;
  padding: var(--table-row-padding) 12px;
  font-size:13px;
  color:var(--text);
  border-bottom: 1px dashed rgba(255,255,255,0.03);
  vertical-align: top;
  max-width: var(--table-cell-max-width);
  min-width: var(--table-cell-min-width);
  line-height: var(--table-row-line-height);
  word-break: break-word;
}

/* Utility: force nowrap (single-line ellipsis) on certain columns */
.table-scroll tbody td.nowrap {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Utility: let a column be very wide */
.table-scroll tbody td.wide {
  max-width: 980px;
}

/* ---------- HELPER CLASSES FOR COLUMNS (APPLY TO <th> or <td>) ----------
   Examples:
     <th class="col-w-150">amount</th>     -> sets exact min-width (150px)
     <th class="col-min-200">merchant</th> -> sets min-width (200px)
     <th class="col-max-400">sms_text</th> -> sets max-width (400px)
   These helpers are purely CSS and don't require JS.
*/
.col-w-80  { min-width: 80px;  max-width: 80px;  width: 80px;  }
.col-w-100 { min-width: 100px; max-width: 100px; width: 100px; }
.col-w-120 { min-width: 120px; max-width: 120px; width: 120px; }
.col-w-150 { min-width: 150px; max-width: 150px; width: 150px; }
.col-w-200 { min-width: 200px; max-width: 200px; width: 200px; }
.col-w-250 { min-width: 250px; max-width: 250px; width: 250px; }
.col-w-320 { min-width: 320px; max-width: 320px; width: 320px; }

/* min-only helpers */
.col-min-80  { min-width: 80px; }
.col-min-120 { min-width: 120px; }
.col-min-150 { min-width: 150px; }
.col-min-200 { min-width: 200px; }
.col-min-300 { min-width: 300px; }

/* max-only helpers */
.col-max-200 { max-width: 200px; }
.col-max-320 { max-width: 320px; }
.col-max-480 { max-width: 480px; }
.col-max-720 { max-width: 720px; }

/* Row helpers */
.row-tight { --table-row-padding: 6px; --table-row-line-height: 1.2; }
.row-normal { --table-row-padding: 10px; --table-row-line-height: 1.3; }
.row-tall { --table-row-padding: 16px; --table-row-line-height: 1.45; }

/* Small empty state */
.table-scroll .empty { padding:18px; color:var(--muted); }

/* ---------- RIGHT COLUMN ---------- */
.right-col { display:flex; flex-direction:column; gap:14px; position:relative; }
.right-col .panel { min-height:120px; }

/* parsed JSON & raw output area */
#parsed_json { max-height: 360px; overflow:auto; white-space: pre-wrap; word-break: break-word; }
#raw_output_right { max-height: 220px; overflow:auto; white-space: pre-wrap; word-break: break-word; }
#recent_list { margin:0; padding-left:18px; list-style: disc; color:var(--muted); max-height:120px; overflow:auto; }

/* ---------- SLEEK CSS-ONLY LOADER (SINGLE GLOWING "S") ----------
   Behavior:
     - .loading-overlay is shown by JS (display:flex) when parsing begins.
     - .loading-box contains the pulsing/glowing logo .logo.small
     - ring/dots removed per request
*/

/* overlay: slightly darker and blurred */
.loading-overlay {
  position: fixed;
  inset: 0;
  display: none; /* JS toggles to flex */
  align-items: center;
  justify-content: center;
  background: rgba(2,6,12,0.6);
  z-index: 9999;
  backdrop-filter: blur(2px) saturate(110%);
}
.loading-box {
  position: relative;
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 18px 22px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(16,22,44,0.98), rgba(10,16,30,0.98));
  border: 1px solid var(--border);
  box-shadow: 0 12px 44px rgba(0,0,0,0.6);
  color: var(--text);
  min-width: 220px;
  max-width: 78vw;
  overflow: visible;
}

/* Logo bubble: single glowing/pulsing S */
.loading-box .logo.small {
  width: var(--loader-size);
  height: var(--loader-size);
  border-radius: 12px;
  display: grid;
  place-items: center;
  z-index: 2;
  font-weight: 900;
  color: #06101a;
  background: linear-gradient(135deg, var(--loader-accent), var(--loader-accent-2));
  box-shadow: 0 8px 32px rgba(138,180,255,0.12), 0 2px 6px rgba(0,0,0,0.4) inset;
  transform-origin: center;
  animation: logo-pulse calc(var(--loader-duration) * 1.25) ease-in-out infinite;
}

/* keyframes for logo pulse (glow + slight scale) */
@keyframes logo-pulse {
  0% {
    transform: scale(1);
    box-shadow:
      0 8px 24px rgba(138,180,255,0.08),
      0 0 0 0 rgba(138,180,255,0.00),
      0 2px 6px rgba(0,0,0,0.4) inset;
  }
  50% {
    transform: scale(1.08);
    box-shadow:
      0 18px 46px rgba(138,180,255,0.14),
      0 0 30px 8px rgba(138,180,255,0.06),
      0 2px 8px rgba(0,0,0,0.45) inset;
  }
  100% {
    transform: scale(1);
    box-shadow:
      0 8px 24px rgba(138,180,255,0.08),
      0 0 0 0 rgba(138,180,255,0.00),
      0 2px 6px rgba(0,0,0,0.4) inset;
  }
}

/* Respect reduced motion: disable pulsing if user prefers reduced motion */
@media (prefers-reduced-motion: reduce) {
  .loading-box .logo.small { animation: none; transform: scale(1); box-shadow: 0 8px 24px rgba(138,180,255,0.08); }
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 1200px) {
  .app-grid { grid-template-columns: 1fr; padding: 12px; }
  .right-col { order: 2; }
  .left-col { order: 1; }
  .table-scroll { max-height: 40vh; }
  .table-scroll tbody td { max-width: 420px; }
}

@media (max-width: 520px) {
  .textarea { min-height: 120px; font-size:13px; }
  .controls { gap:8px; }
  .btn { padding:8px 10px; }
  .table-scroll { max-height: 30vh; }
  .table-scroll tbody td { max-width: 260px; font-size:12px; }
}
