/* RubanTag — App shell CSS */
*, *::before, *::after { box-sizing: border-box; }
body { font-family: 'Inter', system-ui, sans-serif; color: var(--color-text); background: var(--color-bg); margin: 0; }

/* ── App shell ── */
.rtag-shell { display: flex; flex-direction: column; min-height: 100vh; }

/* ── Topbar ── */
.rtag-topbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--topbar-h); background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; gap: var(--space-3);
  padding: 0 var(--space-5);
}
.rtag-topbar-logo { display: flex; align-items: center; gap: var(--space-2); font-weight: var(--fw-bold); font-size: var(--fs-lg); text-decoration: none; color: var(--color-text); }
.rtag-topbar-logo .logo-icon { width: 32px; height: 32px; background: var(--rtag-primary); border-radius: var(--radius-sm); display: grid; place-items: center; color: var(--rtag-on-primary); font-size: 1rem; }
.rtag-topbar-spacer { flex: 1; }
.rtag-topbar-actions { display: flex; align-items: center; gap: var(--space-3); }

/* ── Scrollable content ── */
.rtag-content {
  flex: 1;
  padding: var(--space-5);
  max-width: var(--shell-max);
  width: 100%;
  margin: 0 auto;
}

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: var(--space-2); padding: .55rem 1.2rem; border-radius: var(--radius-md); font-weight: var(--fw-semibold); font-size: var(--fs-sm); border: none; cursor: pointer; text-decoration: none; transition: filter .15s; }
.btn:hover { filter: brightness(.93); }
.btn--primary { background: var(--rtag-primary); color: var(--rtag-on-primary); }
.btn--outline { background: transparent; border: 1.5px solid var(--color-border); color: var(--color-text); }
.btn--outline:hover { border-color: var(--rtag-primary); color: var(--rtag-primary); filter: none; }
.btn--ghost   { background: transparent; color: var(--color-muted); }
.btn--danger  { background: var(--color-danger); color: #fff; }
.btn--sm { padding: .35rem .8rem; font-size: var(--fs-xs); }
.btn--lg { padding: .75rem 1.6rem; font-size: var(--fs-base); }

/* ── Pills ── */
.pill { display: inline-flex; align-items: center; padding: .2rem .6rem; border-radius: var(--radius-full); font-size: var(--fs-xs); font-weight: var(--fw-semibold); }
.pill--green  { background: var(--green-50);  color: var(--green-700); }
.pill--red    { background: var(--red-50);    color: var(--red-700); }
.pill--amber  { background: var(--amber-50);  color: var(--amber-700); }
.pill--blue   { background: var(--blue-50);   color: var(--blue-700); }
.pill--gray   { background: var(--gray-100);  color: var(--gray-600); }
.pill--purple { background: var(--purple-50); color: var(--purple-600); }

/* ── Cards ── */
.card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: var(--space-5); box-shadow: var(--shadow-sm); }

/* ── Flash alerts ── */
.rtag-alert { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); font-size: var(--fs-sm); margin-bottom: var(--space-4); }
.rtag-alert--success { background: var(--green-50);  color: var(--green-700); border: 1px solid var(--green-100); }
.rtag-alert--error   { background: var(--red-50);    color: var(--red-700);   border: 1px solid #fecaca; }
.rtag-alert--warning { background: var(--amber-50);  color: var(--amber-700); border: 1px solid var(--amber-100); }
.rtag-alert--info    { background: var(--blue-50);   color: var(--blue-700);  border: 1px solid var(--blue-100); }

/* ── Breadcrumb ── */
.rtag-breadcrumb { list-style: none; display: flex; flex-wrap: wrap; gap: .25rem; padding: 0; margin: 0 0 var(--space-5); font-size: var(--fs-sm); }
.rtag-breadcrumb li::after { content: '/'; margin-left: .25rem; color: var(--color-muted); }
.rtag-breadcrumb li:last-child::after { display: none; }
.rtag-breadcrumb a { color: var(--rtag-primary-text); text-decoration: none; }
.rtag-breadcrumb .active { color: var(--color-muted); }

/* ── Tables ── */
.rtag-table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.rtag-table th { text-align: left; text-transform: uppercase; letter-spacing: .06em; font-size: .74rem; color: var(--color-muted); border-bottom: 1px solid var(--color-border); padding: .5rem .6rem; }
.rtag-table td { padding: .55rem .6rem; border-bottom: 1px solid var(--color-border); }
.rtag-table tr:hover td { background: rgba(0,0,0,.02); }
.rtag-table tr:last-child td { border-bottom: none; }
.rtag-num { text-align: right; font-variant-numeric: tabular-nums; }
.row-actions { text-align: right; }

/* ── Score badge ── */
.score-badge { display: inline-flex; align-items: center; justify-content: center; width: 52px; height: 52px; border-radius: var(--radius-full); font-size: var(--fs-xl); font-weight: var(--fw-bold); }
.score-badge--green  { background: var(--green-50);  color: var(--green-700); }
.score-badge--blue   { background: var(--blue-50);   color: var(--blue-700); }
.score-badge--amber  { background: var(--amber-50);  color: var(--amber-700); }
.score-badge--red    { background: var(--red-50);    color: var(--red-700); }

/* ── Tag tree ── */
.tag-tree { font-size: var(--fs-sm); line-height: 1.7; }
.tag-node { padding-left: var(--space-5); position: relative; }
.tag-node > .tag-label { display: flex; align-items: center; gap: var(--space-2); cursor: pointer; padding: 2px 0; }
.tag-node > .tag-label:hover { color: var(--rtag-primary); }
.tag-dot { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.tag-count { font-size: var(--fs-xs); color: var(--color-muted); margin-left: auto; }
.tag-dot--H1,.tag-dot--H2 { background: var(--tag-h1); }
.tag-dot--H3 { background: var(--tag-h3); }
.tag-dot--H4,.tag-dot--H5,.tag-dot--H6 { background: var(--tag-h4); }
.tag-dot--P  { background: var(--tag-p); }
.tag-dot--Table,.tag-dot--TR,.tag-dot--TD,.tag-dot--TH { background: var(--tag-table); }
.tag-dot--Figure { background: var(--tag-figure); }
.tag-dot--L,.tag-dot--LI { background: var(--tag-list); }
.tag-dot--Artifact { background: var(--tag-artifact); }

/* ── Page header ── */
.page-header { display: flex; align-items: center; gap: var(--space-4); margin-bottom: var(--space-5); flex-wrap: wrap; }
.page-title { font-size: var(--fs-2xl); font-weight: var(--fw-bold); margin: 0; }
.page-actions { margin-left: auto; display: flex; gap: var(--space-2); }

/* ── Stat cards ── */
.stat-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: var(--space-4); text-align: center; }
.stat-value { font-size: var(--fs-2xl); font-weight: var(--fw-bold); color: var(--rtag-accent); }
.stat-label { font-size: var(--fs-xs); color: var(--color-muted); margin-top: 2px; }

/* ── Responsive ── */
@media (max-width: 600px) {
  .rtag-content { padding: var(--space-4); }
  .page-header { flex-direction: column; align-items: flex-start; }
  .page-actions { margin-left: 0; }
}

/* ── Auth pages (contained 2-column card) ── */
.auth-section { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 3rem 1rem; background: var(--color-bg); }
.auth-card { max-width: 980px; margin: 0 auto; width: 100%; background: #fff; border-radius: 16px; overflow: hidden; box-shadow: var(--shadow-md, 0 10px 40px rgba(15,23,42,.12)); display: flex; }
.auth-card--wide { max-width: 1040px; }

.auth-left { width: 42%; flex-shrink: 0; background: #0f172a; color: #fff; padding: 2.75rem 2.5rem; display: flex; flex-direction: column; justify-content: center; }
.auth-left-logo { display: flex; align-items: center; gap: .6rem; font-weight: 800; font-size: 1.2rem; text-decoration: none; color: #fff; margin-bottom: 1.75rem; }
.auth-left-logo .logo-icon { width: 36px; height: 36px; background: var(--rtag-primary); border-radius: var(--radius-sm); display: grid; place-items: center; font-size: 1.1rem; color: var(--rtag-accent); }
.auth-left-logo .brand-accent { color: var(--rtag-primary); }
.auth-left h2 { font-size: 1.5rem; font-weight: 800; margin: 0 0 .6rem; line-height: 1.25; }
.auth-left p.lead { color: #94a3b8; font-size: .9rem; margin: 0 0 1.75rem; line-height: 1.65; }

.auth-features { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .75rem; }
.auth-features li { display: flex; align-items: center; gap: .6rem; font-size: .87rem; color: #cbd5e1; }
.auth-features li i { color: #60a5fa; flex-shrink: 0; }

.plan-cards { display: flex; flex-direction: column; gap: .6rem; margin-top: .5rem; }
.plan-card { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); border-radius: var(--radius-md); padding: .75rem 1rem; display: flex; align-items: center; gap: .75rem; }
.plan-card.highlight { background: rgba(37,99,235,.2); border-color: rgba(96,165,250,.4); }
.plan-card .plan-name { font-weight: 700; font-size: .85rem; color: #fff; }
.plan-card .plan-desc { font-size: .78rem; color: #94a3b8; margin-top: .1rem; }
.plan-card i { font-size: 1.2rem; color: #60a5fa; flex-shrink: 0; }

.auth-right { flex: 1; background: #fff; padding: 2.75rem 2.5rem; display: flex; align-items: center; justify-content: center; }
.auth-inner { width: 100%; max-width: 400px; }
.auth-inner h1 { font-size: 1.5rem; font-weight: 800; margin: 0 0 .3rem; color: var(--color-text); }
.auth-inner .sub { color: var(--color-muted); font-size: .88rem; margin: 0 0 1.75rem; line-height: 1.6; }

.auth-form .form-group { margin-bottom: 1rem; }
.auth-form label { display: block; font-size: .83rem; font-weight: 600; margin-bottom: .35rem; color: var(--gray-700); }
.auth-form .input-wrap { position: relative; }
.auth-form .input-wrap > i { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--color-muted); font-size: .95rem; pointer-events: none; }
.auth-form .form-input { width: 100%; padding: .6rem .8rem .6rem 2.4rem; border: 1.5px solid var(--color-border); border-radius: var(--radius-md); font-size: .9rem; font-family: inherit; outline: none; transition: border-color .15s; background: var(--color-surface); color: var(--color-text); }
.auth-form .form-input:focus { border-color: var(--rtag-primary); box-shadow: 0 0 0 3px rgba(var(--rtag-primary-rgb),.12); }
.auth-form .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }

.auth-form .alert-error { background: var(--red-50); border: 1px solid #fecaca; border-radius: var(--radius-md); padding: .6rem .9rem; font-size: .85rem; color: var(--red-700); display: flex; gap: .5rem; align-items: flex-start; margin-bottom: 1.2rem; }
.auth-form .alert-error ul { margin: .3rem 0 0 1rem; padding: 0; }
.auth-form .alert-error li { margin-bottom: .2rem; }
.auth-form .alert-success { background: var(--green-50); border: 1px solid var(--green-100); border-radius: var(--radius-md); padding: 1rem; font-size: .87rem; color: var(--green-700); margin-bottom: 1rem; line-height: 1.6; }

.btn-auth { display: block; width: 100%; padding: .7rem; background: var(--rtag-primary); color: var(--rtag-accent); border: none; border-radius: var(--radius-md); font-size: .95rem; font-weight: 700; cursor: pointer; transition: filter .15s; margin-top: .25rem; text-align: center; text-decoration: none; }
.btn-auth:hover { filter: brightness(.93); }

.auth-alt { text-align: center; margin-top: 1.25rem; font-size: .85rem; color: var(--color-muted); }
.auth-alt a { color: var(--rtag-primary); font-weight: 600; text-decoration: none; }
.forgot-link { float: right; font-size: .8rem; color: var(--color-muted); text-decoration: none; font-weight: 500; }
.forgot-link:hover { color: var(--rtag-primary); }
.terms-note { font-size: .75rem; color: var(--color-muted); text-align: center; margin-top: .85rem; line-height: 1.5; }
.auth-back { display: block; text-align: center; margin-top: 1rem; font-size: .85rem; color: var(--color-muted); text-decoration: none; }
.auth-back:hover { color: var(--rtag-primary); }

@media (max-width: 991px) {
  .auth-card, .auth-card--wide { flex-direction: column; max-width: 480px; }
  .auth-left { width: 100%; border-radius: 16px 16px 0 0; padding: 2rem 1.75rem; }
  .auth-right { padding: 2rem 1.75rem; }
  .auth-form .form-row { grid-template-columns: 1fr; }
}
