/* ==================== BASE MOBILE-FIRST ==================== */

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: #222;
  background: #f5f5f5;
  padding: 12px;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ==================== HEADER / TOOLBAR ==================== */

.toolbar {
  background: white;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.header-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.header-top h1 {
  margin: 0;
  font-size: 18px;
  flex: 1;
}

.home-link {
  font-size: 24px;
  display: inline-flex;
  align-items: center;
}

/* Sélecteur de parcours - vertical sur mobile */
.course-selector {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 13px;
}

.course-selector label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
  background: #f9f9f9;
  border-radius: 8px;
  cursor: pointer;
  margin: 0;
}

.course-selector input[type="radio"] {
  cursor: pointer;
  margin: 0;
}

/* Actions de navigation */
.top-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.nav-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.main-actions {
  display: flex;
  width: 100%;
}

/* ==================== BUTTONS ==================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  text-align: center;
  min-height: 44px;
}

.btn-nav {
  background: white;
  color: #2d5a27;
  border: 1.5px solid #2d5a27;
  font-size: 12px;
}

.btn-nav:active {
  background: #f1f8f1;
}

.btn-primary {
  background: #2d5a27;
  color: white;
  width: 100%;
}

.btn-primary:active {
  background: #1f3f1a;
}

/* ==================== CARDS ==================== */

.card {
  background: white;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.card-match-select {
  border-top: 4px solid #2d5a27;
}

.card-scores {
  border-top: 4px solid #f39c12;
}

.section-title {
  margin: 0 0 12px 0;
  font-size: 16px;
  color: #333;
}

/* ==================== FORMS ==================== */

.form-group {
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: #333;
  margin-bottom: 6px;
  display: block;
}

.input-green {
  background: #c6efce;
  border: 1.5px solid #7aa17a;
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
  color: #333;
}

.input-green:focus {
  outline: none;
  border-color: #2d5a27;
  box-shadow: 0 0 0 3px rgba(45, 90, 39, 0.1);
}

.input-large {
  min-height: 44px;
  font-size: 14px;
}

.form-group small {
  font-size: 12px;
  color: #999;
  margin-top: 4px;
}

/* ==================== MATCH INFO GRID ==================== */

.match-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #eee;
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  background: #f9f9f9;
  border-radius: 8px;
}

.info-label {
  font-size: 11px;
  font-weight: 600;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.info-value {
  font-size: 14px;
  font-weight: 600;
  color: #2d5a27;
  word-break: break-word;
}

/* ==================== SCORE TABLE ==================== */

/* Afficher le tableau partout, mais avec scroll sur mobile */
.score-table-desktop {
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Masquer les cartes (à développer plus tard) */
.score-table-mobile {
  display: none;
}

.holes-grid {
  display: none;
}

/* Tableau sur mobile: compact et scrollable */
@media (max-width: 767px) {
  .score-table-desktop {
    margin: 0 -14px;
    padding: 0;
  }

  table {
    width: 100%;
    min-width: 600px;
    border-collapse: collapse;
    font-size: 12px;
  }

  th, td {
    border: 1px solid #ddd;
    padding: 6px 4px;
    text-align: center;
  }

  th {
    background: #f0f0f0;
    font-weight: 600;
    font-size: 11px;
  }

  td:first-child, th:first-child {
    text-align: left;
    font-weight: 600;
    min-width: 70px;
    position: sticky;
    left: 0;
    background: #f9f9f9;
    z-index: 1;
  }

  th:first-child {
    background: #f0f0f0;
    z-index: 2;
  }

  .calc {
    background: #f3f3f3;
    font-weight: 600;
  }

  table input {
    width: 100%;
    height: 100%;
    padding: 4px 2px;
    border: none;
    text-align: center;
    font-size: 13px;
    background: #c6efce;
    box-sizing: border-box;
  }

  table input:focus {
    outline: 2px solid #2d5a27;
    background: #b5e0b5;
  }

  .has-stroke {
    background-color: #ffeeba !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  input::-webkit-outer-spin-button,
  input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
  }
}

/* ==================== SPINNER ==================== */

.spinner-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.spinner-overlay.hidden {
  display: none;
}

.spinner-content {
  background: white;
  padding: 32px;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.spinner {
  border: 4px solid #f3f3f3;
  border-top: 4px solid #2d5a27;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.spinner-content p {
  margin: 0;
  color: #333;
  font-weight: 600;
}

/* ==================== MODALS ==================== */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1001;
  padding: 16px;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  width: 100%;
  max-width: 400px;
  overflow: hidden;
}

.modal-header {
  padding: 16px;
  border-bottom: 1px solid #eee;
  background: #f9f9f9;
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
  color: #333;
}

.modal-body {
  padding: 16px;
  color: #555;
}

.modal-body p {
  margin: 0;
  line-height: 1.6;
  font-size: 14px;
}

.modal-footer {
  padding: 12px 16px;
  border-top: 1px solid #eee;
  text-align: right;
  background: #f9f9f9;
}

.modal-content.modal-error .modal-header {
  background: #ffebee;
}

.modal-content.modal-error .modal-header h2 {
  color: #c62828;
}

/* ==================== UTILITIES ==================== */

.hidden-row {
  display: none;
}

.no-print {
  /* À définir au besoin */
}

/* ==================== PRINT ==================== */

@media print {
  body {
    padding: 0;
    background: white;
  }

  .no-print,
  .toolbar,
  #btnSendResults,
  select {
    display: none !important;
  }

  .card {
    box-shadow: none;
    border: 1px solid #ccc;
    page-break-inside: avoid;
  }

  .score-table-desktop {
    display: table;
  }

  .score-table-mobile {
    display: none;
  }
}

/* ==================== TABLET / DESKTOP ==================== */

@media (min-width: 768px) {
  body {
    padding: 16px;
  }

  .toolbar {
    padding: 14px;
  }

  .header-top {
    margin-bottom: 14px;
  }

  .header-top h1 {
    font-size: 20px;
  }

  .course-selector {
    grid-template-columns: repeat(3, auto);
    gap: 16px;
    margin-bottom: 14px;
  }

  .course-selector label {
    padding: 10px 12px;
    font-size: 14px;
  }

  .top-actions {
    flex-direction: row;
    justify-content: space-between;
  }

  .nav-actions {
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    flex: 1;
  }

  .main-actions {
    width: auto;
    margin-left: 16px;
  }

  .btn {
    padding: 10px 16px;
    font-size: 14px;
  }

  .btn-nav {
    font-size: 13px;
  }

  .card {
    padding: 16px;
    margin-bottom: 16px;
  }

  .match-info-grid {
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 12px;
  }

  .info-item {
    padding: 10px;
  }

  .form-label {
    font-size: 14px;
  }

  .input-green {
    padding: 10px 12px;
  }

  /* Afficher tableau sur desktop */
  .score-table-desktop {
    display: table;
    width: 100%;
  }

  .score-table-mobile {
    display: none;
  }

  /* Tableau desktop */
  table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
  }

  th, td {
    border: 1px solid #ddd;
    padding: 8px 6px;
    text-align: center;
  }

  th {
    background: #f9f9f9;
    font-weight: 600;
  }

  td:first-child, th:first-child {
    text-align: left;
    font-weight: 600;
  }

  .calc {
    background: #f3f3f3;
    font-weight: 600;
  }

  table input {
    width: 100%;
    padding: 6px;
    border: none;
    text-align: center;
    font-size: 14px;
    background: #c6efce;
  }

  table input:focus {
    outline: 2px solid #2d5a27;
  }

  .has-stroke {
    background-color: #ffeeba !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Supprimer les flèches spinbutton */
  input::-webkit-outer-spin-button,
  input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
  }
}

/* ==================== LARGE DESKTOP ==================== */

@media (min-width: 1024px) {
  body {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
  }

  .toolbar {
    padding: 16px;
  }

  .nav-actions {
    gap: 12px;
  }

  .card {
    padding: 20px;
  }
}
