/* ==========================================================================
   CotaGov — Design System Institucional Claro
   Paleta: Icy Blue (#b7d3f2), Wheat (#ead2ac), Teal (#087f8c),
           Ink Black (#050517), Lemon Chiffon (#fef6c9)
   ========================================================================== */

:root {
  /* Paleta Oficial */
  --color-teal: #087f8c;
  --color-teal-hover: #066670;
  --color-teal-light: rgba(8, 127, 140, 0.1);
  --color-teal-subtle: rgba(8, 127, 140, 0.05);

  --color-icy-blue: #b7d3f2;
  --color-icy-blue-light: #eaf2fb;
  --color-icy-blue-subtle: #f4f8fd;

  --color-wheat: #ead2ac;
  --color-wheat-light: #faf5ed;
  --color-wheat-border: #dfc294;

  --color-ink: #050517;
  --color-ink-light: #2c2d44;
  --color-ink-muted: #5a5c78;
  --color-ink-subtle: #8e90a8;

  --color-lemon: #fef6c9;
  --color-lemon-border: #f5e48d;

  /* Superfícies & Layout */
  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-subtle: #f1f5f9;
  --bg-surface-elevated: #ffffff;

  --border-light: #e2e8f0;
  --border-focus: var(--color-teal);
  --border-subtle: #f1f5f9;

  /* Cores de Status / Feedback */
  --status-success: #0d9488;
  --status-success-bg: #f0fdfa;
  --status-warning: #d97706;
  --status-warning-bg: #fffbeb;
  --status-danger: #e11d48;
  --status-danger-bg: #fff1f2;
  --status-info: #0284c7;
  --status-info-bg: #f0f9ff;

  /* Tipografia */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Sombras */
  --shadow-sm: 0 1px 2px 0 rgba(5, 5, 23, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(5, 5, 23, 0.07), 0 2px 4px -2px rgba(5, 5, 23, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(5, 5, 23, 0.08), 0 4px 6px -4px rgba(5, 5, 23, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(5, 5, 23, 0.1), 0 8px 10px -6px rgba(5, 5, 23, 0.04);

  /* Transições & Raio */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   Reset & Base
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--color-ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--color-ink);
  line-height: 1.25;
}

a {
  color: var(--color-teal);
  text-decoration: none;
  transition: var(--transition);
}
a:hover {
  color: var(--color-teal-hover);
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

/* ==========================================================================
   Top Header Navigation
   ========================================================================== */
.app-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--color-ink);
  letter-spacing: -0.5px;
}

.brand-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--color-teal), #0da6b7);
  color: #ffffff;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  box-shadow: 0 2px 8px rgba(8, 127, 140, 0.3);
}

.brand-badge {
  font-size: 0.65rem;
  font-weight: 700;
  background: var(--color-lemon);
  color: #715502;
  border: 1px solid var(--color-lemon-border);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  list-style: none;
}

.nav-item a {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.95rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-ink-muted);
  transition: var(--transition);
}

.nav-item a:hover {
  background: var(--color-icy-blue-subtle);
  color: var(--color-teal);
}

.nav-item.active a {
  background: var(--color-teal-light);
  color: var(--color-teal);
}

.user-profile-menu {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-light);
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  font-size: 0.85rem;
}

.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--color-teal);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
}

/* ==========================================================================
   Main Content Container & Views
   ========================================================================== */
.main-wrapper {
  max-width: 1320px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  flex: 1;
  width: 100%;
}

.view-section {
  display: none;
  animation: fadeIn 0.25s ease;
}

.view-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Typography & Header Sections
   ========================================================================== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-title {
  font-size: 1.85rem;
  letter-spacing: -0.5px;
}

.page-subtitle {
  font-size: 0.95rem;
  color: var(--color-ink-muted);
  margin-top: 0.25rem;
}

/* ==========================================================================
   Cards & Grids
   ========================================================================== */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  transition: var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0.85rem;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.grid-cols-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.grid-cols-2 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 900px) {
  .grid-cols-2 {
    grid-template-columns: 1fr;
  }
}

/* Stat Metric Card */
.metric-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 1.35rem;
}

.metric-label {
  font-size: 0.825rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-ink-muted);
  margin-bottom: 0.4rem;
}

.metric-value {
  font-family: var(--font-display);
  font-size: 1.95rem;
  font-weight: 800;
  color: var(--color-ink);
  line-height: 1.1;
}

.metric-subtext {
  font-size: 0.8rem;
  color: var(--color-ink-muted);
  margin-top: 0.4rem;
}

.metric-icon-box {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
}

.icon-teal { background: var(--color-teal-light); color: var(--color-teal); }
.icon-blue { background: var(--color-icy-blue-light); color: #1e6bb8; }
.icon-wheat { background: var(--color-wheat-light); color: #9c6c24; }
.icon-lemon { background: var(--color-lemon); color: #856404; }

/* Progress Bar */
.progress-bar-container {
  width: 100%;
  height: 8px;
  background: var(--bg-surface-subtle);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.6rem;
}

.progress-bar-fill {
  height: 100%;
  background: var(--color-teal);
  border-radius: 999px;
  transition: width 0.4s ease;
}

/* ==========================================================================
   Buttons & Inputs
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
  outline: none;
}

.btn-primary {
  background: var(--color-teal);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(8, 127, 140, 0.25);
}
.btn-primary:hover {
  background: var(--color-teal-hover);
  box-shadow: 0 4px 12px rgba(8, 127, 140, 0.35);
  color: #ffffff;
}

.btn-secondary {
  background: var(--bg-surface);
  border-color: var(--border-light);
  color: var(--color-ink);
}
.btn-secondary:hover {
  background: var(--bg-surface-subtle);
  border-color: var(--color-ink-subtle);
}

.btn-wheat {
  background: var(--color-wheat);
  color: #4a3411;
  border-color: var(--color-wheat-border);
}
.btn-wheat:hover {
  background: #dfc294;
}

.btn-outline-danger {
  background: transparent;
  border-color: #fecdd3;
  color: var(--status-danger);
}
.btn-outline-danger:hover {
  background: var(--status-danger-bg);
  border-color: var(--status-danger);
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
}

.form-group {
  margin-bottom: 1.15rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-ink-light);
  margin-bottom: 0.4rem;
}

.form-control {
  width: 100%;
  padding: 0.65rem 0.95rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  color: var(--color-ink);
  font-size: 0.925rem;
  transition: var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--color-teal);
  box-shadow: 0 0 0 3px var(--color-teal-light);
}

/* Search Bar Box */
.search-box-wrapper {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}

.search-input-group {
  display: flex;
  gap: 0.75rem;
}

.search-filters-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
}

/* ==========================================================================
   Tables & Data Lists
   ========================================================================== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  text-align: left;
  font-size: 0.875rem;
}

.data-table th {
  background: var(--bg-surface-subtle);
  color: var(--color-ink-muted);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-light);
}

.data-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--color-ink-light);
  vertical-align: middle;
}

.data-table tbody tr:hover td {
  background: var(--color-icy-blue-subtle);
}

.data-table tbody tr.row-outlier td {
  background: #fff5f5;
  border-left: 3px solid var(--status-danger);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-teal { background: var(--color-teal-light); color: var(--color-teal); }
.badge-blue { background: var(--color-icy-blue); color: #0f4b82; }
.badge-wheat { background: var(--color-wheat); color: #533910; }
.badge-lemon { background: var(--color-lemon); color: #725301; border: 1px solid var(--color-lemon-border); }
.badge-danger { background: var(--status-danger-bg); color: var(--status-danger); border: 1px solid #fecdd3; }
.badge-success { background: var(--status-success-bg); color: var(--status-success); border: 1px solid #99f6e4; }

/* Price Formatter Highlight */
.price-tag {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  color: var(--color-ink);
}

/* ==========================================================================
   Statistical Workspace IN 65/2021
   ========================================================================== */
.stats-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-pill-card {
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.stat-pill-card.primary-calc {
  background: var(--color-wheat-light);
  border-color: var(--color-wheat-border);
}

.stat-pill-card.primary-calc .stat-pill-value {
  color: #79500c;
  font-size: 1.65rem;
}

.stat-pill-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-ink-muted);
  margin-bottom: 0.25rem;
}

.stat-pill-value {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--color-ink);
}

/* ==========================================================================
   Modals & Dialogs
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 23, 0.45);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1.5rem;
}

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

.modal-dialog {
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 540px;
  overflow: hidden;
  animation: modalIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-dialog.modal-lg {
  max-width: 780px;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body {
  padding: 1.5rem;
  max-height: 75vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-light);
  background: var(--bg-surface-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* ==========================================================================
   Toasts & Alerts
   ========================================================================== */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--color-ink);
  color: #ffffff;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  animation: slideUp 0.3s ease;
}

.toast.toast-success { background: var(--status-success); }
.toast.toast-danger { background: var(--status-danger); }
.toast.toast-warning { background: #b45309; }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Empty States & Loaders
   ========================================================================== */
.empty-state {
  text-align: center;
  padding: 3.5rem 1.5rem;
  color: var(--color-ink-muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 0.85rem;
  color: var(--color-teal);
}

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(8, 127, 140, 0.2);
  border-top-color: var(--color-teal);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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