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

:root {
  --bg-gradient: linear-gradient(135deg, #0f3c4c 0%, #1a804a 100%);
  --surface: rgba(255, 255, 255, 0.88);
  --surface-strong: rgba(255, 255, 255, 0.96);
  --primary: #1a804a;
  --primary-dark: #0f6340;
  --accent: #f1b722;
  --text-main: #1f2a2d;
  --text-muted: #4a5a5f;
  --border-soft: rgba(26, 128, 74, 0.2);
  --shadow-soft: 0 18px 40px -20px rgba(15, 60, 76, 0.65);
  --shadow-hover: 0 20px 45px -18px rgba(26, 128, 74, 0.55);
  --radius-lg: 18px;
  --radius-sm: 12px;
  --transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  --nav-gap: 0.75rem;
  --nav-link-padding: 0.7rem 1rem;
  --nav-link-font-size: 1rem;
  --nav-link-min-width: 160px;
  --nav-link-flex-basis: 140px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Poppins', 'Segoe UI', sans-serif;
  background: var(--bg-gradient);
  color: var(--text-main);
  max-width: 1100px;
  margin: 0 auto;
  padding: 2.5rem clamp(1.25rem, 4vw, 3rem) 3.5rem;
  line-height: 1.7;
  position: relative;
  min-height: 100vh;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 12% 18%, rgba(255, 255, 255, 0.15) 0%, transparent 38%),
              radial-gradient(circle at 88% 12%, rgba(255, 255, 255, 0.12) 0%, transparent 42%),
              radial-gradient(circle at 30% 80%, rgba(26, 128, 74, 0.22) 0%, transparent 48%);
  pointer-events: none;
  z-index: -2;
}

.page-shell {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--border-soft);
  backdrop-filter: blur(12px);
  padding: clamp(1.75rem, 4vw, 2.75rem);
}

/* === HEADINGS & TEXT === */
h1, h2 {
  font-family: 'Montserrat', sans-serif;
  color: var(--text-main);
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-top: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 2.8rem);
  margin-bottom: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  background: linear-gradient(120deg, #ffffff 10%, #e2f3ec 45%, rgba(255, 255, 255, 0.4) 90%);
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-sm);
  box-shadow: 0 12px 28px -18px rgba(15, 60, 76, 0.4);
}

h2 {
  font-size: clamp(1.45rem, 3vw, 2.1rem);
  margin-bottom: 1.25rem;
}

p {
  margin-bottom: 1.1rem;
}

.intro {
  font-size: 1.1rem;
  line-height: 1.85;
  color: var(--text-muted);
  margin-bottom: 1.8rem;
  max-width: 70ch;
}

a {
  color: var(--primary);
  text-decoration: none;
  position: relative;
  font-weight: 500;
}

a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -0.15rem;
  width: 100%;
  height: 2px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s ease;
}

a:hover::after,
a:focus::after {
  transform: scaleX(1);
}

a:hover,
a:focus {
  color: var(--primary-dark);
}

/* === NAVIGATION === */
nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--nav-gap);
  margin-bottom: 1.5rem;
}

nav .nav-link {
  flex: 1 1 var(--nav-link-flex-basis);
  background: var(--surface-strong);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: var(--nav-link-padding);
  font-weight: 600;
  font-size: var(--nav-link-font-size);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: var(--transition);
  text-align: center;
  gap: 0.45rem;
  border: 1px solid transparent;
  position: relative;
  overflow: hidden;
  min-width: var(--nav-link-min-width);
}

nav .nav-link::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(26, 128, 74, 0.08), rgba(241, 183, 34, 0.08));
  opacity: 0;
  transition: opacity 0.35s ease;
}

nav .nav-link:hover,
nav .nav-link:focus,
nav .nav-link:active {
  transform: translateY(-4px);
  color: var(--primary-dark);
  border-color: rgba(26, 128, 74, 0.2);
  box-shadow: var(--shadow-hover);
}

nav .nav-link:hover::before,
nav .nav-link:focus::before,
nav .nav-link:active::before {
  opacity: 1;
}

/* === BACK BUTTON === */
.back-btn {
  display: inline-block;
  margin-bottom: 2rem;
  padding: 0.5rem 1rem;
  border: 2px dashed #5b3e1d;
  color: #2a1d0e;
  background: #ede0c3;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.3s ease;
}
.back-btn:hover,
.back-btn:focus {
  background-color: #e2d3af;
  color: #000;
}

/* === SECTIONS === */
section {
  display: none;
  background: var(--surface);
  padding: clamp(1.8rem, 4vw, 2.8rem);
  border-radius: var(--radius-lg);
  margin-top: 1.8rem;
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: var(--shadow-soft);
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.45s ease, transform 0.45s ease;
  animation: fade-in 0.8s ease forwards;
}

section.active {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

/* === TABLES === */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1.25rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-strong);
  border: 1px solid rgba(31, 42, 45, 0.08);
  box-shadow: var(--shadow-soft);
  animation: slide-up 0.6s ease both;
}

th,
td {
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid rgba(31, 42, 45, 0.07);
  background: transparent;
  color: var(--text-main);
  font-weight: 500;
  word-break: break-word;
}

table th:nth-child(2),
table td:nth-child(2) {
  width: 8rem;
}

table th:nth-child(4),
table td:nth-child(4) {
  width: 16ch;
}

table th:nth-child(5),
table td:nth-child(5) {
  width: 34ch;
}

.table-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}

.table-controls input[type="text"] {
  flex: 2 1 280px;
  margin-bottom: 0;
}

.sort-label {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 600;
  color: var(--text-muted);
}

.sort-label select {
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(31, 42, 45, 0.12);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text-main);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.sort-label select:hover,
.sort-label select:focus {
  border-color: rgba(26, 128, 74, 0.4);
  box-shadow: 0 0 0 3px rgba(26, 128, 74, 0.1);
}

th {
  background: rgba(26, 128, 74, 0.08);
  color: var(--primary-dark);
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
}

tbody tr {
  transition: var(--transition);
}

tbody tr:hover {
  background: rgba(26, 128, 74, 0.08);
}

/* === FORMS === */
label {
  display: block;
  margin-top: 1rem;
  font-weight: bold;
}
input,
select,
textarea {
  width: 100%;
  margin-bottom: 1.1rem;
  padding: 0.75rem 0.9rem;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(31, 42, 45, 0.12);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text-main);
  transition: var(--transition);
  box-shadow: 0 6px 16px -14px rgba(31, 42, 45, 0.6);
}

input::placeholder,
textarea::placeholder {
  color: rgba(31, 42, 45, 0.5);
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(26, 128, 74, 0.45);
  box-shadow: 0 0 0 4px rgba(26, 128, 74, 0.15);
  outline: none;
}

/* === BUTTONS (Génériques) === */
:is(button, .submit-btn, #sendBtn) {
  width: 100%;
  max-width: 260px;
  padding: 0.85rem 1.8rem;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  border: none;
  border-radius: 999px;
  box-shadow: 0 14px 24px -18px rgba(26, 128, 74, 0.85);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

:is(button, .submit-btn, #sendBtn)::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.25), transparent 55%);
  opacity: 0;
  transition: opacity 0.35s ease;
}

:is(button, .submit-btn, #sendBtn):hover {
  transform: translateY(-3px) scale(1.01);
  box-shadow: 0 18px 28px -16px rgba(26, 128, 74, 0.9);
}

:is(button, .submit-btn, #sendBtn):hover::after {
  opacity: 1;
}

#sendBtn:disabled {
  background: rgba(31, 42, 45, 0.12);
  color: rgba(31, 42, 45, 0.45);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* === FEEDBACK / MESSAGES === */
#program-output,
#response,
#confirmation {
  background: rgba(255, 255, 255, 0.85);
  padding: 1.1rem;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  box-shadow: inset 0 0 0 1px rgba(26, 128, 74, 0.08);
  font-family: 'Poppins', monospace;
  overflow-x: auto;
}

/* === MESSAGES D'ÉTAT === */
#submit-result {
  font-style: italic;
  color: var(--text-muted);
  margin: 0.6rem 0;
  font-size: 1rem;
}

#feedback {
  margin-top: 1em;
  font-weight: 600;
  color: var(--primary-dark);
}

/* === FOOTER === */
.site-footer {
  margin-top: 2.5rem;
  padding-top: 1.2rem;
  border-top: 1px solid rgba(31, 42, 45, 0.12);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.site-footer a {
  color: var(--primary);
  font-weight: 500;
}

.site-footer a:hover,
.site-footer a:focus {
  color: var(--primary-dark);
}

/* === LOADING INDICATOR === */
#loading {
  margin-top: 1rem;
  color: var(--primary);
  font-style: italic;
  display: none;
}

.loading::after {
  content: "⏳";
  animation: pulse 1.1s infinite;
}

@keyframes pulse {
  0%,
  100% { opacity: 0.25; }
  50% { opacity: 1; }
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(28px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(22px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* === RESPONSIVE DESIGN === */
@media (max-width: 768px) {
  :root {
    --nav-gap: 0.6rem;
    --nav-link-padding: 0.55rem 0.75rem;
    --nav-link-font-size: 0.95rem;
    --nav-link-min-width: 140px;
    --nav-link-flex-basis: calc(50% - var(--nav-gap));
  }

  body {
    padding: 1.5rem;
    max-width: 100%;
  }

  .page-shell {
    padding: 1.5rem;
  }

  :is(button, .submit-btn, #sendBtn) {
    max-width: none;
    width: 100%;
  }

  th,
  td {
    font-size: 0.92rem;
    padding: 0.7rem;
  }

  .table-controls {
    gap: 0.8rem;
  }

  .sort-label {
    width: 100%;
    justify-content: space-between;
  }

  .sort-label select {
    width: 100%;
  }

  h1,
  h2 {
    text-align: center;
  }
}

@media (max-width: 400px) {
  :root {
    --nav-gap: 0.45rem;
    --nav-link-padding: 0.5rem 0.65rem;
    --nav-link-font-size: 0.9rem;
    --nav-link-min-width: 120px;
    --nav-link-flex-basis: calc(50% - var(--nav-gap));
  }

  input,
  select,
  textarea {
    font-size: 0.88rem;
  }

  h1,
  h2 {
    font-size: 1.35rem;
  }

  .table-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .sort-label {
    flex-direction: column;
    align-items: stretch;
  }

  .sort-label select {
    width: 100%;
  }
}
