/* ============================================================
   Semainier PWA – Mobile-first styles
   ============================================================ */

:root {
  --blue:        #1B4F72;
  --blue-dark:   #154360;
  --blue-light:  #D6EAF8;
  --blue-mid:    #5DADE2;
  --green:       #1E8449;
  --bg:          #f0f4f8;
  --card-bg:     #ffffff;
  --text:        #2C3E50;
  --text-muted:  #7F8C8D;
  --border:      #E0E6ED;
  --shadow:      0 2px 10px rgba(0,0,0,0.08);
  --radius:      14px;
  --radius-sm:   8px;
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* ---- Offline banner ---- */
#offline-banner {
  display: none;
  background: #C0392B;
  color: #fff;
  text-align: center;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.2px;
}
#offline-banner.visible { display: block; }

/* ---- Update banner ---- */
.update-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #1A5276;
  color: #fff;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  animation: slideDown 0.3s ease;
}
.update-banner.hidden { display: none; }
.update-banner span   { flex: 1; }
#btn-update {
  background: #fff;
  color: #1A5276;
  border: none;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  transition: opacity 0.15s;
}
#btn-update:active { opacity: 0.8; }

@keyframes slideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}

/* ---- App shell ---- */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ---- Header ---- */
#app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--blue);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  padding-top: calc(10px + var(--safe-top));
  box-shadow: 0 2px 12px rgba(0,0,0,0.25);
}

#app-header > button {
  flex-shrink: 0;
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
#app-header > button:active { background: rgba(255,255,255,0.35); }

#week-title-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 0;
}

#week-title {
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

#btn-today {
  display: none;
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.4);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
}
#btn-today.visible { display: inline-block; }
#btn-today:active { background: rgba(255,255,255,0.4); }

#btn-settings {
  flex-shrink: 0;
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
#btn-settings:active { background: rgba(255,255,255,0.35); }

/* ---- Main content ---- */
#app-main {
  flex: 1;
  padding: 14px;
  padding-bottom: calc(80px + var(--safe-bottom) + 14px);
}

/* ---- Zone poids ---- */
.weight-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 13px 16px;
  margin-bottom: 10px;
  border-left: 4px solid var(--blue-mid);
}

.weight-row label {
  font-size: 14px;
  font-weight: 700;
  color: var(--blue);
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 0.2s;
}
.weight-row label.weight-label-empty  { color: #E74C3C; }
.weight-row label.weight-label-filled { color: var(--green); }

.weight-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: #FAFCFF;
  outline: none;
  min-width: 0;
  transition: border-color 0.15s;
}
.weight-input:focus {
  border-color: var(--blue-mid);
}
.weight-input::placeholder {
  color: #BDC3C7;
  font-style: italic;
}

/* ---- Day cards ---- */
.day-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  overflow: hidden;
  border-left: 4px solid transparent;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.day-card.today {
  border-left-color: var(--blue);
  box-shadow: 0 4px 16px rgba(27,79,114,0.15);
}
.day-card.has-content:not(.today) {
  border-left-color: var(--green);
}
.day-card.has-content:not(.today) .day-name {
  color: var(--green);
}

/* Card header (tap to expand) */
.day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  cursor: pointer;
  user-select: none;
  background: var(--card-bg);
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.day-header:active { background: var(--blue-light); }

.day-header-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.day-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.day-card.today .day-name { color: var(--blue); }

.day-date {
  font-size: 12px;
  color: var(--text-muted);
}

.day-toggle {
  font-size: 16px;
  color: var(--text-muted);
  transition: transform 0.25s ease;
  line-height: 1;
}
.day-card.open .day-toggle { transform: rotate(180deg); }

/* Card content (collapsible) */
.day-content {
  display: none;
  border-top: 1px solid var(--border);
}
.day-card.open .day-content { display: block; }

/* ---- Slot rows ---- */
.slot-row {
  display: grid;
  grid-template-columns: 88px 1fr;
  border-bottom: 1px solid var(--border);
}
.slot-row:last-child { border-bottom: none; }

.slot-label {
  padding: 11px 10px 11px 14px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--blue);
  background: var(--blue-light);
  border-right: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  padding-top: 13px;
  line-height: 1.2;
}

.slot-input {
  width: 100%;
  border: none;
  outline: none;
  padding: 11px 13px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: transparent;
  resize: none;
  min-height: 44px;
  line-height: 1.55;
  overflow: hidden;
}
.slot-input::placeholder { color: #BDC3C7; font-style: italic; }
.slot-input:focus { background: #FAFCFF; }

/* ---- Footer ---- */
#app-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 12px 16px;
  padding-bottom: calc(12px + var(--safe-bottom));
  border-top: 1px solid var(--border);
  z-index: 100;
}

#btn-export {
  width: 100%;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
#btn-export:active {
  background: var(--blue-dark);
  transform: scale(0.98);
}

/* ---- Modal (bottom sheet) ---- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
}
.modal.hidden { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
  animation: fadeIn 0.2s ease;
}

.modal-sheet {
  position: relative;
  background: #fff;
  border-radius: 22px 22px 0 0;
  padding: 12px 20px 28px;
  padding-bottom: calc(28px + var(--safe-bottom));
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 11px;
  animation: slideUp 0.25s ease;
}

.modal-handle {
  width: 40px;
  height: 4px;
  background: #DDE0E4;
  border-radius: 2px;
  margin: 0 auto 10px;
}

.modal-sheet h2 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
}
.modal-sheet p {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 4px;
}

.modal-sheet button {
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.modal-sheet button:active {
  opacity: 0.8;
  transform: scale(0.98);
}
.btn-primary  { background: var(--blue);  color: #fff; }
.btn-success  { background: #1E8449;      color: #fff; }
.btn-ghost    { background: #ECF0F1;      color: var(--text-muted); }

.settings-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-top: 4px;
}

.settings-ios-warning {
  background: #FEF9E7;
  border: 1px solid #F9E79F;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  color: #7D6608;
  line-height: 1.5;
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: calc(76px + var(--safe-bottom) + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(44,62,80,0.92);
  color: #fff;
  padding: 9px 20px;
  border-radius: 20px;
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  z-index: 300;
  pointer-events: none;
  transition: opacity 0.3s;
}
.toast.hidden   { display: none; }
.toast.fade-out { opacity: 0; }

/* ---- Animations ---- */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

/* ---- Empty state ---- */
.empty-state {
  text-align: center;
  padding: 40px 24px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h3    { font-size: 17px; margin-bottom: 8px; color: var(--text); }
.empty-state p     { font-size: 14px; line-height: 1.5; }

/* ---- Responsive – tablet / desktop ---- */
@media (min-width: 600px) {
  #app-main { max-width: 600px; margin: 0 auto; padding: 20px; padding-bottom: calc(90px + var(--safe-bottom)); }
  #app-footer { display: flex; justify-content: center; }
  #btn-export { max-width: 400px; }
  .modal-sheet { max-width: 480px; margin: 0 auto; border-radius: 22px; margin-bottom: 24px; }
  .modal { align-items: center; }
}
