/* ============================================
   Base Template Stylesheet
   Shared layout for FVARESS / MERCS sites
   ============================================ */

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

a:hover {
  color: var(--color-primary-light);
}

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

/* --- Navigation --- */
.nav {
  background: var(--color-bg-header);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  color: var(--color-text-on-primary);
  font-size: 1.1rem;
  font-weight: 600;
  padding: 1rem 0;
  white-space: nowrap;
}

.nav-brand a {
  color: var(--color-text-on-primary);
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 0.25rem;
}

.nav-links a {
  color: var(--color-text-on-primary);
  padding: 1rem 0.75rem;
  display: block;
  font-size: 0.9rem;
  opacity: 0.85;
  transition: opacity 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--color-text-on-primary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
}

/* --- Dropdown Menu --- */
.nav-dropdown {
  position: relative;
}

.nav-dropdown > a {
  cursor: pointer;
}

.nav-dropdown > a::after {
  content: " \25BE";
  font-size: 0.7em;
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--color-bg-header);
  min-width: 180px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  list-style: none;
  z-index: 101;
  border-radius: 0 0 6px 6px;
}

.dropdown-menu a {
  padding: 0.6rem 1rem;
  display: block;
  white-space: nowrap;
  color: var(--color-text-on-primary);
  font-size: 0.85rem;
  opacity: 0.85;
  transition: opacity 0.2s, background 0.2s;
}

.dropdown-menu a:hover,
.dropdown-menu a.active {
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
}

.nav-dropdown:hover .dropdown-menu {
  display: block;
}

/* --- Hero / Header Image --- */
.hero {
  width: 100%;
  max-height: 350px;
  overflow: hidden;
  position: relative;
}

.hero img {
  width: 100%;
  height: 350px;
  object-fit: cover;
  display: block;
}

.hero-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 2rem 1.5rem;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.6));
  color: white;
}

.hero-overlay h1 {
  font-size: 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

.hero-overlay p {
  max-width: 1200px;
  margin: 0.25rem auto 0;
  opacity: 0.9;
}

/* --- Main Content --- */
.main {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  width: 100%;
}

/* --- Page Header --- */
.page-header {
  margin-bottom: 2rem;
}

.page-header h1 {
  font-size: 1.8rem;
  color: var(--color-primary-dark);
  border-bottom: 3px solid var(--color-accent);
  padding-bottom: 0.5rem;
  display: inline-block;
}

/* --- Cards --- */
.card {
  background: var(--color-bg-card);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  border: 1px solid var(--color-border-light);
}

.card h2 {
  font-size: 1.3rem;
  color: var(--color-primary-dark);
  margin-bottom: 0.75rem;
}

.card h3 {
  font-size: 1.1rem;
  color: var(--color-text);
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
}

.card h3:first-child {
  margin-top: 0;
}

.card p {
  margin-bottom: 0.75rem;
  color: var(--color-text-light);
}

.card p:last-child {
  margin-bottom: 0;
}

.card ol, .card ul:not(.info-list) {
  padding-left: 1.5rem;
  margin-bottom: 0.75rem;
  color: var(--color-text-light);
}

.card ol:last-child, .card ul:not(.info-list):last-child {
  margin-bottom: 0;
}

.card ol li, .card ul:not(.info-list) li {
  padding: 0.35rem 0;
  line-height: 1.5;
}

/* --- Grid Layout --- */
.grid {
  display: grid;
  gap: 1.5rem;
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

/* --- Tables --- */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
}

th, td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

th {
  background: var(--color-primary);
  color: var(--color-text-on-primary);
  font-weight: 600;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

tbody tr:nth-child(even) td {
  background: rgba(0, 0, 0, 0.04);
}

tbody tr:nth-child(odd) td {
  background: var(--color-bg-card);
}

tr:hover td {
  background: rgba(0, 0, 0, 0.07);
}

/* --- Info List --- */
.info-list {
  list-style: none;
}

.info-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--color-border-light);
  display: flex;
  gap: 0.5rem;
}

.info-list li:last-child {
  border-bottom: none;
}

.info-label {
  font-weight: 600;
  min-width: 140px;
  color: var(--color-text);
}

.info-value {
  color: var(--color-text-light);
}

.info-label small {
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--color-text-light);
}

/* --- Badges --- */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
}

.badge-ok { background: #e8f5e9; color: var(--color-ok); }
.badge-warn { background: #fff3e0; color: var(--color-warn); }
.badge-error { background: #ffebee; color: var(--color-error); }
.badge-info { background: #e3f2fd; color: #1976d2; }

/* --- Footer --- */
.footer {
  background: var(--color-bg-footer);
  color: var(--color-text-on-footer);
  padding: 2rem 1.5rem;
  margin-top: auto;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.footer a {
  color: var(--color-accent-light);
}

.footer-org {
  font-size: 0.85rem;
}

.footer-contact {
  font-size: 0.85rem;
  text-align: right;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .nav-toggle {
    display: block;
  }

  .nav-links {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--color-bg-header);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  }

  .nav-links.open {
    display: flex;
  }

  .nav-links a {
    padding: 0.75rem 1.5rem;
  }

  .nav-dropdown:hover .dropdown-menu {
    display: none;
  }

  .nav-dropdown.open .dropdown-menu {
    display: flex;
    flex-direction: column;
    position: static;
    box-shadow: none;
    border-radius: 0;
  }

  .dropdown-menu a {
    padding: 0.6rem 1.5rem 0.6rem 2.5rem;
  }

  .hero img {
    height: 200px;
  }

  .hero-overlay h1 {
    font-size: 1.4rem;
  }

  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }

  .footer-inner {
    flex-direction: column;
    text-align: center;
  }

  .footer-contact {
    text-align: center;
  }

  .info-list li {
    flex-direction: column;
    gap: 0.15rem;
  }

  .info-label {
    min-width: auto;
  }

  /* Stack tables into cards on mobile */
  table, thead, tbody, th, td, tr {
    display: block;
  }

  thead {
    display: none;
  }

  tr {
    margin-bottom: 1rem;
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-accent);
    border-radius: 6px;
    padding: 0.5rem;
    background: var(--color-bg-card);
  }

  tbody tr:nth-child(odd) td,
  tbody tr:nth-child(even) td {
    background: transparent;
  }

  td {
    padding: 0.35rem 0.75rem;
    border-bottom: none;
    text-align: left;
  }

  td::before {
    content: attr(data-label);
    font-weight: 600;
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--color-text-light);
    margin-bottom: 0.1rem;
  }
}
