/* =============================================================== */
/* UI REVAMP: COMMON FOUNDATION - THEME VARIABLES
/* =============================================================== */

:root {
  /* Color Palette - Orange & Blue Theme */
  --color-primary: #ff7a1f;
  --color-primary-dark: #e66000;
  --color-primary-hover: #e66000; /* 10% darker than primary */
  --color-secondary: #0b4f91;
  --color-secondary-dark: #073765;
  --color-secondary-hover: #073765; /* 10% darker than secondary */

  /* Semantic Colors for UI Conventions */
  --color-danger: #dc3545;
  --color-danger-hover: #c82333;
  --color-success: #28a745;
  --color-success-hover: #218838;

  /* Background & Layout */
  --color-bg-soft: #fafafa;
  --color-bg-white: #ffffff;
  --color-border: #e1e1e1;
  --color-text: #222;
  --color-text-light: #666;
  --color-text-white: #ffffff;

  /* Gradients */
  --gradient-hero: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 70%);

  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  --spacing-xxl: 3rem;

  /* Typography */
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-xxl: 1.5rem;

  /* Component sizing */
  --border-radius: 4px;
  --border-radius-lg: 8px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);

  /* Focus states */
  --focus-outline: 2px solid #111;
  --focus-offset: 2px;
}

/* =============================================================== */
/* BUTTON COMPONENTS - Updated with Theme Variables
/* =============================================================== */

/* Primary Button */
.btn-primary {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-text) !important;
  /* Ensure Bootstrap 5 button variables also yield black text
     This prevents later generic `.btn { color: var(--bs-btn-color) }` rules
     from re-introducing white text when variables default to #fff. */
  --bs-btn-color: var(--color-text) !important;
  --bs-btn-hover-color: var(--color-text) !important;
  transition: all 0.2s ease-in-out;
}

/* Accessibility: Ensure sufficient contrast for the homepage/advanced search CTA */
.btn.btn-primary.btn-search {
  /* Bright orange background requires dark foreground to meet WCAG AA */
  color: var(--color-text) !important; /* #222 by default */
  text-shadow: none !important; /* remove greenish shadow that reduces readability */
  box-shadow: none !important;
}

.btn.btn-primary.btn-search:hover,
.btn.btn-primary.btn-search:focus,
.btn.btn-primary.btn-search:active {
  color: var(--color-text) !important;
  background-color: var(--color-primary) !important;
  border-color: var(--color-primary) !important;
}

/* =============================================================== */
/* PAGE-SPECIFIC OVERRIDES                                         */
/* =============================================================== */
/* Reduce margin/padding for target H4 inside search results page */
.jobs-list .blog-card .blog-post-title {
  margin: 0 !important;
  padding-bottom: 0 !important;
}

/* Set a small margin for all result descriptions */
#main-content > main > div.main-container > div > div > div.col-sm-9.page-content.col-thin-left > div.category-list > div.adds-wrapper.jobs-list div.blog-card .jobs-desc {
  margin-top: 15px !important;
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active,
.btn-primary.active,
.open .dropdown-toggle.btn-primary {
  background-color: var(--color-primary-hover) !important;
  border-color: var(--color-primary-hover) !important;
  color: var(--color-text) !important;
}

.btn-primary:focus {
  outline: var(--focus-outline);
  outline-offset: var(--focus-offset);
}

/* Secondary Button */
.btn-secondary {
  background-color: var(--color-secondary) !important;
  border-color: var(--color-secondary) !important;
  color: var(--color-text-white) !important;
  transition: all 0.2s ease-in-out;
}

.btn-secondary:hover,
.btn-secondary:focus,
.btn-secondary:active,
.btn-secondary.active,
.open .dropdown-toggle.btn-secondary {
  background-color: var(--color-secondary-hover) !important;
  border-color: var(--color-secondary-hover) !important;
  color: var(--color-text-white) !important;
}

.btn-secondary:focus {
  outline: var(--focus-outline);
  outline-offset: var(--focus-offset);
}

/* Outline Button */
.btn-outline {
  background-color: transparent !important;
  border: 2px solid var(--color-primary) !important;
  color: var(--color-primary) !important;
  transition: all 0.2s ease-in-out;
}

.btn-outline:hover,
.btn-outline:focus,
.btn-outline:active,
.btn-outline.active {
  background-color: var(--color-primary) !important;
  border-color: var(--color-primary) !important;
  color: var(--color-text-white) !important;
}

.btn-outline:focus {
  outline: var(--focus-outline);
  outline-offset: var(--focus-offset);
}

/* =============================================================== */
/* HERO STATS: Ensure text contrast on gradient background          */
/* =============================================================== */
.hero .iconbox-wrap-text,
.hero .iconbox-wrap-text strong {
  color: var(--color-text-white) !important;
}

/* Link Button */
.btn-link {
  background-color: transparent !important;
  border: none !important;
  color: var(--color-primary) !important;
  text-decoration: underline;
  transition: all 0.2s ease-in-out;
}

.btn-link:hover,
.btn-link:focus {
  color: var(--color-primary-hover) !important;
  text-decoration: none;
}

.btn-link:focus {
  outline: var(--focus-outline);
  outline-offset: var(--focus-offset);
}

/* Danger Button - Red for destructive actions (semantic clarity) */
.btn-danger {
  background-color: var(--color-danger) !important;
  border-color: var(--color-danger) !important;
  color: var(--color-text-white) !important;
  transition: all 0.2s ease-in-out;
}

.btn-danger:hover,
.btn-danger:focus,
.btn-danger:active,
.btn-danger.active,
.open .dropdown-toggle.btn-danger {
  background-color: var(--color-danger-hover) !important;
  border-color: var(--color-danger-hover) !important;
  color: var(--color-text-white) !important;
}

.btn-danger:focus {
  outline: var(--focus-outline);
  outline-offset: var(--focus-offset);
}

/* Success Button - Green for positive actions (semantic clarity) */
.btn-success {
  background-color: var(--color-success) !important;
  border-color: var(--color-success) !important;
  color: var(--color-text-white) !important;
  transition: all 0.2s ease-in-out;
}

.btn-success:hover,
.btn-success:focus,
.btn-success:active,
.btn-success.active,
.open .dropdown-toggle.btn-success {
  background-color: var(--color-success-hover) !important;
  border-color: var(--color-success-hover) !important;
  color: var(--color-text-white) !important;
}

.btn-success:focus {
  outline: var(--focus-outline);
  outline-offset: var(--focus-offset);
}

/* Info Button - Styled with secondary blue */
.btn-info {
  background-color: var(--color-secondary) !important;
  border-color: var(--color-secondary) !important;
  color: var(--color-text-white) !important;
  transition: all 0.2s ease-in-out;
}

.btn-info:hover,
.btn-info:focus,
.btn-info:active,
.btn-info.active,
.open .dropdown-toggle.btn-info {
  background-color: var(--color-secondary-hover) !important;
  border-color: var(--color-secondary-hover) !important;
  color: var(--color-text-white) !important;
}

.btn-info:focus {
  outline: var(--focus-outline);
  outline-offset: var(--focus-offset);
}

/* Border Button Variants */
.btn-border {
  background-color: transparent !important;
  border: 2px solid !important;
  transition: all 0.2s ease-in-out;
}

.btn-border.btn-danger {
  border-color: var(--color-danger) !important;
  color: var(--color-danger) !important;
}

.btn-border.btn-danger:hover,
.btn-border.btn-danger:focus,
.btn-border.btn-danger:active {
  background-color: var(--color-danger) !important;
  border-color: var(--color-danger) !important;
  color: var(--color-text-white) !important;
}

.btn-border.btn-primary {
  border-color: var(--color-primary) !important;
  color: var(--color-primary) !important;
}

.btn-border.btn-primary:hover,
.btn-border.btn-primary:focus,
.btn-border.btn-primary:active {
  background-color: var(--color-primary) !important;
  border-color: var(--color-primary) !important;
  color: var(--color-text-white) !important;
}

.btn-border.btn-secondary {
  border-color: var(--color-secondary) !important;
  color: var(--color-secondary) !important;
}

.btn-border.btn-secondary:hover,
.btn-border.btn-secondary:focus,
.btn-border.btn-secondary:active {
  background-color: var(--color-secondary) !important;
  border-color: var(--color-secondary) !important;
  color: var(--color-text-white) !important;
}

.btn-border.btn-success {
  border-color: var(--color-success) !important;
  color: var(--color-success) !important;
}

.btn-border.btn-success:hover,
.btn-border.btn-success:focus,
.btn-border.btn-success:active {
  background-color: var(--color-success) !important;
  border-color: var(--color-success) !important;
  color: var(--color-text-white) !important;
}

/* =============================================================== */
/* HERO SECTION - Gradient Background (replaces background image)
/* =============================================================== */

.hero {
  background: var(--gradient-hero);
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

/* Smaller hero variant for search page */
.hero.hero-compact {
  min-height: 0;
  height: auto !important;
  padding-top: var(--spacing-xs);
  padding-bottom: var(--spacing-xs);
}

/* Collapse legacy intro/table overlay in compact hero */
.hero.hero-compact .dtable,
.hero.hero-compact.hasOverly .dtable {
  height: auto !important;
  min-height: 0 !important;
  background: transparent !important;
  display: block !important; /* break out of table layout */
  padding: 0 !important; /* remove legacy vertical padding that inflates height */
}

.hero.hero-compact .dtable-cell {
  height: auto !important;
  display: block !important;
  padding: 0 !important;
}

.hero.hero-compact.intro,
.hero.hero-compact .intro {
  height: auto !important;
  min-height: 0 !important;
}

/* In compact hero, remove extra vertical padding/margins around search form */
.hero.hero-compact .search-form {
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

.hero.hero-compact .search-bar {
  /* tighter margins to keep header small, especially on mobile */
  margin: 0.25rem 0 0.5rem 0 !important;
}

/* Defeat legacy mobile padding on hasOverly direct child in compact hero */
@media (max-width: 767.98px) {
  .hero.hero-compact.hasOverly > div,
  .hero.hero-compact.hasOverly > .dtable {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
  }
}

.hero .container {
  position: relative;
  z-index: 2;
}

.hero h1,
.hero .intro-title {
  color: var(--color-text-white);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.hero p,
.hero .sub {
  color: var(--color-text-white);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* =============================================================== */
/* UNIFIED SEARCH BAR SIZING (matches home page)                   */
/* =============================================================== */
.hero .search-bar .form-control {
  height: 46px !important;
  border-radius: 4px 0 0 4px;
}

.search-button-wrapper .btn {
  height: 46px;
  border-radius: 0 4px 4px 0;
  white-space: nowrap;
}

/* =============================================================== */
/* HEADER / NAVBAR ALIGNMENT FIXES                                */
/* Ensure the logo aligns vertically with nav links and removes    */
/* stray spacing from inline elements inside the brand anchor.     */
/* =============================================================== */
.header .navbar .navbar-brand {
  padding-top: 0.25rem;   /* align closer to nav-link vertical rhythm */
  padding-bottom: 0.25rem;
  display: flex;
  align-items: center;
  margin-bottom: 0;       /* avoid baseline shifting */
}

.header .navbar .navbar-brand span {
  display: block;         /* prevent inline baseline gap */
  line-height: 0;         /* remove extra vertical whitespace around image */
}

.header .navbar .navbar-brand img {
  height: 32px;           /* consistent with base template intention */
  width: auto;
  display: block;         /* removes descender whitespace of inline images */
  margin: 0;              /* no unexpected offset */
  border: 0;              /* avoid any default image borders */
}

/* Keep nav links visually centered against the brand */
.header .navbar .navbar-nav .nav-link {
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
  display: flex;
  align-items: center;
}

/* Header CTA: Alertas button sizing and alignment */
.header .navbar .postadd .btn {
  display: inline-flex !important;           /* ensure icon + text align properly */
  align-items: center !important;
  gap: 6px !important;                       /* space between icon and text */
  white-space: nowrap !important;            /* prevent wrapping within the button */
  padding: 6px 12px !important;              /* slightly tighter to avoid overflow */
  line-height: 1.15 !important;              /* compact vertical rhythm */
  font-size: 0.9rem !important;              /* ~14.4px for better fit on tight navbars */
}

.header .navbar .postadd .btn i,
.header .navbar .postadd .btn .icon,
.header .navbar .postadd .btn [class^="icon-"] {
  font-size: 0.85em !important;              /* scale icon smaller than text */
  line-height: 1 !important;                 /* avoid extra vertical space */
}

@media (max-width: 991.98px) {
  /* On smaller screens, reduce size a bit more to avoid overflow */
  .header .navbar .postadd .btn {
    padding: 6px 10px !important;
    font-size: 0.85rem !important;          /* ~13.6px */
  }
  .header .navbar .postadd .btn i,
  .header .navbar .postadd .btn .icon,
  .header .navbar .postadd .btn [class^="icon-"] {
    font-size: 0.8em !important;
  }
}

@media (max-width: 767.98px) {
  .hero .search-bar { flex-direction: column; gap: 0.5rem; }
  .hero .search-bar .form-control { border-radius: 4px; }
  /* Ensure the search button wrapper aligns flush under the input on mobile */
  .hero .search-bar .search-button-wrapper {
    margin-left: 0 !important; /* override .ms-2 used for desktop */
    margin-right: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    align-self: stretch; /* stretch full width in column layout */
    width: 100%;
  }
  .search-button-wrapper .btn { border-radius: 4px; width: 100%; }
}

/* =============================================================== */
/* ADVANCED SEARCH PAGE LAYOUT (concursos-abertos-previstos)       */
/* Force a clear two-column layout: filters (left) + results (right)
   without changing HTML/Django logic. Scoped to the page structure. */

/* Make the main row a flex container on md+ screens */
#main-content > main > div.main-container > div.container > div.row {
  display: flex;
  flex-wrap: nowrap;
  gap: 16px; /* small gutter between columns */
}

/* Left sidebar (filters) */
#main-content > main > div.main-container > div.container > div.row > .page-sidebar.mobile-filter-sidebar {
  flex: 0 0 280px; /* fixed comfortable width */
  max-width: 340px;
  float: none !important; /* defeat bootstrap float so flex takes over */
  width: auto !important;
}

/* Right content (results) */
#main-content > main > div.main-container > div.container > div.row > .page-content.col-thin-left {
  flex: 1 1 auto;
  min-width: 0; /* allow content to shrink without overflow */
  float: none !important;
  width: auto !important;
}

/* Optional: keep the filters visible while scrolling on desktop */
@media (min-width: 992px) {
  #main-content > main > div.main-container > div.container > div.row > .page-sidebar.mobile-filter-sidebar > aside {
    position: sticky;
    top: 16px; /* below navbar/hero */
  }
}

/* Stack columns on small screens (fallback to legacy) */
@media (max-width: 991.98px) {
  #main-content > main > div.main-container > div.container > div.row {
    display: block; /* revert to block layout on small screens */
  }
}

/* =============================================================== */
/* UNIFIED PAGINATION (matches blog style)                         */
/* =============================================================== */
.pagination {
  display: flex;
  list-style: none;
  padding-left: 0;
  justify-content: center;
  margin: 2rem 0;
}

.page-item {
  margin: 0 0.25rem;
}

.page-link {
  padding: 0.5rem 0.75rem;
  color: var(--color-secondary);
  text-decoration: none;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.page-link:hover {
  background-color: #e9ecef;
  border-color: #adb5bd;
}

.page-item.active .page-link {
  background-color: var(--color-secondary);
  color: #ffffff;
  border-color: var(--color-secondary);
}

/* =============================================================== */
/* Save Search Bar: make button occupy full area (no gray bg)      */
/* =============================================================== */
.tab-box.save-search-bar {
  background: transparent !important;
  padding: 0 !important;
}

.tab-box.save-search-bar:hover {
  background: transparent !important;
}

.tab-box.save-search-bar .btn {
  display: block;
  width: 100%;
  margin: 0;
  border-radius: 0;
  padding: 14px 16px;
}

/* Force high-contrast text on the save-search CTA button */
.tab-box.save-search-bar .btn.btn-primary,
.save-search-bar .btn.btn-primary {
  color: var(--color-text) !important;
  text-shadow: none !important;
}

@media (max-width: 576px) {
  .tab-box.save-search-bar .btn {
    padding: 16px;
  }
}

/* =============================================================== */
/* ACCESSIBILITY IMPROVEMENTS
/* =============================================================== */

/* Ensure focus is visible for keyboard navigation */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: var(--focus-outline);
  outline-offset: var(--focus-offset);
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --color-border: #000000;
    --color-text: #000000;
    --focus-outline: 3px solid #000000;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* =============================================================== */
/* FLAG ICONS - Preparation for SVG assets
/* =============================================================== */

.flag {
  width: clamp(32px, 5vw, 56px);
  height: auto;
  margin: var(--spacing-xs);
}

/* .flag-br {  // Placeholder for Brazilian flag SVG; kept for future wiring */
/* } */

/* Mobile flag sizing */
@media (max-width: 768px) {
  .flag {
    width: clamp(24px, 4vw, 36px);
  }
}
