/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

/* * SAFE MODE: PICO DEFAULTS
 * We are leaving this standard to let Pico.css handle 
 * all colors (Blue/Azure) and Dark Mode automatically.
 */

/* Optional: Slight tweak to ensure text contrast if Pico defaults miss something */
@media (prefers-color-scheme: dark) {
  :root {
    --pico-color: #e3e6e8;
    --pico-background-color: #13171f;
  }
}

/* 
 * FLASH NOTIFICATIONS & ALERTS 
 * High-contrast styling for Rails Flash and Devise Errors
 */
.flash {
  margin-bottom: 1rem;
  padding: 1rem;
  border: 1px solid transparent; /* Border color defined by specific types below */
  border-radius: var(--pico-border-radius);
  /* Fallback */
  background-color: var(--pico-card-background-color);
  box-shadow: var(--pico-card-box-shadow);
}

/* Header for Devise Error Summaries */
.flash header {
  margin-bottom: 0.5rem;
  font-weight: bold;
  opacity: 1;
}

/* List for Devise Error Details */
.flash ul {
  margin-bottom: 0;
  padding-left: 1rem;
}

/* Success / Notice (Green) */
.flash--notice, .flash--success {
  background-color: #d1e7dd; /* Bootstrap Success BG */
  color: #0f5132;            /* Bootstrap Success Text */
  border-color: #badbcc;
  border-left: 0.5rem solid #0f5132;
}

/* Alert / Error (Red) */
.flash--alert, .flash--error, .flash--danger {
  background-color: #f8d7da; /* Bootstrap Danger BG */
  color: #842029;            /* Bootstrap Danger Text */
  border-color: #f5c2c7;
  border-left: 0.5rem solid #842029;
}

/* Warning (Yellow) */
.flash--warning {
  background-color: #fff3cd;
  color: #664d03;
  border-color: #ffecb5;
  border-left: 0.5rem solid #664d03;
}

/* Info (Blue) */
.flash--info {
  background-color: #cff4fc;
  color: #055160;
  border-color: #b6effb;
  border-left: 0.5rem solid #055160;
}

/* Hide empty flash containers */
.flash:empty {
  display: none;
}

/* Non-filer warning banner (reuses flash--warning palette) */
.non-filer-banner {
  margin-bottom: 1rem;
  padding: 1rem;
  background-color: #fff3cd;
  color: #664d03;
  border: 1px solid #ffecb5;
  border-left: 0.5rem solid #664d03;
  border-radius: var(--pico-border-radius);
}

.non-filer-banner a {
  color: #664d03;
  font-weight: 600;
}

/* Non-filer callout on landing page */
.non-filer-callout {
  text-align: center;
  margin-top: 1rem;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  color: #664d03;
  background-color: rgba(255, 243, 205, 0.5);
  border-radius: var(--pico-border-radius);
}

.non-filer-callout a {
  color: #664d03;
  font-weight: 600;
}

/* Year range labels below trend charts */
.trend-year-range {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  color: #94a3b8;
  margin-top: -0.25rem;
  padding: 0 0.125rem;
}

/* Missing years note below trend charts */
.trend-missing-years {
  display: block;
  margin-top: 0.25rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.7rem;
  color: #664d03;
  background-color: rgba(255, 243, 205, 0.5);
  border-radius: 0.25rem;
}

/* Non-filer badge for entity index */
.non-filer-badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background-color: #fff3cd;
  color: #664d03;
  border: 1px solid #ffecb5;
  border-radius: 0.25rem;
  margin-left: 0.5rem;
  vertical-align: middle;
}

/*
 * SORTABLE TABLE HEADERS
 * Clickable column headers for sorting tables
 */
.sortable-header {
  text-decoration: none;
  color: inherit;
  white-space: nowrap;
}

.sortable-header:hover {
  text-decoration: underline;
}

.sortable-header.active {
  font-weight: bold;
}

/*
 * PAGE HEADER LAYOUTS
 * Common pattern: title on left, action buttons on right
 */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.25rem;
}

.page-header--center {
  align-items: center;
}

.page-header hgroup {
  margin-bottom: 0;
}

/*
 * BUTTON GROUPS
 * Horizontal grouping for action buttons
 */
.button-group {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

.button-group--end {
  justify-content: flex-end;
}

.button-group--center {
  align-items: center;
}

/*
 * FILTER FORMS
 * Consistent styling for index page filters
 */
.filter-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1rem;
}

/*
 * CONTENT SECTIONS
 * Common spacing patterns
 */
.section-spaced {
  margin-bottom: 1.25rem;
}

.content-block {
  margin-top: 1rem;
}

/*
 * STATUS INDICATORS
 * Visual status badges
 */
.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.status-indicator--live {
  color: #2ea44f;
}

.status-indicator--live::before {
  content: "●";
}

/*
 * SOURCE TYPE BADGES
 * Document source type visual indicators
 */
.source-type-badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.source-type-badge.pdf {
  background-color: #dbeafe;
  color: #1e40af;
}

.source-type-badge.web {
  background-color: #dcfce7;
  color: #166534;
}

/*
 * UTILITY: Text alignment
 */
.text-right {
  text-align: right;
}

.align-self-center {
  align-self: center;
}

/*
 * UTILITY: Hidden for JS toggle
 * Use this instead of inline style="display: none"
 */
.hidden {
  display: none;
}

/*
 * DATA INDICATORS
 * Visual indicators for data states
 */
.missing-data {
  background-color: #fff3cd;
  color: #856404;
  padding: 0.1em 0.4em;
  border-radius: 3px;
  font-size: 0.85em;
}

.muted {
  color: #6c757d;
}

/*
 * UTILITY: Link styling
 */
.link-plain {
  text-decoration: none;
}

.link-plain:hover {
  text-decoration: underline;
}

/*
 * FINANCIAL TREND CHARTS
 * Sparkline-style area charts for entity dashboard
 */
.trends-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.trend-card {
  padding: 0.75rem;
  margin: 0;
}

.trend-card header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.5rem;
  padding: 0;
  border: none;
  background: none;
}

.trend-card header strong {
  font-size: 0.875rem;
}

.trend-latest {
  font-size: 0.875rem;
  color: var(--pico-muted-color);
}

.trend-card--revenue {
  background-color: rgba(22, 163, 74, 0.08);
  border-left: 3px solid #16a34a;
}

.trend-card--expenditure {
  background-color: rgba(220, 38, 38, 0.08);
  border-left: 3px solid #dc2626;
}

.trend-card--balance-sheet {
  background-color: rgba(37, 99, 235, 0.08);
  border-left: 3px solid #2563eb;
}

.trend-card--derived {
  background-color: rgba(139, 92, 246, 0.08);
  border-left: 3px solid #8b5cf6;
}

/*
 * FINANCIAL TRENDS SECTION HEADERS
 * Subsection headers within the financial trends area
 */
#financial-trends h3 {
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--pico-color);
  border-bottom: 1px solid var(--pico-muted-border-color);
  padding-bottom: 0.25rem;
}

/*
 * LANDING PAGE
 */
.landing-hero {
  text-align: center;
  padding: 2rem 0 1rem;
}

.landing-hero h1 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
}

.landing-stats {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin: 1.5rem 0;
}

.landing-stat {
  text-align: center;
  min-width: 100px;
}

.landing-stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  display: block;
}

.landing-stat-label {
  font-size: 0.75rem;
  color: var(--pico-muted-color);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Rankings grid: 1 col mobile, 2 col tablet, 3 col desktop */
.rankings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin: 2rem 0;
}

@media (min-width: 768px) {
  .rankings-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1200px) {
  .rankings-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.ranking-card {
  margin: 0;
}

.ranking-card table {
  margin: 0;
  font-size: 0.875rem;
}

.ranking-card td:last-child,
.ranking-card th:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.ranking-card td:first-child {
  width: 2rem;
  color: var(--pico-muted-color);
}

.ranking-description {
  font-size: 0.8rem;
  color: var(--pico-muted-color);
  margin-bottom: 0.75rem;
}

/* Toggle buttons for Top 10 / Bottom 10 */
.ranking-toggle-group {
  display: flex;
  gap: 0;
}

.ranking-toggle {
  all: unset;
  cursor: pointer;
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  border: 1px solid var(--pico-muted-border-color);
  color: var(--pico-muted-color);
  background: transparent;
}

.ranking-toggle:first-child {
  border-radius: var(--pico-border-radius) 0 0 var(--pico-border-radius);
}

.ranking-toggle:last-child {
  border-radius: 0 var(--pico-border-radius) var(--pico-border-radius) 0;
  border-left: none;
}

.ranking-toggle--active {
  background: var(--pico-primary-background);
  color: var(--pico-primary-inverse);
  border-color: var(--pico-primary-background);
}

.ranking-toggle--active + .ranking-toggle {
  border-left: 1px solid var(--pico-primary-background);
}

.ranking-card header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/*
 * ENTITY HERO STATS
 */
.hero-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

@media (min-width: 768px) {
  .hero-stats {
    grid-template-columns: repeat(4, 1fr);
  }
}

.hero-stat {
  padding: 1rem;
  background: var(--pico-card-background-color);
  border-radius: var(--pico-border-radius);
}

.hero-stat-value {
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  font-weight: 700;
  display: block;
  font-variant-numeric: tabular-nums;
}

.hero-stat-label {
  font-size: 0.75rem;
  color: var(--pico-muted-color);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.25rem;
}

/*
 * RESPONSIVE: Page header stacking on mobile
 */
@media (max-width: 576px) {
  .page-header {
    flex-direction: column;
    gap: 1rem;
  }
  .page-header .button-group {
    width: 100%;
    justify-content: flex-start;
  }
}