/* =============================================
   MLC - Outil de chiffrage  |  styles.css
   ============================================= */

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

:root {
  --brand:        #C8420A;
  --brand-light:  #F5C4B3;
  --brand-dark:   #99310A;
  --bg:           #F7F6F2;
  --surface:      #FFFFFF;
  --border:       rgba(0,0,0,0.12);
  --border-md:    rgba(0,0,0,0.22);
  --text:         #1A1A1A;
  --text-muted:   #6B6B6B;
  --text-hint:    #9A9A9A;
  --radius-sm:    6px;
  --radius-md:    10px;
  --radius-lg:    14px;
  --shadow-sm:    0 1px 4px rgba(0,0,0,0.07);
  --shadow-md:    0 4px 16px rgba(0,0,0,0.10);
  --success-bg:   #EAF3DE;
  --success-text: #27500A;
  --info-bg:      #E6F1FB;
  --info-text:    #0C447C;
  --warn-bg:      #FAEEDA;
  --warn-text:    #633806;
  --purple-bg:    #EEEDFE;
  --purple-text:  #3C3489;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ---- HEADER ---- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.site-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}
.logo-badge {
  width: 36px; height: 36px;
  background: var(--brand);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #fff; letter-spacing: -0.5px;
}
.site-logo span { font-weight: 600; font-size: 15px; }
nav { display: flex; gap: 4px; }
.nav-link {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.nav-link:hover { background: var(--bg); color: var(--text); }
.nav-link.active { background: var(--brand-light); color: var(--brand-dark); }

/* ---- PAGE LAYOUT ---- */
.page { max-width: 860px; margin: 0 auto; padding: 2rem 1.25rem 4rem; }

.page-title {
  font-size: 22px; font-weight: 600;
  margin-bottom: 4px;
}
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-bottom: 1.75rem; }

/* ---- CARDS ---- */
.card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}
.card-title {
  font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 0.5px solid var(--border);
  padding-bottom: 10px; margin-bottom: 1rem;
  display: flex; align-items: center; gap: 6px;
}
.card-title .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--brand);
  display: inline-block;
}

/* ---- FORM ---- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.full { grid-column: 1 / -1; }
.field label {
  font-size: 11.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted);
}
.field label .req { color: var(--brand); margin-left: 2px; }
input[type=text], input[type=number], input[type=email],
select, textarea {
  width: 100%;
  background: var(--surface);
  border: 0.5px solid var(--border-md);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  font-size: 14px;
  color: var(--text);
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(200,66,10,0.12);
}
textarea { resize: vertical; min-height: 68px; }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B6B6B' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

/* checkboxes */
.check-group { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.check-item {
  display: flex; align-items: center; gap: 7px;
  font-size: 13px; color: var(--text);
  cursor: pointer; user-select: none;
}
.check-item input[type=checkbox] {
  width: 16px; height: 16px; border-radius: 4px;
  accent-color: var(--brand); cursor: pointer;
}

/* radio-like buttons */
.radio-group { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.radio-btn {
  padding: 5px 14px;
  border: 0.5px solid var(--border-md);
  border-radius: 99px;
  font-size: 13px; cursor: pointer;
  transition: all 0.15s;
  background: var(--surface);
  color: var(--text);
}
.radio-btn.selected {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 7px; padding: 10px 22px;
  border-radius: var(--radius-md);
  font-size: 14px; font-weight: 600;
  cursor: pointer; border: none;
  transition: all 0.15s; text-decoration: none;
}
.btn-primary {
  background: var(--brand); color: #fff;
  box-shadow: 0 2px 8px rgba(200,66,10,0.25);
}
.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-outline {
  background: transparent;
  border: 0.5px solid var(--border-md);
  color: var(--text);
}
.btn-outline:hover { background: var(--bg); }
.btn-success {
  background: #27500A; color: #fff;
}
.btn-success:hover { background: #1a3607; }
.btn-bar {
  display: flex; gap: 10px; margin-top: 1.25rem;
  flex-wrap: wrap;
}

/* ---- LOADING ---- */
.loading-wrap {
  display: flex; align-items: center; gap: 12px;
  padding: 1.25rem; color: var(--text-muted); font-size: 14px;
}
.dots { display: flex; gap: 5px; }
.dots span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--brand);
  animation: pulse 1.2s infinite ease-in-out;
}
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse { 0%,80%,100%{transform:scale(0.7);opacity:0.4} 40%{transform:scale(1);opacity:1} }

/* ---- RESULT ---- */
.result-wrap { margin-top: 1.75rem; }
.result-header {
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 12px;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.result-title { font-size: 17px; font-weight: 600; }
.result-meta { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

.result-section { margin-bottom: 1.1rem; }
.section-label {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: flex; align-items: center; gap: 6px;
}
.section-label .tag {
  font-size: 10px; padding: 2px 8px;
  border-radius: 99px; font-weight: 600;
}
.tag-mat  { background: var(--info-bg);    color: var(--info-text); }
.tag-conso { background: var(--success-bg); color: var(--success-text); }
.tag-acc  { background: var(--warn-bg);    color: var(--warn-text); }
.tag-mo   { background: var(--purple-bg);  color: var(--purple-text); }

.item-list { border: 0.5px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.item-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 14px;
  border-bottom: 0.5px solid var(--border);
  font-size: 14px;
}
.item-row:last-child { border-bottom: none; }
.item-row:nth-child(even) { background: var(--bg); }
.item-name { flex: 1; color: var(--text); }
.item-qty  { color: var(--text-muted); font-weight: 500; white-space: nowrap; margin-left: 12px; }

.mo-total {
  background: var(--purple-bg);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 10px;
}
.mo-total-label { font-size: 14px; color: var(--purple-text); font-weight: 500; }
.mo-total-value { font-size: 24px; font-weight: 700; color: var(--purple-text); }

.remark-box {
  background: var(--warn-bg);
  border-left: 3px solid #EF9F27;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 12px 14px;
  font-size: 13px; color: var(--warn-text);
  line-height: 1.65;
  margin-top: 10px;
}

/* ---- ERROR ---- */
.error-box {
  background: #FCEBEB;
  border: 0.5px solid #F09595;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  color: #A32D2D; font-size: 14px;
}

/* ---- INDEX PAGE ---- */
.hero { text-align: center; padding: 3rem 1rem 2rem; }
.hero h1 { font-size: 28px; font-weight: 700; margin-bottom: 8px; }
.hero p  { font-size: 15px; color: var(--text-muted); max-width: 480px; margin: 0 auto; }
.module-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 1rem; margin-top: 2rem;
}
.module-card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  text-decoration: none; color: var(--text);
  display: flex; flex-direction: column; gap: 10px;
  transition: box-shadow 0.15s, border-color 0.15s;
  box-shadow: var(--shadow-sm);
}
.module-card:hover {
  border-color: var(--brand);
  box-shadow: var(--shadow-md);
}
.module-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}
.module-card h2 { font-size: 17px; font-weight: 600; }
.module-card p  { font-size: 13px; color: var(--text-muted); line-height: 1.5; }

/* ---- SETUP PAGE ---- */
.setup-box {
  background: var(--info-bg);
  border: 0.5px solid #B5D4F4;
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}
.setup-box h3 { font-size: 15px; font-weight: 600; color: var(--info-text); margin-bottom: 6px; }
.setup-box ol { padding-left: 1.3rem; font-size: 13px; color: var(--info-text); line-height: 1.9; }
.setup-box code {
  background: rgba(23,95,165,0.12);
  padding: 1px 6px; border-radius: 4px;
  font-family: monospace; font-size: 12px;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 600px) {
  .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; }
  .field.full { grid-column: 1; }
  .module-grid { grid-template-columns: 1fr; }
  .site-header { padding: 0 1rem; }
  .page { padding: 1.25rem 1rem 3rem; }
  nav .nav-link span { display: none; }
}

/* ---- PRINT / PDF ---- */
@media print {
  .site-header, .btn-bar, nav { display: none !important; }
  .card { box-shadow: none; border: 1px solid #ccc; }
  .page { padding: 0; max-width: 100%; }
}
