@tailwind base;
@tailwind components;
@tailwind utilities;

/* ── PALETA ────────────────────────────────────────── */
:root {
  --bg-base:        #0d1117;
  --bg-surface:     #111827;
  --bg-elevated:    #1e2d3d;
  --bg-border:      #1e3a5f;
  --border-subtle:  #1e2d3d;

  --accent-primary: #1a56db;
  --accent-light:   #0ea5e9;
  --accent-danger:  #dc2626;
  --accent-success: #059669;
  --accent-purple:  #7c3aed;
  --accent-amber:   #d97706;

  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #4b5563;
  --text-blue:      #60a5fa;
  --text-red:       #f87171;
  --text-green:     #34d399;

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 12px;
}

/* ══════════════════════════════════════════
   TOPBAR
   ══════════════════════════════════════════ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  padding: 0 20px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
}
.logo-mark {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-light));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: #fff;
}
.brand-name {
  font-family: 'Playfair Display', serif;
  font-size: 18px; font-weight: 600; color: var(--text-primary);
}
.brand-sub {
  display: block; font-size: 10px;
  color: var(--text-muted); letter-spacing: 1.5px; text-transform: uppercase;
}
.nav-tab {
  padding: 6px 16px; border-radius: 6px;
  font-size: 12px; font-weight: 500;
  color: var(--text-muted); text-decoration: none; transition: all .15s;
}
.nav-tab.active { color: #38bdf8; background: rgba(56,189,248,0.08); }
.nav-tab:hover { color: var(--text-secondary); }
.status-dot {
  display: inline-block; width: 6px; height: 6px;
  border-radius: 50%; background: var(--text-green);
  box-shadow: 0 0 0 3px rgba(52,211,153,0.2);
  margin-right: 5px;
}
.search-global {
  background: var(--bg-elevated); border: 1px solid var(--bg-border);
  border-radius: 7px; padding: 6px 12px;
  font-size: 12px; color: var(--text-secondary); width: 200px;
}
.search-global::placeholder { color: var(--text-muted); }
.search-global:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(26,86,219,0.2);
}
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; color: #fff;
}

/* ══════════════════════════════════════════
   SIDEBAR
   ══════════════════════════════════════════ */
.sidebar {
  width: 200px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  padding: 16px 12px;
  display: flex; flex-direction: column; gap: 20px;
}
.sidebar-input {
  background: var(--bg-elevated);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 11px; color: var(--text-secondary);
  width: 100%;
}
.sidebar-input::placeholder { color: var(--text-muted); }
.sidebar-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(26,86,219,0.15);
}
.oab-tag {
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(26,86,219,0.15);
  border: 1px solid rgba(26,86,219,0.3);
  border-radius: var(--radius-sm);
  padding: 5px 8px; margin-top: 6px;
  font-size: 11px; color: #93c5fd; font-weight: 500;
}
.quick-btn {
  flex: 1; padding: 6px;
  background: var(--bg-elevated); border: 1px solid var(--bg-border);
  border-radius: var(--radius-sm);
  font-size: 11px; color: var(--text-secondary);
  cursor: pointer; text-align: center; transition: all .15s;
}
.quick-btn:hover { background: var(--bg-border); color: var(--text-primary); }
.btn-sync {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-light));
  border: none; border-radius: 8px;
  padding: 10px; font-size: 12px; font-weight: 600;
  color: #fff; cursor: pointer; width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: opacity .2s;
}
.btn-sync:hover { opacity: .9; }
.btn-sync:disabled { opacity: .5; cursor: not-allowed; }
.sidebar-footer {
  display: flex; justify-content: space-between;
  padding-top: 8px; border-top: 1px solid var(--border-subtle);
}
.sidebar-footer a { font-size: 10px; color: var(--text-muted); cursor: pointer; }
.sidebar-footer a:hover { color: var(--text-secondary); }
.section-label {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ══════════════════════════════════════════
   EMPTY STATE
   ══════════════════════════════════════════ */
.empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  height: 100%;
  gap: 14px; padding: 60px 20px;
}
.empty-icon {
  width: 72px; height: 72px; border-radius: 18px;
  background: linear-gradient(135deg, rgba(26,86,219,0.15), rgba(14,165,233,0.08));
  border: 1px solid rgba(26,86,219,0.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 30px;
}
.empty-title {
  font-family: 'Playfair Display', serif;
  font-size: 18px; color: var(--text-primary); margin: 0;
}
.empty-sub {
  font-size: 13px; color: var(--text-muted);
  max-width: 320px; text-align: center; line-height: 1.7; margin: 0;
}
.empty-cta {
  background: transparent;
  border: 1px solid rgba(56,189,248,0.3);
  border-radius: 5px; padding: 2px 8px;
  font-size: 12px; color: #38bdf8; cursor: pointer;
  font-family: 'DM Sans', sans-serif;
}

/* ══════════════════════════════════════════
   ALERT BANNER
   ══════════════════════════════════════════ */
.alert-banner {
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(135deg, rgba(220,38,38,.12), rgba(220,38,38,.04));
  border: 1px solid rgba(220,38,38,.3);
  border-left: 3px solid var(--accent-danger);
  border-radius: var(--radius-lg);
  padding: 12px 16px; margin-bottom: 18px;
}
.alert-icon {
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  background: rgba(220,38,38,.15);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: var(--text-red);
  margin-right: 10px; flex-shrink: 0;
}
.alert-title { font-size: 12px; font-weight: 600; color: #fca5a5; margin: 0; }
.alert-sub   { font-size: 11px; color: var(--text-muted); margin: 2px 0 0; }
.alert-count {
  background: var(--accent-danger); color: #fff;
  font-size: 11px; font-weight: 700;
  padding: 4px 12px; border-radius: 20px; white-space: nowrap;
}

/* ══════════════════════════════════════════
   METRICS CARDS
   ══════════════════════════════════════════ */
.metrics-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
  margin-bottom: 20px;
}
.metric-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px 16px; position: relative; overflow: hidden;
}
.metric-bar {
  position: absolute; top: 0; left: 0; right: 0;
  height: 2px; background: var(--accent);
}
.metric-label {
  display: block; font-size: 10px; font-weight: 600;
  letter-spacing: 1px; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 8px;
}
.metric-value {
  display: block; font-size: 28px; font-weight: 300;
  color: var(--text-primary); line-height: 1;
}
.metric-trend {
  display: block; font-size: 10px;
  color: var(--text-muted); margin-top: 6px;
}

/* ══════════════════════════════════════════
   COMPOSITION BARS
   ══════════════════════════════════════════ */
.comp-card {
  background: var(--bg-surface); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); padding: 14px 16px;
}
.comp-row   { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.comp-name  { font-size: 12px; color: var(--text-secondary); min-width: 130px; }
.comp-bar-bg{ flex: 1; height: 5px; background: var(--bg-elevated); border-radius: 3px; }
.comp-bar   { height: 5px; border-radius: 3px; transition: width .4s ease; }
.comp-pct   { font-size: 11px; color: var(--text-muted); min-width: 28px; text-align: right; }

/* ══════════════════════════════════════════
   TABLE
   ══════════════════════════════════════════ */
.table-wrapper {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.table-wrapper table thead th {
  background: var(--bg-base);
  font-size: 9.5px; font-weight: 600;
  letter-spacing: 0.8px; text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-subtle);
}
.table-wrapper table tbody td {
  padding: 10px 14px;
  font-size: 11.5px; color: var(--text-secondary);
  border-bottom: 1px solid rgba(30,45,61,0.5);
  vertical-align: top;
}
.table-wrapper table tbody tr:hover td { background: rgba(30,45,61,0.4); }
.table-wrapper table tbody tr:last-child td { border-bottom: none; }
.proc-number {
  font-family: 'Courier New', monospace;
  font-size: 11px; color: #60a5fa; font-weight: 500;
}
.pub-text {
  font-size: 11px; color: var(--text-muted);
  max-width: 300px; line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.action-cell { white-space: nowrap; }
.action-btn {
  background: none; border: none;
  color: var(--text-muted); font-size: 14px;
  cursor: pointer; padding: 3px 5px;
  border-radius: 4px; transition: color .15s;
}
.action-btn:hover { color: #60a5fa; }

/* Badges */
.badge {
  display: inline-block; padding: 2px 8px;
  border-radius: 4px; font-size: 10px; font-weight: 600; letter-spacing: 0.3px;
}
.badge-intimacao { background: rgba(56,189,248,.10); color: #38bdf8; border: 1px solid rgba(56,189,248,.2); }
.badge-sentenca  { background: rgba(167,139,250,.10); color: #a78bfa; border: 1px solid rgba(167,139,250,.2); }
.badge-despacho  { background: rgba(52,211,153,.10);  color: #34d399; border: 1px solid rgba(52,211,153,.2); }
.badge-lista     { background: rgba(75,85,99,.20);    color: #94a3b8; border: 1px solid rgba(75,85,99,.3); }
.badge-citacao   { background: rgba(251,191,36,.10);  color: #fbbf24; border: 1px solid rgba(251,191,36,.2); }
.badge-decisao   { background: rgba(248,113,113,.10); color: #f87171; border: 1px solid rgba(248,113,113,.2); }

/* ══════════════════════════════════════════
   DETAIL VIEW
   ══════════════════════════════════════════ */
.detail-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px; margin-bottom: 20px;
}
.detail-field {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}
.field-label {
  display: block; font-size: 9.5px; font-weight: 600;
  letter-spacing: 1px; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 6px;
}
.field-value { font-size: 13px; color: var(--text-primary); }

.pub-full-text {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  font-size: 13px; color: var(--text-secondary);
  line-height: 1.8; white-space: pre-wrap;
}
.highlight-prazo {
  background: rgba(220,38,38,.15);
  border: 1px solid rgba(220,38,38,.3);
  color: #fca5a5; border-radius: 3px;
  padding: 0 4px; font-weight: 600;
}
.highlight-sentenca {
  background: rgba(167,139,250,.12);
  border: 1px solid rgba(167,139,250,.25);
  color: #c4b5fd; border-radius: 3px;
  padding: 0 4px; font-weight: 600;
}

/* ══════════════════════════════════════════
   BACK LINK
   ══════════════════════════════════════════ */
.back-link {
  font-size: 12px; color: var(--text-muted);
  text-decoration: none; margin-bottom: 10px; display: inline-block;
}
.back-link:hover { color: var(--text-secondary); }

/* ══════════════════════════════════════════
   SCROLLBAR
   ══════════════════════════════════════════ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--bg-border); }

/* ══════════════════════════════════════════
   UTILITIES / LEGACY
   ══════════════════════════════════════════ */
@layer base {
  body {
    @apply bg-[var(--bg-base)] text-[var(--text-primary)];
    font-family: 'DM Sans', sans-serif;
  }
  ::selection { background: rgba(56, 189, 248, 0.2); color: #f1f5f9; }
}

.datajud-section { grid-column: span 12; margin-top: 12px; }
.datajud-section-title { font-size: 15px; font-weight: 700; color: var(--text-primary); margin-bottom: 16px; padding-bottom: 10px; border-bottom: 1px solid var(--border-subtle); letter-spacing: -0.01em; }
.datajud-section-title span { font-size: 10px; font-weight: 400; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; margin-left: 8px; }
.datajud-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin-bottom: 24px; }
.datajud-box { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: 10px; padding: 14px; }
.datajud-label { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 6px; }
.datajud-value { font-size: 13px; color: var(--text-primary); line-height: 1.5; word-break: break-word; font-weight: 500; }
.datajud-loading { grid-column: span 12; display: flex; flex-direction: column; align-items: center; padding: 48px 0; color: var(--text-muted); font-size: 14px; gap: 20px; }
.datajud-error { font-size: 13px; color: var(--text-muted); line-height: 1.6; padding: 8px 0; }
.dje-loading { font-size: 11px; color: var(--text-muted); margin-top: 8px; font-style: italic; }

.timeline-wrapper { grid-column: span 12; margin-top: 12px; }
.timeline-title { font-size: 13px; font-weight: 700; color: var(--text-primary); margin-bottom: 16px; letter-spacing: -0.01em; }
.timeline-container { position: relative; padding-left: 28px; }
.timeline-container::before { content: ''; position: absolute; left: 9px; top: 4px; bottom: 4px; width: 1.5px; background: linear-gradient(to bottom, rgba(56,189,248,0.3), rgba(56,189,248,0.05)); }
.timeline-item { position: relative; padding: 0 0 24px 20px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot { position: absolute; left: -25px; top: 5px; width: 11px; height: 11px; border-radius: 50%; background: rgba(56,189,248,0.9); border: 2.5px solid var(--bg-base); box-shadow: 0 0 0 3px rgba(56,189,248,0.1); }
.timeline-date { font-family: 'Courier New', monospace; font-size: 11px; color: var(--text-muted); margin-bottom: 4px; letter-spacing: -0.01em; }
.timeline-item-title { font-size: 13px; color: var(--text-primary); font-weight: 500; }
.timeline-complements { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.comp-badge { font-size: 10px; background: rgba(56,189,248,0.08); color: rgba(56,189,248,0.8); padding: 3px 10px; border-radius: 4px; border: 1px solid rgba(56,189,248,0.12); font-weight: 500; }

#progressBar { transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1); }

@keyframes pulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 0.7; } }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.spinner {
  border: 2.5px solid rgba(255,255,255,0.06);
  border-top: 2.5px solid #38bdf8;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 14px auto;
}

.toast {
  background: rgba(17,24,39,0.97);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 12px 18px;
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  font-size: 13px;
  display: flex;
  gap: 10px;
  align-items: center;
  pointer-events: auto;
  backdrop-filter: blur(12px);
}
.toast.success { border-left: 3px solid #38bdf8; }
.toast.error { border-left: 3px solid #f87171; }

/* Pagination */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
}
.page-info { font-size: 11px; color: var(--text-muted); }
.page-btns { display: flex; gap: 4px; }
.page-btn {
  padding: 4px 10px;
  font-size: 11px;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  cursor: pointer;
  transition: all .15s;
}
.page-btn:hover { background: var(--bg-elevated); color: var(--text-primary); }
.page-btn.active { background: var(--accent-primary); color: #fff; border-color: var(--accent-primary); }
.page-btn:disabled { opacity: .3; cursor: not-allowed; }

/* btn-fav */
.btn-fav { opacity: 0.4; transition: all 0.2s; }
.btn-fav:hover { opacity: 0.8; }
.btn-fav.active { color: #f0c040; opacity: 1; }
