:root {
  --primary-color: #006c6d;
  --primary-hover: #008a8b;
  --secondary-color: #009591;
  --tertiary-color: #007b9a;
  --bg-color: #f8f9fa;
  --text-color: #333;
  --header-bg: #ffffff;
  --footer-bg: #006c6d;
  --footer-text: #ffffff;
  --container-width: 2200px;
  --spacing: 1.5rem;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
  overflow-x: hidden; /* Prevent minor accidental overflows from showing scrollbars */
}

img {
  max-width: 100%;
  height: auto;
}

* {
  box-sizing: border-box;
}

.container {
  max-width: var(--container-width);
  margin: 0 auto;
  padding: 0 var(--spacing);
  width: 80%;
  box-sizing: border-box;
}

/* Responsive adjustments for smaller screens */
@media (max-width: 1920px) {
  :root {
    --spacing: 1rem;
  }
}

@media (max-width: 1680px) {
  :root {
    --container-width: 1600px;
    --spacing: 1.5rem;
  }
}

@media (max-width: 1440px) {
  :root {
    --container-width: 1360px;
  }
}

@media (max-width: 1200px) {
  :root {
    --container-width: 960px;
    --spacing: 1.25rem;
  }
}

@media (max-width: 992px) {
  :root {
    --container-width: 720px;
  }
}

@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
}

@media (max-width: 768px) {
  :root {
    --container-width: 100%;
    --spacing: 0.5rem;
  }

  .container {
    width: 95%;
  }
  
  .main-navigation .menu {
    flex-direction: column;
  }
  
  .main-navigation .menu-item {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid rgba(255,255,255,0.1);
  }
  
  .main-navigation .menu::before,
  .main-navigation .menu::after {
    display: none; /* Hide ribbon folds on mobile */
  }

  .node--type-offre-d-emploi {
    padding: 1rem;
  }

  .views-row {
    padding: 1rem;
  }
}

a {
  color: var(--primary-color);
  text-decoration: none;
  transition: color 0.3s;
}

a:hover,
a:focus {
  color: var(--secondary-color);
  text-decoration: underline;
}

/* Header & Navigation */
.site-header {
  background-color: var(--header-bg);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.header-flex-row {
  display: flex !important;
  flex-direction: row !important;
  justify-content: space-between !important;
  align-items: center !important;
  flex-wrap: nowrap !important;
  width: 100% !important;
  gap: 2rem !important;
}

@media (max-width: 768px) {
  .header-flex-row {
    flex-wrap: wrap !important;
    gap: 1rem !important;
  }
}

.header-flex-row .block {
  flex: 0 1 auto;
}

.block-alp-entete,
[id*="block-alp-entete"] {
  margin-left: auto;
  text-align: right;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

@media (max-width: 768px) {
  .block-alp-entete,
  [id*="block-alp-entete"] {
    margin-left: 0;
    text-align: left;
    justify-content: flex-start;
  }
}

/* Site Branding */
.site-branding__inner {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.site-branding__logo img {
  display: block;
  max-height: 80px;
  width: auto;
}

.site-branding__text {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.site-branding__name {
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.2;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.site-branding__name a {
  text-decoration: none;
  color: var(--primary-color);
}

.site-branding__slogan {
  font-size: 1rem;
  color: var(--text-color);
  font-weight: 400;
  margin-top: 0.2rem;
  overflow-wrap: break-word;
}

@media (max-width: 768px) {
  .site-branding__name {
    font-size: 1.4rem; /* Scale down a bit on mobile */
  }
}

@media (max-width: 768px) {
  .site-branding__slogan {
    display: none;
  }
}

.main-navigation {
  margin-top: 1.5rem;
  position: relative;
}

/* Ribbon Style for Drupal Menus */
.main-navigation .menu,
.main-navigation ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  background-color: var(--secondary-color);
  width: 100%;
  position: relative;
}

/* Ribbon ends (the folded corners) */
.main-navigation .menu::before,
.main-navigation .menu::after {
  content: "";
  position: absolute;
  top: 100%;
  border-style: solid;
  border-width: 0 10px 10px 0;
  z-index: -1;
}

.main-navigation .menu::before {
  left: 0;
  border-color: transparent #004d4e transparent transparent;
}

.main-navigation .menu::after {
  right: 0;
  border-width: 0 0 10px 10px;
  border-color: transparent transparent transparent #004d4e;
}

.main-navigation .menu-item,
.main-navigation li {
  position: relative;
  list-style: none;
  flex: 1;
  text-align: center;
}

.main-navigation a {
  text-decoration: none;
  color: white;
  font-weight: 400;
  transition: all 0.2s;
  display: block;
  padding: 0.8rem 0.5rem;
  border-right: 1px solid rgba(255,255,255,0.1);
}

.main-navigation .menu-item:last-child a {
  border-right: none;
}

.main-navigation a:hover,
.main-navigation a:focus,
.main-navigation .menu-item--active-trail > a,
.main-navigation .menu-item:hover > a {
  background-color: var(--primary-color);
  color: white;
}

/* Nested Menus (Ribbon Style) */
.main-navigation .menu-sub,
.main-navigation ul li ul {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--primary-color);
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  flex-direction: column;
  min-width: 100%;
  gap: 0;
  padding: 0;
  z-index: 100;
}

/* Third level and deeper: open to the right */
.main-navigation .nav-level-2,
.main-navigation .menu-sub .menu-sub,
.main-navigation ul li ul li ul {
  top: 0;
  left: 100%;
}

/* The magic hover rule */
.main-navigation li:hover > ul,
.main-navigation .menu-item:hover > .menu-sub,
.main-navigation .menu-item:focus-within > .menu-sub,
.main-navigation .menu-item.is-open > .menu-sub {
  display: flex !important;
}

.main-navigation .menu-sub a {
  padding: 0.8rem 1rem;
  font-weight: 400;
  text-align: left;
  border-right: none;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.main-navigation .menu-sub a:hover {
  background-color: var(--tertiary-color);
}


/* Layout */
.breadcrumb-wrapper {
  background-color: #f1f3f5;
  padding: 0.75rem 0;
  font-size: 0.9rem;
  color: var(--secondary-color);
}

.breadcrumb-wrapper ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.breadcrumb-wrapper li:not(:last-child)::after {
  content: "/";
  margin-left: 0.5rem;
  color: #adb5bd;
}

.breadcrumb-wrapper a {
  text-decoration: none;
  color: var(--primary-color);
}

.breadcrumb-wrapper a:hover {
  text-decoration: underline;
}

.main-content {
  padding: 2rem 0;
}

.content-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  width: 100%;
}

.paragraph--type--teaser {
  padding-right: 1em;
}

/* Layout Discovery / Layout Builder styles */
.layout--threecol-section {
  padding: 2rem 0;
}

@media (min-width: 992px) {
  /* Three columns layout when both sidebars exist */
  .content-layout {
    grid-template-columns: 250px 1fr 250px;
  }
  
  /* If one sidebar is missing, Drupal usually doesn't output the div, 
     but we should ensure the content expands */
  .content-layout:not(:has(.sidebar-first)):not(:has(.sidebar-second)) {
    grid-template-columns: 1fr;
  }
  
  .content-layout:has(.sidebar-first):not(:has(.sidebar-second)) {
    grid-template-columns: 250px 1fr;
  }
  
  .content-layout:not(:has(.sidebar-first)):has(.sidebar-second) {
    grid-template-columns: 1fr 250px;
  }
}

/* Footer Rewrite - Optimized for Drupal region wrappers */
.site-footer {
  background-color: var(--footer-bg);
  color: var(--footer-text);
  padding: 2rem 0;
}

.footer-flex-container {
  display: flex !important;
  flex-direction: row !important;
  justify-content: space-between !important;
  align-items: flex-start !important;
  flex-wrap: wrap !important;
  width: 100% !important;
  gap: 3rem !important;
}

/* The Magic Bullet: display: contents makes the intermediate wrapper "disappear" 
   for layout purposes, making the blocks direct flex items of .footer-flex-container */
.footer-flex-container > div:not(.block) {
  display: contents;
}

/* Ensure blocks share the space */
.footer-flex-container .block {
  flex: 1 1 auto;
  min-width: 280px;
}

/* Main footer info takes more space */
.footer-flex-container .block-alp-footer,
.footer-flex-container [id*="block-alp-footer"] {
  flex: 3;
  max-width: 800px;
}

/* Menu block pushes to the right */
.footer-flex-container .block-alp-pieddepage,
.footer-flex-container [id*="block-alp-pieddepage"] {
  flex: 1;
  text-align: left;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.footer-flex-container .menu {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.footer-flex-container .menu a {
  color: white;
  text-decoration: none;
  opacity: 0.85;
  transition: opacity 0.2s;
  font-size: 0.95rem;
}

.footer-flex-container .menu a:hover {
  opacity: 1;
  text-decoration: underline;
}

@media (max-width: 850px) {
  .footer-flex-container,
  .footer-flex-container > div[class*="region"] {
    flex-direction: column !important;
    gap: 2.5rem !important;
  }
  
  .footer-flex-container .block-alp-pieddepage {
    text-align: left;
    align-items: flex-start;
  }
}

/* Modern buttons/elements */
.button, button {
  background-color: var(--primary-color);
  color: white;
  padding: 0.6rem 1.8rem;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  transition: background-color 0.3s;
  font-weight: 600;
}

.button:hover, button:hover {
  background-color: var(--primary-hover);
}

.button--small {
  padding: 0.4rem 1rem;
  font-size: 0.9rem;
}

.sidebar-first h2, .sidebar-second h2 {
  color: var(--secondary-color);
  border-bottom: 2px solid var(--secondary-color);
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}

/* Views & Exposed Filters */
.views-exposed-form .form--inline,
.views-exposed-form form,
.view-filters form {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  background: #f8f9fa;
  padding: 1.5rem;
  border-radius: 8px;
  margin-bottom: 2rem;
  border: 1px solid #dee2e6;
}

.views-exposed-form .js-form-item,
.view-filters .js-form-item {
  margin-bottom: 0;
  display: flex;
  flex-direction: row; /* Try row if they were stacked */
  align-items: center;
  gap: 0.75rem;
}

/* Force inline-block for form items if flex is resisted */
.views-exposed-form .form-item {
  display: inline-block;
  margin-right: 1.5rem;
  vertical-align: bottom;
}

.views-exposed-form label,
.view-filters label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-color);
  margin-bottom: 0;
  min-width: 60px;
}

.views-exposed-form select, 
.views-exposed-form input[type="text"],
.view-filters select, 
.view-filters input[type="text"] {
  padding: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  min-width: 150px;
}

/* Views Content / Table Results */
.view-content table,
.views-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.views-table th {
  background-color: var(--secondary-color);
  color: #ffffff;
  text-align: left;
  padding: 1.2rem 1rem;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  border-bottom: 2px solid rgba(0,0,0,0.1);
  border-right: 1px solid rgba(255,255,255,0.1);
}

.views-table th:last-child {
  border-right: none;
}

.views-table th a {
  color: #ffffff;
  text-decoration: none;
}

.views-table th a:hover {
  text-decoration: underline;
}

.views-table td {
  padding: 1rem;
  border-bottom: 1px solid #eee;
  border-right: 1px solid #eee;
  vertical-align: middle;
  background-color: #ffffff;
}

.views-table td:last-child {
  border-right: none;
}

.views-table tr:nth-child(even) td {
  background-color: #f4f9f9; /* Subtle alternate row color based on secondary color */
}

.views-table tr:last-child td {
  border-bottom: none;
}

.views-table tr.clickable-row {
  cursor: pointer;
}

.views-table tr:hover td {
  background-color: rgba(0, 108, 109, 0.05) !important;
}

.responsive-table-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1rem;
}

@media (max-width: 768px) {
  .views-table {
    font-size: 0.7rem;
    width: 100% !important;
    min-width: 320px; /* Minimum smartphone width */
    table-layout: auto;
  }

  .views-table th {
    padding: 0.6rem 0.3rem;
    font-size: 0.65rem;
    white-space: normal; /* Allow headers to wrap */
  }

  .views-table td {
    padding: 0.5rem 0.3rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
  }

  .views-table tr.clickable-row {
    cursor: default;
  }
}

.views-field-title a {
  font-weight: 600;
  color: var(--primary-color);
  text-decoration: none;
}

.views-field-title a:hover {
  text-decoration: underline;
}

.views-row {
  background: white;
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 1.5rem;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.views-row:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.views-field-title h3,
.views-row h3 {
  margin-top: 0;
  color: var(--primary-color);
  font-size: 1.25rem;
}

.views-field-body,
.views-row .content {
  color: #555;
  margin-bottom: 1rem;
}

/* Generic metadata in listings */
.views-field-created,
.views-field-field-type,
.views-field-field-location {
  font-size: 0.85rem;
  color: #777;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Pagination */
.pager {
  margin-top: 3rem;
  display: flex;
  justify-content: center;
}

.pager__items {
  list-style: none;
  display: flex;
  gap: 0.5rem;
  padding: 0;
}

.pager__item a {
  display: block;
  padding: 0.5rem 1rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  text-decoration: none;
  color: var(--primary-color);
}

.pager__item--active a,
.pager__item a:hover {
  background-color: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

/* Fields Styling */
.field {
  margin-bottom: 1rem;
}

/* Job Offer Detail View (offre_d_emploi) */
.node--type-offre-d-emploi {
  background: white;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.job-offer-header {
  margin-bottom: 2rem;
  border-bottom: 1px solid #eee;
  padding-bottom: 1rem;
}

.job-offer-badges {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 50px;
  font-weight: 600;
  font-size: 0.9rem;
  max-width: 100%; /* Prevent badges from overflowing container */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge--contract {
  background-color: rgba(0, 108, 109, 0.1);
  color: var(--primary-color);
}

.badge--time {
  background-color: rgba(0, 149, 145, 0.1);
  color: var(--secondary-color);
}

.badge .icon {
  stroke-width: 2.5px;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.job-offer-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 3rem;
  overflow-x: hidden; /* Contain any child overflow */
}

@media (min-width: 992px) {
  .job-offer-layout {
    grid-template-columns: 1fr 320px;
  }
}

.job-section {
  margin-bottom: 2rem;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.job-section-title {
  font-size: 1.3rem;
  color: var(--primary-color);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 2px solid #f1f3f5;
  padding-bottom: 0.4rem;
  flex-wrap: wrap; /* Allow title to wrap if very long */
}

.job-section--highlight {
  background: #f8f9fa;
  padding: 1.2rem 1.5rem;
  border-radius: 8px;
  border-left: 4px solid var(--primary-color);
  overflow-wrap: break-word;
}

.job-body, .job-contacts {
  font-size: 1.05rem;
  line-height: 1.6;
  color: #444;
  overflow-wrap: break-word;
}

.job-body p, .job-contacts p, .job-contacts div {
  margin-top: 0;
  margin-bottom: 0.75rem;
}

.job-body p:last-child, .job-contacts p:last-child, .job-contacts div:last-child {
  margin-bottom: 0;
}

.job-contacts {
  white-space: normal; /* Collapses all extra newlines and spaces */
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.job-url-wrapper {
  margin-top: 0.75rem;
  overflow-wrap: break-word;
}

.job-info-card {
  background: #fff;
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 1.5rem;
  position: static; /* Default to static for mobile */
}

@media (min-width: 992px) {
  .job-info-card {
    position: sticky;
    top: 120px;
  }
}

.job-info-card-title {
  margin-top: 0;
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #666;
  margin-bottom: 1.5rem;
}

.job-info-item {
  margin-bottom: 1.5rem;
}

.job-info-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: #888;
  margin-bottom: 0.25rem;
}

.job-info-label .icon {
  width: 16px;
  height: 16px;
  color: var(--secondary-color);
}

.job-info-value {
  font-weight: 600;
  color: var(--text-color);
}

.job-info-subvalue {
  font-weight: 400;
  font-size: 0.9rem;
  color: #666;
}

.job-info-item--expiration {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px dashed #ddd;
}

.job-tags .field__items {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.job-tags .field__item {
  background: #eee;
  padding: 0.3rem 0.8rem;
  border-radius: 4px;
  font-size: 0.9rem;
}

.field--label-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: baseline;
}

.field--label-inline .field__label {
  font-weight: 700;
}

.field--label-above .field__label {
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.field__label-suffix {
  margin-right: 0.2rem;
}
