/* ==========================================================================
   hub.css — Espace partagé « maison », pensé pour le téléphone.
   Dépend de theme.css pour les tokens, boutons et modales.
   ========================================================================== */

.hub-body { background: var(--bg); }

.hub {
  max-width: 720px;
  margin: 0 auto;
  padding: 26px 16px calc(60px + env(safe-area-inset-bottom, 0px));
}

/* --------------------------------------------------------------
   Écrans d'accueil (non connecté / pas encore d'espace)
   -------------------------------------------------------------- */
.hub-gate {
  max-width: 420px;
  margin: 12vh auto 0;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.hub-gate h1 {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.hub-gate p { margin: 0; line-height: 1.5; }
.hub-gate .btn-primary { align-self: center; padding: 12px 22px; }

/* --------------------------------------------------------------
   En-tête
   -------------------------------------------------------------- */
.hub-header { margin-bottom: 18px; }

.hub-title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.hub-header h1 {
  margin: 0;
  font-size: clamp(1.5rem, 5vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.04em;
}

.hub-switch {
  padding: 6px 10px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: .8rem;
}

.hub-members {
  margin: 6px 0 0;
  font-size: .82rem;
  color: var(--text-3);
}

/* --------------------------------------------------------------
   Onglets
   -------------------------------------------------------------- */
.hub-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  padding: 4px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  overflow-x: auto;
  scrollbar-width: none;
}

.hub-tabs::-webkit-scrollbar { display: none; }

.hub-tab {
  flex: 1;
  min-width: max-content;
  padding: 9px 14px;
  border: none;
  border-radius: var(--r-full);
  background: transparent;
  color: var(--text-2);
  font-family: inherit;
  font-size: .84rem;
  font-weight: 620;
  white-space: nowrap;
  cursor: pointer;
  transition: background .2s var(--ease), color .2s var(--ease);
}

.hub-tab.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.hub-panel { display: none; flex-direction: column; gap: 14px; }
.hub-panel.is-active { display: flex; }

/* --------------------------------------------------------------
   Cartes de saisie
   -------------------------------------------------------------- */
.hub-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.hub-card-title {
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-3);
}

.hub-input {
  width: 100%;
  padding: 11px 13px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: .92rem;
  box-sizing: border-box;
}

.hub-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

.hub-textarea { resize: vertical; min-height: 78px; line-height: 1.45; }

.hub-row { display: flex; gap: 8px; }
.hub-row .hub-input { flex: 1; min-width: 0; }
.hub-row .btn-primary, .hub-row .btn-secondary { flex-shrink: 0; }

/* --- Photo de profil --- */
.avatar-row { align-items: center; margin-top: 14px; }
.avatar-preview {
  width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0;
  background: var(--surface-2) center/cover no-repeat;
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; color: var(--text-3);
}
.avatar-pick-btn { cursor: pointer; }

.hub-empty {
  margin: 4px 0;
  text-align: center;
  font-size: .86rem;
  color: var(--text-3);
}

/* --- Zone d'envoi de photos --- */
.hub-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 22px 16px;
  border-radius: var(--r-md);
  border: 2px dashed color-mix(in srgb, var(--primary) 40%, transparent);
  background: color-mix(in srgb, var(--primary) 6%, transparent);
  text-align: center;
  cursor: pointer;
  transition: background .2s var(--ease), border-color .2s var(--ease);
}

.hub-drop:hover { background: color-mix(in srgb, var(--primary) 12%, transparent); }
.hub-drop-icon { font-size: 1.9rem; line-height: 1; }
.hub-drop-text { font-size: .95rem; font-weight: 640; color: var(--text); }

/* --- Pastilles de couleur --- */
.color-row { display: flex; gap: 8px; flex-wrap: wrap; }

.color-dot {
  width: 30px; height: 30px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform .15s var(--ease), border-color .15s var(--ease);
}

.color-dot:hover { transform: scale(1.1); }
.color-dot.is-active { border-color: var(--text); transform: scale(1.12); }

/* --------------------------------------------------------------
   Galerie
   -------------------------------------------------------------- */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 8px;
}

.photo-thumb {
  position: relative;
  aspect-ratio: 1;
  border: none;
  padding: 0;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface-2);
  cursor: pointer;
}

.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.photo-thumb-by {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 14px 6px 4px;
  background: linear-gradient(to top, rgba(0,0,0,.66), transparent);
  color: #fff;
  font-size: .64rem;
  font-weight: 620;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Visionneuse --- */
.photo-viewer {
  position: relative;
  width: min(94vw, 760px);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.photo-viewer img {
  max-width: 100%;
  max-height: 68vh;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
}

.photo-viewer-bar { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.photo-viewer-bar .btn-secondary { text-decoration: none; }

/* --------------------------------------------------------------
   Notes
   -------------------------------------------------------------- */
.note-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }

.note-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 13px 14px;
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--note-color, #fde68a) 26%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--note-color, #fde68a) 58%, transparent);
}

.note-item-text { font-size: .92rem; line-height: 1.4; white-space: pre-line; word-break: break-word; }

.note-item-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: .68rem;
  font-weight: 660;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-3);
}

.icon-btn {
  border: none;
  background: none;
  padding: 4px 6px;
  border-radius: var(--r-sm);
  color: var(--text-3);
  font-size: .9rem;
  cursor: pointer;
  line-height: 1;
}

.icon-btn:hover { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }

/* --------------------------------------------------------------
   Calendriers et aperçu
   -------------------------------------------------------------- */
.cal-list, .member-list { display: flex; flex-direction: column; gap: 8px; }

.cal-item, .member-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
}

.cal-swatch { width: 10px; height: 28px; border-radius: 5px; flex-shrink: 0; background: var(--cal-color, var(--primary)); }
.cal-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cal-name { font-size: .9rem; font-weight: 640; }
.cal-url { font-size: .7rem; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.member-avatar {
  width: 32px; height: 32px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--primary) 20%, transparent);
  color: var(--primary);
  font-weight: 700;
  font-size: .85rem;
}

.member-name { flex: 1; min-width: 0; font-size: .9rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.member-tag { font-size: .66rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }

.agenda-preview { display: flex; flex-direction: column; gap: 8px; }

.preview-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 9px 11px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border-left: 3px solid var(--ev-color, var(--primary));
}

.preview-when {
  flex-shrink: 0;
  min-width: 84px;
  font-size: .74rem;
  font-weight: 660;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.preview-title { font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --------------------------------------------------------------
   Aide dépliable
   -------------------------------------------------------------- */
.hub-help {
  margin-top: 2px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font-size: .82rem;
}

.hub-help summary { cursor: pointer; font-weight: 620; color: var(--text-2); }
.hub-help ol { margin: 10px 0 6px; padding-left: 20px; line-height: 1.55; color: var(--text-2); }
.hub-help li { margin-bottom: 6px; }
.hub-help a { color: var(--primary); }

/* --------------------------------------------------------------
   États des messages
   -------------------------------------------------------------- */
.field-hint { margin: 0; font-size: .76rem; line-height: 1.45; color: var(--text-3); }
.field-hint.error   { color: var(--danger); }
.field-hint.success { color: var(--success); }

@media (max-width: 480px) {
  .hub { padding: 18px 12px 60px; }
  .hub-card { padding: 14px; }
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }
}
