* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background: #f5f5f5;
  color: #222;
  font-size: 16px;
  line-height: 1.8;
}

.container {
  max-width: 860px;
  margin: 40px auto;
  background: white;
  padding: 40px;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
}

h1.doc-title {
  font-size: 1.4rem;
  margin-bottom: 24px;
  border-bottom: 2px solid #ddd;
  padding-bottom: 12px;
  color: #1a1a2e;
}

h1 { font-size: 1.6rem; margin-bottom: 8px; color: #1a1a2e; }

.doc-body { margin-bottom: 32px; }

.doc-line {
  margin: 8px 0;
  text-align: right;
}

.field {
  display: inline-block;
  border: none;
  border-bottom: 2px solid #2563eb;
  background: #eff6ff;
  padding: 2px 8px;
  font-size: 15px;
  font-family: inherit;
  color: #1e40af;
  min-width: 120px;
  outline: none;
  border-radius: 2px;
  vertical-align: baseline;
}

.field:focus {
  background: #dbeafe;
  border-color: #1d4ed8;
}

.date-field { min-width: 160px; }

.actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  align-items: center;
  border-top: 1px solid #eee;
  padding-top: 20px;
  margin-top: 24px;
  flex-wrap: wrap;
}

button {
  background: #2563eb;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
}

button:hover { background: #1d4ed8; }

.actions a {
  color: #555;
  text-decoration: none;
  font-size: 14px;
}

.actions a:hover { color: #111; }

/* Index page */
.form-list {
  list-style: none;
  margin-top: 16px;
}

.form-list li {
  padding: 10px 0;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.form-list a {
  color: #2563eb;
  text-decoration: none;
  font-size: 15px;
}

.form-list a:hover { text-decoration: underline; }

.field-count { color: #888; font-size: 13px; }

@media print {
  /* A4: 210×297mm — standard paper in Morocco */
  @page {
    size: A4 portrait;
    margin: 2.5cm 2cm 2.5cm 2cm;
  }

  body {
    background: white;
    font-size: 13pt;
    line-height: 2;
    color: #000;
  }

  .container {
    box-shadow: none;
    border-radius: 0;
    padding: 0;
    margin: 0;
    max-width: 100%;
  }

  h1.doc-title {
    font-size: 14pt;
    border-bottom: 1pt solid #000;
    margin-bottom: 16pt;
    padding-bottom: 8pt;
  }

  /* Hide all UI chrome */
  .actions { display: none !important; }
  button { display: none !important; }

  /* Fields: look like underlines, not interactive inputs */
  .field {
    border: none;
    border-bottom: 1pt solid #000;
    background: transparent;
    color: #000;
    font-size: 13pt;
    font-family: inherit;
    border-radius: 0;
    padding: 0 4pt;
    min-width: 80pt;
    -webkit-appearance: none;
    appearance: none;
  }

  /* Hide date picker icon and spin buttons */
  input[type="date"]::-webkit-calendar-picker-indicator { display: none; }
  input[type="date"]::-webkit-inner-spin-button { display: none; }
  input[type="date"] { -webkit-appearance: textfield; }
  input[type="number"]::-webkit-outer-spin-button,
  input[type="number"]::-webkit-inner-spin-button { display: none; }

  /* Tables: keep borders visible for printed forms */
  .doc-table { border-collapse: collapse; width: 100%; }
  .doc-table td {
    border: 0.5pt solid #555;
    padding: 4pt 6pt;
    min-height: 20pt;
  }
  .cell-field { border-bottom: none; min-width: 0; width: 100%; }

  /* Avoid page breaks inside a paragraph */
  .doc-line { page-break-inside: avoid; }

  /* Signature area: push to bottom of last page */
  .doc-body { margin-bottom: 0; }
}
