:root {
  --bg-primary: #0f172a;
  --bg-card: rgba(30, 41, 59, 0.7);
  --bg-card-hover: rgba(51, 65, 85, 0.8);
  --border-color: rgba(255, 255, 255, 0.1);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --accent-blue: #38bdf8;
  --accent-purple: #818cf8;
  --accent-green: #34d399;
  --accent-amber: #fbbf24;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --font-family: 'Mukta', 'Nirmala UI', 'Mangal', 'Arial', -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.app-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 16px;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  margin-bottom: 12px;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-badge {
  font-size: 28px;
  background: rgba(56, 189, 248, 0.15);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.app-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}

.badge-online {
  background: rgba(52, 211, 153, 0.15);
  color: var(--accent-green);
  border: 1px solid rgba(52, 211, 153, 0.3);
}

.badge-offline {
  background: rgba(251, 191, 36, 0.15);
  color: var(--accent-amber);
  border: 1px solid rgba(251, 191, 36, 0.3);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: currentColor;
}

/* Sync & Status Card */
.sync-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(129, 140, 248, 0.25);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.sync-card-info {
  display: flex;
  align-items: center;
}

.sync-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.db-icon {
  font-size: 1.4rem;
}

.sync-headline {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.sync-subtext {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.sync-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(129, 140, 248, 0.2);
  color: #a5b4fc;
  border: 1px solid rgba(129, 140, 248, 0.4);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-family);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.sync-action-btn:hover {
  background: rgba(129, 140, 248, 0.35);
  color: #ffffff;
  border-color: rgba(129, 140, 248, 0.6);
  transform: translateY(-1px);
}

.sync-action-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.spinning {
  display: inline-block;
  animation: spin 1s linear infinite;
}

/* Search Section */
.search-section {
  margin-bottom: 16px;
}

.search-box-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 12px;
}

.search-icon {
  position: absolute;
  left: 16px;
  width: 20px;
  height: 20px;
  color: var(--text-secondary);
}

.search-box-wrapper input {
  width: 100%;
  padding: 14px 44px 14px 48px;
  font-family: var(--font-family);
  font-size: 1.05rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  outline: none;
  transition: all 0.2s ease;
}

.search-box-wrapper input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

.clear-btn {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
}

.nav-group-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 10px;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filter-pills {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 4px;
  scrollbar-width: none;
}

.filter-pills::-webkit-scrollbar {
  display: none;
}

.pill {
  white-space: nowrap;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 20px;
  font-family: var(--font-family);
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.pill-cat.active, .pill-cat:hover {
  background: rgba(129, 140, 248, 0.25);
  color: var(--accent-purple);
  border-color: var(--accent-purple);
}

.pill-topic.active, .pill-topic:hover {
  background: rgba(251, 191, 36, 0.25);
  color: var(--accent-amber);
  border-color: var(--accent-amber);
}

.pill-court.active, .pill-court:hover {
  background: rgba(56, 189, 248, 0.2);
  color: var(--accent-blue);
  border-color: var(--accent-blue);
}

/* Card Summary Box & Action Button */
.card-summary-box {
  background: rgba(15, 23, 42, 0.5);
  border-left: 3px solid var(--accent-amber);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin: 10px 0;
  font-size: 0.92rem;
  color: #e2e8f0;
  line-height: 1.5;
}

.card-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.btn-view-detail {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), rgba(129, 140, 248, 0.25));
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #f8fafc;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-family);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-view-detail:hover {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.35), rgba(129, 140, 248, 0.4));
  border-color: var(--accent-blue);
  transform: translateY(-1px);
}

/* Category Badges */
.badge-cat {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-criminal {
  background: rgba(248, 113, 113, 0.18);
  color: #f87171;
  border: 1px solid rgba(248, 113, 113, 0.35);
}

.badge-civil {
  background: rgba(52, 211, 153, 0.18);
  color: #34d399;
  border: 1px solid rgba(52, 211, 153, 0.35);
}

.badge-writ {
  background: rgba(129, 140, 248, 0.18);
  color: #a5b4fc;
  border: 1px solid rgba(129, 140, 248, 0.35);
}

.badge-petition {
  background: rgba(251, 191, 36, 0.18);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.35);
}

/* Results header */
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.data-source-badge {
  font-size: 0.8rem;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
}

/* Judgment Card */
.judgments-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.judgment-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.judgment-card:hover {
  transform: translateY(-2px);
  border-color: rgba(56, 189, 248, 0.4);
  background: var(--bg-card-hover);
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
  gap: 8px;
}

.decision-badge {
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-blue);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
}

.date-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.meta-tag {
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 8px;
  border-radius: 4px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
}

.modal-backdrop.active {
  display: flex;
}

.modal-content {
  background: #1e293b;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 750px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  background: rgba(15, 23, 42, 0.5);
}

.modal-controls {
  display: flex;
  gap: 8px;
}

.tool-btn, .close-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-family);
  font-weight: 600;
}

.tool-btn:hover, .close-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  font-size: 1.05rem;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  background: rgba(15, 23, 42, 0.4);
  padding: 14px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.meta-item strong {
  color: var(--accent-blue);
  display: block;
  font-size: 0.8rem;
  text-transform: uppercase;
}

.divider {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 16px 0;
}

.judgment-text {
  white-space: pre-wrap;
  color: #e2e8f0;
  line-height: 1.8;
}

.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
}

.page-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.page-btn.active {
  background: var(--accent-blue);
  color: #0f172a;
  font-weight: 700;
}

.loading-state {
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(56, 189, 248, 0.2);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 600px) {
  .sync-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .sync-action-btn {
    width: 100%;
    justify-content: center;
  }
}

.app-footer {
  margin-top: 24px;
  padding: 14px 16px 8px;
  border-top: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.8rem;
  line-height: 1.5;
  text-align: center;
}

.footer-line + .footer-line {
  margin-top: 2px;
}

.app-footer a {
  color: var(--accent-blue);
  text-decoration: none;
}

.app-footer a:hover {
  text-decoration: underline;
}

.pill[hidden] {
  display: none !important;
}
