/* =========================================
   Glaura — Mon espace (bookings + account)
   Layers on top of bookings.css + profile.css
   (already loaded by mon-espace/index.blade.php).
   Adds the new "mes-*" design system pieces:
   identity card, section nav, segmented tabs,
   month timeline, row actions, pills, review
   modal, empty states, toasts.

   Font: the design spec calls for DM Sans, but
   the site loads Inter globally (layouts/feed);
   this page follows the existing var(--font)
   rather than adding a second webfont.
   ========================================= */

.mon-espace-page {
  --mes-primary: #E50050;
  --mes-primary-light: #FFF0F4;
  --mes-page-bg: #f7f8fa;
  --mes-border: #EFEFEF;
  --mes-border-strong: #E2E2E6;
  --mes-grey: #939393;
  --mes-dark-grey: #464646;
  --mes-near-black: #1c1c1e;
  --mes-green: #2f9d76;
  --mes-green-bg: #EBF9F3;
  --mes-amber: #B26A00;
  --mes-amber-bg: #FFF8E1;
  --mes-pink-bg: #FDECF1;
  --mes-credit: #ff5c8f;
  --mes-radius-btn: 10px;
  --mes-radius-card: 16px;
  --mes-radius-panel: 18px;
  background: var(--mes-page-bg);
}

.mon-espace-page * { box-sizing: border-box; }

.mon-espace-page :focus-visible {
  outline: 2px solid var(--mes-primary);
  outline-offset: 2px;
}

.mes-hidden-form { display: none; }

/* ---- Shell layout ---- */
.mes-shell {
  display: block;
  padding: 16px 16px 32px;
}

@media (min-width: 1024px) {
  .mes-shell {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 28px;
    align-items: start;
    padding: 28px 32px 40px;
    max-width: 1280px;
    margin: 0 auto;
  }
}

.mes-rail {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 20px;
}

@media (min-width: 1024px) {
  .mes-rail {
    position: sticky;
    top: 28px;
    margin-bottom: 0;
  }
}

.mes-main {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

/* ---- Identity card ---- */
.identity-card {
  background: var(--mes-near-black);
  border-radius: var(--mes-radius-panel);
  padding: 16px;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

@media (min-width: 1024px) {
  .identity-card { padding: 22px; gap: 16px; }
}

.identity-main {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  background: none;
  border: none;
  text-align: left;
  width: 100%;
}

.identity-avatar {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--mes-primary);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
}

@media (min-width: 1024px) {
  .identity-avatar { width: 52px; height: 52px; font-size: 20px; }
}

.identity-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  gap: 1px;
}

.identity-name {
  font-size: 16px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (min-width: 1024px) {
  .identity-name { font-size: 17px; }
}

.identity-email {
  font-size: 12px;
  opacity: .6;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: none;
}

.identity-subline {
  font-size: 12px;
  opacity: .6;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (min-width: 1024px) {
  .identity-email { display: block; }
  .identity-subline { display: none; }
}

.identity-chevron {
  flex-shrink: 0;
}

@media (min-width: 1024px) {
  .identity-chevron { display: none; }
}

.identity-divider {
  height: 1px;
  background: rgba(255, 255, 255, .12);
}

.identity-stats {
  display: flex;
  justify-content: space-between;
}

.identity-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.identity-stat-value {
  font-size: 19px;
  font-weight: 700;
}

.identity-stat-value--credits { color: var(--mes-credit); }

.identity-stat-label {
  font-size: 11px;
  opacity: .6;
}

/* ---- Section nav (desktop only) ---- */
.section-nav-card {
  display: none;
}

@media (min-width: 1024px) {
  .section-nav-card {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid var(--mes-border);
    border-radius: var(--mes-radius-panel);
    padding: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .04);
  }
}

.section-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  border: none;
  background: none;
  cursor: pointer;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  color: var(--mes-dark-grey);
  text-align: left;
  transition: background .15s, color .15s;
}

.section-nav-item svg { flex-shrink: 0; stroke: var(--mes-grey); transition: stroke .15s; }

.section-nav-item:hover { background: var(--mes-page-bg); }

.section-nav-item.active {
  background: var(--mes-primary-light);
  color: var(--mes-primary);
  font-weight: 600;
}

.section-nav-item.active svg { stroke: var(--mes-primary); }

.section-nav-item--logout { color: var(--mes-primary); font-weight: 600; }
.section-nav-item--logout svg { stroke: var(--mes-primary); }
.section-nav-item--logout:hover { background: var(--mes-primary-light); }

.section-nav-divider {
  height: 1px;
  background: var(--mes-border);
  margin: 6px 14px;
}

/* ---- Tabs ---- */
.mes-segmented {
  display: flex;
  gap: 22px;
  border-bottom: 1px solid #E6E6EA;
  overflow-x: auto;
}

@media (min-width: 1024px) {
  .mes-segmented { display: none; }
}

.mes-segmented-item {
  background: none;
  border: none;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  color: var(--mes-grey);
  padding: 0 0 10px;
  cursor: pointer;
  white-space: nowrap;
}

.mes-segmented-item.active {
  color: var(--mes-near-black);
  font-weight: 700;
  box-shadow: inset 0 -2px 0 var(--mes-primary);
}

.mes-tabbar {
  display: none;
}

@media (min-width: 1024px) {
  .mes-tabbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
  }
}

.mes-tabbar-tabs {
  display: inline-flex;
  gap: 26px;
  border-bottom: 1px solid #E6E6EA;
}

.mes-tabbar-item {
  background: none;
  border: none;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  color: var(--mes-grey);
  padding: 0 0 11px;
  cursor: pointer;
}

.mes-tabbar-item.active {
  color: var(--mes-near-black);
  font-weight: 700;
  box-shadow: inset 0 -2px 0 var(--mes-primary);
}

.mes-filters {
  display: flex;
  gap: 8px;
}

.mes-filter-pill {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  color: var(--mes-dark-grey);
  background: #fff;
  border: 1px solid var(--mes-border-strong);
  border-radius: 99px;
  padding: 7px 30px 7px 13px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23464646' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
}

/* ---- Month groups ---- */
.mes-month-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mes-month-group + .mes-month-group { margin-top: 18px; }

.mes-month-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mes-month-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--mes-grey);
  white-space: nowrap;
}

@media (min-width: 1024px) { .mes-month-label { font-size: 12px; } }

.mes-month-rule {
  flex: 1;
  height: 1px;
  background: #E6E6EA;
}

.mes-month-summary {
  font-size: 12px;
  color: var(--mes-grey);
  white-space: nowrap;
}

.mes-month-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---- Rows ---- */
.mes-row {
  background: #fff;
  border: 1px solid var(--mes-border);
  border-radius: var(--mes-radius-card);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .04);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mes-row--cancelled { opacity: .72; }

.mes-row-date {
  display: none;
}

.mes-row-date-mobile {
  font-size: 12px;
  font-weight: 600;
  color: var(--mes-grey);
}

.mes-row--cancelled .mes-row-date-mobile { text-decoration: line-through; }

.mes-row-body {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.mes-row-photo {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--mes-border) center / cover no-repeat;
}

.mes-row-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

.mes-row-title-line {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.mes-row-service {
  font-size: 15px;
  font-weight: 700;
  color: var(--mes-near-black);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.mes-row--cancelled .mes-row-service { color: var(--mes-dark-grey); }

.mes-row-meta {
  font-size: 13px;
  color: #6b6b70;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mes-row--cancelled .mes-row-meta { color: var(--mes-grey); }

.mes-row-stars {
  font-size: 12px;
  font-weight: 600;
  color: var(--mes-amber);
  letter-spacing: 1px;
}

.mes-row-chip {
  font-size: 11px;
  font-weight: 600;
  color: var(--mes-grey);
  background: var(--mes-page-bg);
  border-radius: 99px;
  padding: 2px 8px;
}

.mes-row-actions {
  display: flex;
  gap: 8px;
  border-top: 1px solid #F3F3F5;
  padding-top: 11px;
}

.mes-row-actions .mes-btn {
  flex: 1;
  justify-content: center;
  min-height: 44px;
}

@media (min-width: 1024px) {
  .mes-row {
    display: grid;
    grid-template-columns: 104px 1fr auto;
    align-items: center;
    gap: 18px;
    padding: 16px 20px;
  }

  .mes-row-date {
    display: flex;
    flex-direction: column;
    border-right: 1px solid #F1F1F4;
    padding-right: 12px;
  }

  .mes-row-day {
    font-size: 20px;
    font-weight: 700;
    color: var(--mes-near-black);
  }

  .mes-row--cancelled .mes-row-day {
    color: var(--mes-grey);
    text-decoration: line-through;
  }

  .mes-row-time {
    font-size: 12px;
    color: var(--mes-grey);
  }

  .mes-row-date-mobile { display: none; }

  .mes-row-actions {
    border-top: none;
    padding-top: 0;
    align-items: center;
  }

  .mes-row-actions .mes-btn {
    flex: none;
    min-height: 0;
  }
}

/* ---- Pills ---- */
.mes-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.mes-pill--termine { background: var(--mes-green-bg); color: var(--mes-green); }
.mes-pill--annule { background: var(--mes-pink-bg); color: var(--mes-primary); }
.mes-pill--confirme { background: var(--mes-page-bg); color: #6b6b70; }
.mes-pill--attente { background: var(--mes-amber-bg); color: var(--mes-amber); }

/* ---- Buttons ---- */
.mes-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  padding: 9px 14px;
  border-radius: var(--mes-radius-btn);
  border: none;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: opacity .15s, border-color .15s, color .15s;
}

.mes-btn:hover { opacity: .85; }

.mes-btn--amber { background: var(--mes-amber-bg); color: var(--mes-amber); }
.mes-btn--dark { background: var(--mes-near-black); color: #fff; }
.mes-btn--outline { background: #fff; color: var(--mes-dark-grey); border: 1px solid var(--mes-border-strong); }
.mes-btn--outline:hover { border-color: var(--mes-dark-grey); opacity: 1; }
.mes-btn--ghost { background: none; color: var(--mes-grey); }
.mes-btn--ghost:hover { color: var(--mes-primary); opacity: 1; }
.mes-btn--primary { background: var(--mes-primary); color: #fff; }
.mes-btn--rebook { background: var(--mes-primary-light); color: var(--mes-primary); flex: none; }

.mes-btn--lg { font-size: 14px; padding: 12px 22px; border-radius: 12px; }

/* ---- Empty states ---- */
.mes-empty {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.mes-empty-card {
  background: #fff;
  border: 1px solid var(--mes-border);
  border-radius: 20px;
  padding: 40px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
}

@media (min-width: 1024px) { .mes-empty-card { padding: 56px 40px; } }

.mes-empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--mes-primary-light);
  color: var(--mes-primary);
}

.mes-empty-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--mes-near-black);
}

@media (min-width: 1024px) { .mes-empty-title { font-size: 20px; } }

.mes-empty-body {
  font-size: 14px;
  color: #6b6b70;
  max-width: 360px;
}

.mes-empty-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
}

.mes-rebook-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 640px) {
  .mes-rebook-grid { grid-template-columns: 1fr 1fr; }
}

.mes-rebook-card {
  background: #fff;
  border: 1px solid var(--mes-border);
  border-radius: var(--mes-radius-card);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.mes-rebook-photo {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--mes-border) center / cover no-repeat;
}

.mes-rebook-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.mes-rebook-service {
  font-size: 15px;
  font-weight: 700;
  color: var(--mes-near-black);
}

.mes-rebook-meta {
  font-size: 12px;
  color: #6b6b70;
}

.mes-loadmore-wrap {
  display: flex;
  justify-content: center;
  padding-top: 4px;
}

/* ---- Account tab ---- */
.mes-account {
  max-width: 640px;
}

.mes-account-logout {
  margin-top: 16px;
}

/* ---- Review modal (base modal chrome mirrors #cancelModal in bookings.css,
   since #reviewModal isn't ID-scoped there and has no baseline of its own) ---- */
#reviewModal.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

#reviewModal .modal-content {
  background: #fff;
  border-radius: 16px;
  padding: 28px 24px 24px;
  max-width: 420px;
  width: 100%;
  position: relative;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .18);
}

#reviewModal .modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: #f0f0f0;
  border: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: #666;
  padding: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#reviewModal .modal-close:hover { background: var(--mes-primary); color: #fff; }

#reviewModal h3 {
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  margin: 0 0 4px;
  color: #1f2937;
}

.mes-review-service {
  text-align: center;
  font-size: 14px;
  color: #6b7280;
  margin: 0 0 18px;
}

.mes-review-stars {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 18px;
}

.mes-review-star {
  background: none;
  border: none;
  font-size: 30px;
  line-height: 1;
  color: var(--mes-border-strong);
  cursor: pointer;
  padding: 4px;
}

.mes-review-star.is-filled { color: var(--mes-amber); }

.mes-review-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--mes-dark-grey);
  margin-bottom: 8px;
}

.mes-review-textarea {
  width: 100%;
  min-height: 90px;
  border: 1.5px solid var(--mes-border-strong);
  border-radius: 12px;
  padding: 12px 14px;
  font-family: var(--font);
  font-size: 14px;
  color: var(--mes-near-black);
  resize: vertical;
  margin-bottom: 8px;
}

.mes-review-textarea:focus {
  outline: none;
  border-color: var(--mes-primary);
  box-shadow: 0 0 0 3px rgba(229, 0, 80, .1);
}

#reviewModal .modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

#reviewModal .btn-confirm-cancel {
  background: var(--mes-primary);
  color: #fff;
  border: none;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  padding: 12px 20px;
  width: 100%;
  cursor: pointer;
  transition: opacity .15s;
}

#reviewModal .btn-confirm-cancel:hover { opacity: .85; }

#reviewModal .btn-confirm-cancel:disabled {
  opacity: .5;
  cursor: not-allowed;
}

/* ---- Toasts (not loaded elsewhere on this page) ---- */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
}

.toast {
  background: #333;
  color: #fff;
  padding: 16px 24px;
  border-radius: 8px;
  margin-bottom: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .15);
  animation: mesToastIn .3s ease;
  max-width: 350px;
}

.toast.success { background: #10b981; }
.toast.error { background: #ef4444; }
.toast.fade-out { animation: mesToastOut .3s ease forwards; }

@keyframes mesToastIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes mesToastOut {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100%); opacity: 0; }
}

/* Class-driven modal visibility (house convention — see auth-modals.js):
   both overlays stay hidden until JS adds .show. Declared last so it
   overrides the base display:flex chrome above and in bookings.css. */
#cancelModal.modal-overlay,
#reviewModal.modal-overlay {
  display: none;
}

#cancelModal.modal-overlay.show,
#reviewModal.modal-overlay.show {
  display: flex;
}

/* =========================================
   Session gate
   Shown only when /mon-espace renders without a Laravel session, while
   mon-espace-session-gate.js waits to hear whether Firebase can restore
   one. Deliberately outside .mon-espace-page (which is hidden in that
   state), so it repeats the few tokens it needs instead of inheriting.
   ========================================= */

.mes-session-gate {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: 32px 20px;
  background: #f7f8fa;
}

.mes-gate-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 420px;
  padding: 32px 24px;
  border: 1px solid #EFEFEF;
  border-radius: 18px;
  background: #fff;
  text-align: center;
}

.mes-gate-card[hidden] { display: none; }

.mes-gate-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #FDECF1;
  border-top-color: #E50050;
  border-radius: 50%;
  animation: mesGateSpin .8s linear infinite;
}

@keyframes mesGateSpin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .mes-gate-spinner { animation-duration: 2.4s; }
}

.mes-gate-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: #1c1c1e;
}

.mes-gate-text {
  margin: 0;
  font-size: .9375rem;
  line-height: 1.5;
  color: #464646;
}

.mes-gate-cta {
  min-height: 44px;
  padding: 0 24px;
  border: 0;
  border-radius: 10px;
  background: #E50050;
  color: #fff;
  font-size: .9375rem;
  font-weight: 600;
  cursor: pointer;
}

.mes-gate-cta:hover { background: #c80045; }

.mes-gate-cta:focus-visible {
  outline: 2px solid #E50050;
  outline-offset: 2px;
}

/* Multi-service bookings: the title is the full list of services, one per
   line; add-ons read lighter with a "+" prefix. */
.mes-row-title-line--multi { align-items: flex-start; }
.mes-row-services {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.mes-row-service--addon { font-weight: 500; }
