/* ============================================================
   contractes.opendata.cat — "Portal Obert" theme
   Public procurement portal — light, professional, welcoming
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Archivo:wght@400;500;600;700;800&display=swap');

:root {
  --primary: #1a365d;
  --primary-light: #2b4c7e;
  --primary-lighter: #e8eef6;
  --primary-bg: #f0f4f9;
  --accent: #e67e22;
  --accent-light: #f39c4f;
  --accent-bg: #fef5eb;

  --bg: #f7f8fa;
  --bg-white: #ffffff;
  --bg-subtle: #f0f2f5;

  --text: #1e293b;
  --text-dim: #64748b;
  --text-muted: #94a3b8;
  --text-bright: #0f172a;

  --border: #e2e8f0;
  --border-light: #f1f5f9;

  --green: #16a34a;
  --green-bg: #f0fdf4;
  --blue: #2563eb;
  --blue-bg: #eff6ff;
  --amber: #d97706;
  --amber-bg: #fffbeb;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --purple: #7c3aed;
  --purple-bg: #f5f3ff;

  --font-display: 'Archivo', system-ui, -apple-system, sans-serif;
  --font-body: 'Archivo', system-ui, -apple-system, sans-serif;

  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.07);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);
}

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

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

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-light); text-decoration: underline; }

/* ---- Navigation ---- */
.nav {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.nav-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  height: 56px;
  gap: 32px;
}
.nav-brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  text-decoration: none;
}
.nav-brand:hover { text-decoration: none; color: var(--primary-light); }
.nav-brand-icon { display: flex; align-items: center; color: var(--accent); }
.nav-links {
  display: flex;
  list-style: none;
  gap: 4px;
  flex: 1;
}
.nav-links li a {
  display: block;
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-dim);
  transition: all 0.15s;
  text-decoration: none;
}
.nav-links li a:hover {
  background: var(--primary-lighter);
  color: var(--primary);
  text-decoration: none;
}
.nav-links li a.active {
  background: var(--primary);
  color: #fff;
}
.nav-info {
  margin-left: auto;
}
.nav-info-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ---- Main ---- */
.main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
  min-height: calc(100vh - 56px - 120px);
}
.container { max-width: 1280px; margin: 0 auto; }

/* ---- Hero / Search ---- */
.hero {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  border-radius: var(--radius-xl);
  padding: 48px 40px;
  margin-bottom: 32px;
  color: #fff;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -10%;
  width: 400px;
  height: 400px;
  background: rgba(255,255,255,0.05);
  border-radius: 50%;
}
.hero::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: 20%;
  width: 250px;
  height: 250px;
  background: rgba(255,255,255,0.03);
  border-radius: 50%;
}
.hero-content { position: relative; z-index: 1; }
.hero h1 {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}
.hero p {
  font-size: 1.05rem;
  opacity: 0.85;
  margin-bottom: 24px;
  max-width: 600px;
}
.hero-search {
  display: flex;
  gap: 0;
  max-width: 640px;
  position: relative;
}
.hero-search input[type="text"] {
  flex: 1;
  padding: 14px 20px;
  font-size: 1rem;
  border: 2px solid rgba(255,255,255,0.25);
  border-right: none;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  background: rgba(255,255,255,0.12);
  color: #fff;
  outline: none;
  font-family: var(--font-body);
}
.hero-search input[type="text"]::placeholder { color: rgba(255,255,255,0.55); }
.hero-search input[type="text"]:focus { border-color: rgba(255,255,255,0.5); background: rgba(255,255,255,0.18); }
.hero-search button {
  padding: 14px 28px;
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font-body);
  border: none;
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.hero-search button:hover { background: var(--accent-light); }

/* ---- Stats Grid ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s;
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-card-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.stat-card-value {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.02em;
}
.stat-card-value.accent { color: var(--accent); }
.stat-card-value.green { color: var(--green); }
.stat-card-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ---- Cards ---- */
.card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.card-header h2 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-bright);
}
.card-header .card-count {
  font-size: 0.82rem;
  color: var(--text-muted);
  background: var(--bg-subtle);
  padding: 4px 12px;
  border-radius: 20px;
}

/* ---- Section titles ---- */
.section-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-bright);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-title .title-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}
.section-title .title-icon.blue { background: var(--blue-bg); color: var(--blue); }
.section-title .title-icon.green { background: var(--green-bg); color: var(--green); }
.section-title .title-icon.amber { background: var(--amber-bg); color: var(--amber); }

/* ---- Opportunity Cards ---- */
.opp-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.opp-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s, border-color 0.15s;
  display: block;
  text-decoration: none;
  color: var(--text);
}
.opp-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary-lighter);
  text-decoration: none;
}
.opp-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}
.opp-card-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--primary);
  line-height: 1.4;
  flex: 1;
}
.opp-card-budget {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-bright);
  white-space: nowrap;
}
.opp-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 0.82rem;
  color: var(--text-dim);
}
.opp-card-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}
.opp-card-meta .meta-label {
  color: var(--text-muted);
  font-weight: 500;
}

/* ---- Badges ---- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge-open { background: var(--green-bg); color: var(--green); }
.badge-awarded { background: var(--blue-bg); color: var(--blue); }
.badge-formal { background: var(--purple-bg); color: var(--purple); }
.badge-muted { background: var(--bg-subtle); color: var(--text-muted); }
.badge-primary { background: var(--primary-lighter); color: var(--primary); }
.badge-accent { background: var(--accent-bg); color: var(--accent); }

/* ---- Tables ---- */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
table thead th {
  background: var(--bg-subtle);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  padding: 10px 14px;
  text-align: left;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
}
table thead th[data-sort="asc"]::after { content: ' \2191'; }
table thead th[data-sort="desc"]::after { content: ' \2193'; }
table tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: top;
}
table tbody tr:hover { background: var(--primary-bg); }
table tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; }
td.nowrap { white-space: nowrap; }

/* ---- Filters ---- */
.filters {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.filters-title {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  align-items: end;
}
.filter-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.filter-group select,
.filter-group input[type="text"],
.filter-group input[type="number"],
.filter-group input[type="date"] {
  width: 100%;
  padding: 8px 12px;
  font-size: 0.88rem;
  font-family: var(--font-body);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-white);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.filter-group select:focus,
.filter-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 54, 93, 0.08);
}

/* ---- Buttons ---- */
.btn {
  display: inline-block;
  padding: 8px 20px;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: var(--font-body);
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  text-align: center;
}
.btn:hover { text-decoration: none; }
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-light); color: #fff; }
.btn-accent {
  background: var(--accent);
  color: #fff;
}
.btn-accent:hover { background: var(--accent-light); color: #fff; }
.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text-dim);
}
.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-lighter);
}
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- Pagination ---- */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  margin-top: 24px;
  flex-wrap: wrap;
}
.page-link {
  display: inline-block;
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  transition: all 0.15s;
}
.page-link:hover {
  background: var(--primary-lighter);
  color: var(--primary);
  border-color: var(--primary-lighter);
  text-decoration: none;
}
.page-link.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.page-ellipsis {
  padding: 6px 8px;
  color: var(--text-muted);
}

/* ---- Detail page ---- */
.detail-header {
  margin-bottom: 24px;
}
.detail-header h1 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-bright);
  margin-bottom: 8px;
  line-height: 1.3;
}
.detail-header .detail-sub {
  font-size: 0.9rem;
  color: var(--text-dim);
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
}
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}
.detail-field {
  padding: 14px 0;
  border-bottom: 1px solid var(--border-light);
}
.detail-field:last-child { border-bottom: none; }
.detail-field-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.detail-field-value {
  font-size: 0.95rem;
  color: var(--text);
  font-weight: 500;
}
.detail-field-value.large {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--primary);
}

/* ---- Two-column layout ---- */
.layout-sidebar {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
}
@media (max-width: 900px) {
  .layout-sidebar {
    grid-template-columns: 1fr;
  }
}

/* ---- Empty state ---- */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state p {
  font-size: 1rem;
  margin-bottom: 16px;
}

/* ---- Footer ---- */
.footer {
  background: var(--primary);
  color: rgba(255,255,255,0.8);
  margin-top: 48px;
}
.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.footer-brand {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.footer-brand strong {
  font-family: var(--font-display);
  font-size: 1rem;
  color: #fff;
}
.footer-brand span {
  font-size: 0.82rem;
  opacity: 0.7;
}
.footer-links {
  display: flex;
  gap: 20px;
}
.footer-links a {
  color: rgba(255,255,255,0.7);
  font-size: 0.85rem;
  text-decoration: none;
}
.footer-links a:hover { color: #fff; text-decoration: underline; }
.footer-copy {
  font-size: 0.75rem;
  opacity: 0.55;
  max-width: 600px;
  line-height: 1.5;
}

/* ---- Search results highlight ---- */
.search-section-label {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 12px;
  margin-top: 28px;
}
.search-section-label:first-child { margin-top: 0; }

/* ---- Quick links on home ---- */
.quick-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 32px;
}
.quick-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: var(--text);
  transition: all 0.15s;
}
.quick-link:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary-lighter);
  text-decoration: none;
}
.quick-link-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.quick-link-icon.blue { background: var(--blue-bg); color: var(--blue); }
.quick-link-icon.green { background: var(--green-bg); color: var(--green); }
.quick-link-icon.amber { background: var(--amber-bg); color: var(--amber); }
.quick-link-icon.purple { background: var(--purple-bg); color: var(--purple); }
.quick-link-text {
  font-weight: 600;
  font-size: 0.88rem;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .main { padding: 16px; }
  .hero { padding: 32px 24px; }
  .hero h1 { font-size: 1.4rem; }
  .hero p { font-size: 0.92rem; }
  .hero-search { flex-direction: column; }
  .hero-search input[type="text"] { border-radius: var(--radius-lg); border-right: 2px solid rgba(255,255,255,0.25); }
  .hero-search button { border-radius: var(--radius-lg); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .filters-grid { grid-template-columns: 1fr; }
  .opp-card-top { flex-direction: column; gap: 8px; }
  .nav-info { display: none; }
  .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}
