/* subapps/armorph/static/css/armorph-ui.css */

/* ────────────────────────────────────────────────────────────────────────────
   GLOBAL BUTTON + CARD POLISH
   ──────────────────────────────────────────────────────────────────────────── */

/* Smooth transition for any button */
button {
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

/* Brief flash after click (removed by JS after ~180ms) */
button.btn-flash {
  background-color: #38bdf8 !important; /* Tailwind sky-400 */
  color: #000 !important;
  border-color: #38bdf8 !important;
}

/* Persisted "clicked" state — sky blue bg, black text (if you want to keep some buttons highlighted) */
button.btn-clicked {
  background-color: #38bdf8 !important;
  color: #000 !important;
  border-color: #38bdf8 !important;
}

/* Optional: refine contrast for disabled buttons */
button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Sky-blue shadow for cards/boxes */
.armorph-card {
  /* soft sky layers */
  box-shadow:
    0 10px 28px -8px rgba(56, 189, 248, 0.45),
    0 4px 10px -4px rgba(56, 189, 248, 0.35);
  border: 1px solid rgba(56, 189, 248, 0.18); /* subtle edge */
  border-radius: 0.75rem; /* matches Tailwind rounded-xl */
  background: #fff;
}

/* Optional: light lift on hover/focus within */
.armorph-card:hover,
.armorph-card:focus-within {
  box-shadow:
    0 14px 38px -10px rgba(56, 189, 248, 0.5),
    0 6px 14px -6px rgba(56, 189, 248, 0.4);
}

/* POS dropdown highlight when no rule matched (user attention) */
.pos-unclassified {
  background-color: #e0f2fe !important; /* sky-100 */
  border-color: #38bdf8 !important;     /* sky-400 */
}

/* Titles inside the Patterns <select> (non-selectable guidance) */
.pattern-title {
  font-weight: 700;            /* bold */
  color: #0f172a;              /* slate-900 for contrast */
}

/* Chips */
.miq-chip {
  display: inline-block;
  padding: 2px 6px;
  font-size: 11px;
  border-radius: 9999px;
  border: 1px solid rgba(0,0,0,0.08);
  background: #f8fafc;
}

.chip-auto   { background: #ecfeff; border-color: #67e8f9; }   /* cyan tint */
.chip-edited { background: #eff6ff; border-color: #93c5fd; }   /* indigo tint */
.chip-custom { background: #fef3c7; border-color: #facc15; }   /* amber tint */

/* Hide "auto" chip if you don't want to show it */
.miq-chip.chip-auto {
  display: none !important;
}

/* Generic "unclassified" look you can reuse anywhere */
.am-unclassified {
  background-color: #e0f2fe !important; /* sky-100 */
  box-shadow: 0 0 0 2px #7dd3fc inset;   /* sky-300 ring */
  border-color: #7dd3fc !important;
}

/* Placeholder highlight for unset state (optional) */
select.pattern-select .placeholder { color: #64748b; } /* slate-500 */


/* ────────────────────────────────────────────────────────────────────────────
   ROW-GROUP TABLE (TOKEN + C1..C4)
   Works with the renderer in subapps/armorph/static/js/tokenize.js
   ──────────────────────────────────────────────────────────────────────────── */

/* Sticky TOKEN cell on the RIGHT (RTL tables) */
#armorph-table td.token-cell {
  position: sticky;
  right: 0;                 /* stick to right edge in RTL */
  background: #fff;         /* avoid overlay artifacts when scrolling */
  z-index: 1;               /* above adjacent cells */
  border-left: 1px solid #e5e7eb; /* subtle divider to its left */
}

/* Head row subtle gradient to visually anchor the group */
#armorph-table tr.head-row {
  background-image: linear-gradient(to left, rgba(99,102,241,0.06), transparent);
}

/* Subtle group divider */
#armorph-table tr.head-row {
  border-top: 2px solid #f3f4f6;
}

/* Hover polish */
#armorph-table tr:hover td {
  background-color: #fafafa;
}

/* Chevron control */
.arm-chevron {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  cursor: pointer;
  user-select: none;
}
.arm-chevron svg {
  transition: transform .15s ease;
}

/* If you set aria-expanded on the chevron, rotate when collapsed */
.arm-chevron[aria-expanded="false"] svg {
  transform: rotate(-90deg);
}

/* Optional class if you choose to toggle a "collapsed" class on the head row */
#armorph-table tr.head-row.collapsed .arm-chevron svg {
  transform: rotate(-90deg);
}

/* If you choose to toggle a wrapper "group-collapsed" on <tbody> rows (not required) */
#armorph-table tr.group-collapsed + tr.sub-row,
#armorph-table tr.group-collapsed ~ tr.sub-row[data-parent="__SAME__"] {
  /* Placeholder pattern — JS currently sets style=display:none directly.
     Keep this block for future switch to class-based collapsing. */
}

/* Zebra for continuation rows (very light) */
#armorph-table tr.sub-row td {
  background-image: linear-gradient(to left, rgba(15,23,42,0.02), transparent); /* slate-900 @ 2% */
}

/* Tighten header look (works alongside Tailwind classes) */
#armorph-table thead th {
  border-bottom: 1px solid #e5e7eb; /* gray-200 */
}

/* Cell baseline padding (keeps consistency if some cells host inputs) */
#armorph-table td,
#armorph-table th {
  vertical-align: top;
  line-height: 1.5;
}

/* Inputs inside table cells (inline editors) */
#armorph-table td .miq-input,
#armorph-table td .miq-select {
  width: 100%;
  font-size: 0.875rem;  /* text-sm */
  padding: 0.35rem 0.5rem;
  border-radius: 0.5rem;
  border: 1px solid #6366f1; /* indigo-500 */
  background: #fff;
}
#armorph-table td .miq-input:focus,
#armorph-table td .miq-select:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.5); /* indigo-500/50 */
}

/* Collapsed state helper (if you want to hide via CSS class instead of inline style)
   Current JS sets display:none on sub-rows directly; this is optional and future-proof. */
#armorph-table tr.sub-row.is-hidden {
  display: none !important;
}


/* ────────────────────────────────────────────────────────────────────────────
   ML SUGGESTIONS (column & option tinting)
   Mirrors classes used by tokenize.ml.js so styles also exist in global CSS.
   ──────────────────────────────────────────────────────────────────────────── */

/* Column header highlighted when conflicts (peek) exist */
.am-ml-conflict-col {
  background: #bae6fd !important; /* sky-200 */
}

/* Column header (and cells) highlighted when any ML suggestion exists */
.am-ml-suggested-col {
  background: #FEF9C3 !important; /* yellow-100 */
}
.am-ml-suggested-cell {
  background: #FFFBEB !important; /* amber-50 */
}

/* Best-effort per-option tinting in native <select>.
   NOTE: Some browsers (notably macOS Safari) ignore per-<option> background. */
select option.am-opt-ml {
  color: #064e3b;            /* green-900 */
  background: #dcfce7;       /* green-100 */
}
select option.am-opt-rule {
  color: #1e3a8a;            /* blue-900 */
  background: #dbeafe;       /* blue-100 */
}


/* ────────────────────────────────────────────────────────────────────────────
   ML REVIEW MODAL (opens when clicking "اقترح")
   ──────────────────────────────────────────────────────────────────────────── */

#am-ml-modal-backdrop{
  position:fixed; inset:0; background:rgba(2,6,23,.55);
  display:none; z-index:100;
}
#am-ml-modal{
  position:fixed; inset-inline:0; inset-block-start:6vh;
  margin-inline:auto; max-width:980px; width:92%;
  background:#fff; border-radius:16px;
  box-shadow:0 30px 80px rgba(2,6,23,.35);
  display:none; z-index:101; overflow:hidden;
}
#am-ml-modal header{
  padding:.9rem 1rem; border-bottom:1px solid rgba(15,23,42,.08);
  display:flex; align-items:center; justify-content:space-between; gap:.5rem;
}
#am-ml-modal .am-meta{
  font-size:.85rem; color:#334155; display:flex; gap:.75rem; flex-wrap:wrap;
}
#am-ml-modal .am-meta b{ color:#0f172a; }
#am-ml-modal .am-body{ max-height:70vh; overflow:auto; padding:0 1rem 1rem; }
#am-ml-modal table{ width:100%; border-collapse:separate; border-spacing:0; }
#am-ml-modal thead th{
  position:sticky; top:0; background:#f8fafc; z-index:1;
  border-bottom:1px solid #e5e7eb; text-align:start; padding:.6rem .5rem;
}
#am-ml-modal tbody td{ border-bottom:1px solid #f1f5f9; padding:.45rem .5rem; vertical-align:top; }
#am-ml-modal .am-row-title{ white-space:nowrap; font-weight:700; }
#am-ml-modal .am-badge{
  display:inline-flex; align-items:center; gap:.35rem;
  padding:.2rem .45rem; border-radius:9999px; font-size:.78rem; font-weight:700;
  border:1px solid rgba(15,23,42,.12); white-space:nowrap;
}
#am-ml-modal .am-ml { background:#dcfce7; color:#064e3b; border-color:#86efac; }  /* ML green */
#am-ml-modal .am-rule { background:#dbeafe; color:#1e3a8a; border-color:#93c5fd; } /* Rule blue */
#am-ml-modal .am-neutral { background:#f1f5f9; color:#0f172a; }
#am-ml-modal .am-choice{ display:flex; align-items:center; gap:.5rem; margin:.25rem 0; }
#am-ml-modal .am-actions{ display:flex; gap:.5rem; justify-content:flex-end; padding: .75rem 1rem 1rem; border-top:1px solid #e5e7eb; }
#am-ml-modal .btn{ border:0; border-radius:10px; padding:.55rem .9rem; font-weight:800; cursor:pointer; }
#am-ml-modal .btn-apply{ background:#22c55e; color:#052e2b; }
#am-ml-modal .btn-cancel{ background:#e2e8f0; color:#0f172a; }

/* ────────────────────────────────────────────────────────────────────────────
   ARMORPH PAGE BACKGROUND HELPERS (mesh, subtle glow)
   ──────────────────────────────────────────────────────────────────────────── */

/* Dark panel with subtle AI mesh, used behind hero + content shell */
.armorph-mesh-bg {
  background-image:
    radial-gradient(900px 600px at 85% 10%, rgba(14,165,233,0.24) 0%, transparent 55%),
    radial-gradient(900px 500px at 10% 20%, rgba(103,232,249,0.18) 0%, transparent 60%);
  background-color: #0E2236; /* panel */
}

/* ────────────────────────────────────────────────────────────────────────────
   ARMORPH BOOT OVERLAY (AI-styled loader)
   ──────────────────────────────────────────────────────────────────────────── */

.armorph-boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  /* subtle AI gradient mesh behind blur */
  background:
    radial-gradient(60% 60% at 30% 20%, rgba(14,165,233,0.22), transparent 60%),
    radial-gradient(50% 50% at 70% 80%, rgba(99,102,241,0.18), transparent 60%),
    rgba(2, 6, 23, 0.65); /* slate-950 overlay */
  backdrop-filter: saturate(120%) blur(2px);
  z-index: 10000; /* above everything */
}
.armorph-boot[hidden] { display: none; }

.armorph-boot__box {
  min-width: 320px;
  max-width: 92vw;
  text-align: center;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  border-radius: 18px;
  padding: 1.1rem 1.25rem 1.15rem;
  box-shadow:
    0 30px 80px rgba(2, 6, 23, 0.35),
    inset 0 0 0 1px rgba(15,23,42,0.05);
  border: 1px solid rgba(15,23,42,0.08);
  position: relative;
  isolation: isolate;
}

/* small glowing accent line on top edge */
.armorph-boot__box::before {
  content: "";
  position: absolute;
  inset-inline: 22%;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg, #06b6d4, #0ea5e9, #6366f1);
  filter: blur(.3px);
  opacity: .85;
  border-radius: 9999px;
}

/* branded badge with Arabic ظ mark */
.armorph-boot__badge {
  width: 52px; height: 52px;
  margin: 0 auto 10px;
  display: grid; place-items: center;
  border-radius: 14px;
  background:
    radial-gradient(120% 120% at 20% 15%, rgba(14,165,233,0.6), transparent 62%),
    radial-gradient(120% 120% at 80% 85%, rgba(99,102,241,0.55), transparent 60%),
    #0f172a;
  color: #e2f3ff;
  font-weight: 900;
  font-size: 1.35rem;
  letter-spacing: .02em;
  box-shadow:
    0 10px 20px rgba(2,6,23,.25),
    inset 0 0 0 1px rgba(255,255,255,.08);
  animation: bootFloat 3s ease-in-out infinite;
}
.armorph-boot__badge span { transform: translateY(-1px); }

.armorph-boot__spinner {
  width: 34px;
  height: 34px;
  margin: 2px auto 10px;
  border-radius: 50%;
  border: 3px solid #bae6fd;               /* sky-200 */
  border-top-color: #0ea5e9;                /* sky-500 */
  animation: armorph-spin 0.9s linear infinite;
}

.armorph-boot__text {
  font-weight: 800;
  color: #0f172a;                           /* slate-900 */
  margin-top: 0.25rem;
  font-size: 1.02rem;
}
.armorph-boot__sub {
  font-size: .86rem;
  color: #334155;                           /* slate-700 */
  margin-top: .25rem;
  opacity: .95;
}

/* subtle progress bar with shimmer */
.armorph-boot__bar {
  position: relative;
  height: 4px;
  margin: .75rem auto .15rem;
  width: 75%;
  border-radius: 9999px;
  background: #e2e8f0; /* slate-200 */
  overflow: hidden;
}
.armorph-boot__bar > i {
  position: absolute;
  inset-block: 0;
  width: 38%;
  border-radius: 9999px;
  background: linear-gradient(90deg, #38bdf8, #60a5fa, #a78bfa); /* sky-400 → indigo-400 → violet-400 */
  animation: amSlideWide 1.25s ease-in-out infinite;
  box-shadow: 0 0 16px rgba(14,165,233,.35);
}

/* Animations */
@keyframes armorph-spin { to { transform: rotate(360deg); } }
@keyframes amSlideWide {
  0%   { transform: translateX(-120%); }
  50%  { transform: translateX(35%); }
  100% { transform: translateX(220%); }
}
@keyframes bootFloat {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-3px); }
}

/* Reduced motion: respect user preference */
@media (prefers-reduced-motion: reduce) {
  .armorph-boot__spinner { animation: none; }
  .armorph-boot__bar > i { animation: none; width: 50%; transform: translateX(0); }
  .armorph-boot__badge { animation: none; }
}
