/* ═══════════════════════════════════════════════════════════════
   FAVORIS — styles intégrés à l'Agenda Collaboratif
   Toutes les classes préfixées fav- pour éviter les conflits
   Utilise exclusivement les variables CSS de l'agenda
   ═══════════════════════════════════════════════════════════════ */

/* ── Conteneur principal ──────────────────────────────────────── */
#favoris-item {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  position: relative;
  font-family: var(--font-ui); /* Alignement sur la police globale de l'agenda */
}

/* ── Barre supérieure ─────────────────────────────────────────── */
.fav-top-bar {
  padding: 10px 16px 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fav-data-bar {
  display: flex;
  gap: 5px;
  align-items: stretch;
  flex-wrap: wrap;
}
.fav-data-bar .btn {
  flex: 1;
  min-width: 60px;
  padding: 6px 8px;
  font-size: 13px; /* Aligné sur la taille des boutons de l'agenda */
  text-align: center;
  font-family: var(--font-ui);
}

.fav-search-row {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}
#fav-search {
  width: 100%;
  padding: 7px 32px 7px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px; /* Aligné sur la recherche des notes */
  font-family: var(--font-ui);
  outline: none;
  transition: border-color .15s;
}
#fav-search:focus { border-color: var(--accent); }
#fav-search-clear {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-muted);
  display: none;
  padding: 2px;
  line-height: 1;
}
#fav-search-clear:hover { color: var(--text); }

/* ── Tag cloud ────────────────────────────────────────────────── */
.fav-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
}
.fav-card-label {
  font-size: 11px; /* Aligné sur les métadonnées de l'agenda */
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-family: var(--font-ui);
}
#fav-tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.fav-tag {
  display: inline-block;
  background: rgba(91, 106, 240, 0.15);
  color: var(--accent2);
  font-size: 12px; /* Aligné sur la taille des .tag des notes */
  padding: 2px 7px;
  border-radius: 10px;
  cursor: pointer;
  transition: filter .15s, background .15s;
  max-width: 150px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  font-family: var(--font-ui);
}
.fav-tag:hover { filter: brightness(1.2); }

/* ── Section bookmarks ────────────────────────────────────────── */
#fav-bookmarks-section {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 10px 14px;
  gap: 0;
  font-family: var(--font-ui);
}
#fav-bookmarks-section:not(.fav-editing) #fav-root-target { display: none; }

.fav-tree-header {
  display: flex;
  align-items: center;
  background: var(--accent);
  color: #fff;
  padding: 8px 10px;
  border-radius: var(--radius) var(--radius) 0 0;
  gap: 6px;
  flex-shrink: 0;
}
.fav-tree-header span {
  font-size: 14px; /* Aligné sur .notes-header-title */
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex: 1;
}
.fav-tree-header .fav-action-btn {
  color: rgba(255,255,255,0.85);
}
.fav-tree-header .fav-action-btn:hover {
  opacity: 1;
  background: rgba(255,255,255,0.15);
}

.fav-edit-hidden .fav-edit-action { display: none !important; }
#fav-bookmarks-section:not(.fav-editing) .fav-header-edit-action { display: none; }

#fav-tree {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

#fav-root-target {
  padding: 7px 10px;
  font-size: 12px; /* Ajusté harmonieusement */
  color: var(--text-muted);
  text-align: center;
  border-bottom: 1px dashed var(--border);
  background: var(--surface);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  transition: background .15s;
  flex-shrink: 0;
}
#fav-root-target.fav-drag-over {
  background: rgba(91,106,240,0.10);
}

/* ── Tree nodes ───────────────────────────────────────────────── */
#fav-tree-content details {
  border-left: 2px solid var(--border);
  margin-left: 10px;
}
#fav-tree-content details[open] {
  border-left-color: var(--accent);
}
#fav-tree-content summary {
  padding: 7px 8px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  list-style: none;
  color: var(--text);
  font-size: 13px; /* Aligné sur la taille des titres de cartes de notes */
  font-family: var(--font-ui);
  transition: background .12s;
}
#fav-tree-content summary:hover { background: rgba(255,255,255,0.04); }
#fav-tree-content summary::-webkit-details-marker { display: none; }

.fav-bookmark-item {
  display: flex;
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  align-items: center;
  font-size: 13px; /* Aligné sur le contenu des listes de l'agenda */
  font-family: var(--font-ui);
  transition: background .12s;
}
.fav-bookmark-item:hover { background: rgba(255,255,255,0.04); }
.fav-bookmark-item:last-child { border-bottom: none; }

.fav-favicon {
  width: 14px; height: 14px;
  border-radius: 3px;
  margin-right: 5px;
  flex-shrink: 0;
  object-fit: contain;
  opacity: 0.85;
}
.fav-favicon-fallback {
  width: 14px; height: 14px;
  margin-right: 5px;
  flex-shrink: 0;
  font-size: 12px;
  line-height: 14px;
  text-align: center;
}
.fav-col-site {
  flex: 0 0 auto;
  width: 185px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
}
.fav-col-site a {
  text-decoration: none;
  color: var(--accent);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fav-col-site a:hover { text-decoration: underline; }
.fav-col-tags {
  flex: 3;
  display: flex;
  gap: 3px;
  margin: 0 8px;
  overflow: hidden;
  white-space: nowrap;
  mask-image: linear-gradient(to right, black 85%, transparent 100%);
  -webkit-mask-image: linear-gradient(to right, black 85%, transparent 100%);
}
.fav-col-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

/* ── Action buttons ───────────────────────────────────────────── */
.fav-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  opacity: 0.55;
  color: var(--text);
  width: 24px; height: 24px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .15s, background .12s;
  border-radius: 5px;
  flex-shrink: 0;
}
.fav-action-btn:hover { opacity: 1; background: rgba(255,255,255,0.06); }

.fav-btn-key.fav-has-cred { color: #f59e0b; opacity: 0.9; }
.fav-cred-copy { display: none; }
.fav-cred-copy.fav-has-cred { display: flex; }

/* ── Edit inline box ─────────────────────────────────────────── */
.fav-edit-box {
  display: flex;
  gap: 5px;
  padding: 7px 8px;
  background: var(--accent2);
  border-radius: var(--radius);
  width: 100%;
  align-items: center;
  margin: 4px 0;
  flex-wrap: wrap;
}
.fav-edit-box input {
  flex: 1;
  min-width: 80px;
  padding: 5px 7px;
  border: none;
  border-radius: 4px;
  font-size: 13px; /* Aligné sur .form-input de l'agenda */
  outline: none;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-ui);
}
.fav-edit-box button {
  flex-shrink: 0;
  padding: 5px 9px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 700;
  font-size: 13px; /* Aligné sur la taille globale des boutons */
  background: var(--surface);
  color: var(--accent2);
  font-family: var(--font-ui);
}

/* ── Drag & drop ─────────────────────────────────────────────── */
.fav-drag-over {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
  background: rgba(91,106,240,0.06) !important;
}
#fav-tree-content summary[draggable="true"] { cursor: grab; }
#fav-tree-content summary[draggable="true"]:active { cursor: grabbing; }

/* ── Section dossiers partagés ────────────────────────────────── */
#fav-shared-section {
  margin-top: 14px;
  flex-shrink: 0;
  font-family: var(--font-ui);
}
.fav-shared-header {
  display: flex;
  align-items: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 7px 10px;
  border-radius: var(--radius) var(--radius) 0 0;
  gap: 8px;
  font-size: 12px; /* Harmonisé */
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.fav-shared-user-block {
  border: 1px solid var(--border);
  border-top: none;
}
.fav-shared-user-block:last-child {
  border-radius: 0 0 var(--radius) var(--radius);
}
.fav-shared-user-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  font-size: 13px; /* Aligné sur la taille de l'agenda */
  font-weight: 600;
  color: var(--text-muted);
}
.fav-shared-user-label img {
  width: 18px; height: 18px;
  border-radius: 50%;
  object-fit: cover;
}
.fav-shared-tree {
  background: var(--surface);
  max-height: 280px;
  overflow-y: auto;
}
.fav-shared-tree details {
  border-left: 2px solid var(--border);
  margin-left: 10px;
}
.fav-shared-tree summary {
  padding: 6px 8px;
  cursor: pointer;
  list-style: none;
  color: var(--text);
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  transition: background .12s;
  font-size: 13px; /* Égalisé avec l'arbre principal */
  font-family: var(--font-ui);
}
.fav-shared-tree summary:hover { background: rgba(255,255,255,0.04); }
.fav-shared-tree summary::-webkit-details-marker { display: none; }
.fav-shared-bm {
  display: flex;
  align-items: center;
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 13px; /* Égalisé */
  gap: 5px;
  transition: background .12s;
}
.fav-shared-bm:hover { background: rgba(255,255,255,0.04); }
.fav-shared-bm a {
  text-decoration: none;
  color: var(--accent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fav-shared-bm a:hover { text-decoration: underline; }
.fav-share-btn {
  font-size: 12px; /* Harmonisé sur le bouton secondaire */
  padding: 2px 7px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  margin-left: auto;
  transition: all .15s;
  white-space: nowrap;
  flex-shrink: 0;
  font-family: var(--font-ui);
}
.fav-share-btn:hover { background: var(--surface2); color: var(--text); }
.fav-share-btn.fav-shared-active {
  background: rgba(91,106,240,0.15);
  color: var(--accent);
  border-color: var(--accent);
}

/* ── Overlays / Modaux ────────────────────────────────────────── */
.fav-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: flex-start;
  justify-content: center;
  z-index: 10000;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(2px);
  font-family: var(--font-ui);
}
.fav-overlay.active { display: flex; }

.fav-modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  width: calc(100% - 40px);
  max-width: 420px;
  max-height: 85vh;
  overflow-y: auto;
  animation: favSlideTop .25s ease-out;
  margin: 20px auto 0;
  box-sizing: border-box;
}
@keyframes favSlideTop {
  from { opacity: 0; transform: translateY(-16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fav-modal-box h3 {
  margin: 0 0 14px;
  font-size: 16px; /* Ajusté sur les h2 de modales de l'agenda */
  color: var(--text);
  font-weight: 700;
}
.fav-modal-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px; /* Ajusté sur le standard .form-input */
  background: var(--surface2);
  color: var(--text);
  outline: none;
  font-family: var(--font-ui);
  margin-bottom: 10px;
}
.fav-modal-input:focus { border-color: var(--accent); }
.fav-modal-input.fav-has-eye { padding-right: 42px; }

.fav-modal-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: block;
  margin-bottom: 4px;
}
.fav-modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.fav-mbtn {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: var(--radius);
  font-size: 13px; /* Parfaitement identique à .btn */
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font-ui);
  transition: opacity .15s, transform .1s;
}
.fav-mbtn:active { transform: scale(0.97); }
.fav-mbtn-primary { background: var(--accent);  color: #fff; }
.fav-mbtn-danger  { background: var(--danger);  color: #fff; }
.fav-mbtn-accent  { background: var(--accent2); color: #fff; }
.fav-mbtn-ghost   { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }

/* ── Confirm modal ────────────────────────────────────────────── */
#fav-confirm-box { text-align: center; }
#fav-confirm-msg {
  margin: 0 0 18px;
  font-size: 13px; /* Aligné sur les textes de description */
  color: var(--text);
  white-space: pre-line;
}

/* ── Credentials modal ────────────────────────────────────────── */
.fav-cred-site {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fav-cred-field-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
  width: 100%;
}
.fav-cred-input-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.fav-cred-input-row input,
.fav-cred-input-row .fav-modal-input {
  flex: 1;
  min-width: 0;
  padding: 8px 36px 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px; /* Standardisé */
  background: var(--surface2);
  color: var(--text);
  outline: none;
  font-family: var(--font-ui);
  margin-bottom: 0;
}
.fav-cred-input-row input:focus,
.fav-cred-input-row .fav-modal-input:focus { border-color: var(--accent); }
.fav-cred-input-row .fav-pwd-field {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
}
.fav-cred-copy-btn {
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 13px; /* Standardisé */
  padding: 5px 8px;
  border-radius: var(--radius);
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
  font-family: var(--font-ui);
}
.fav-cred-copy-btn:hover { background: var(--surface2); color: var(--text); }

/* ── Pwd field with eye ───────────────────────────────────────── */
.fav-pwd-field {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}
.fav-pwd-field .fav-modal-input { margin-bottom: 0; }
.fav-eye-btn {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 2px;
  color: var(--text-muted);
}
.fav-eye-btn:hover { color: var(--text); }

/* ── Masstag / Group modal ────────────────────────────────────── */
#fav-masstag-folder-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
#fav-change-pwd-error,
#fav-unlock-error {
  color: var(--danger);
  font-size: 12px;
  margin-top: 6px;
  min-height: 18px;
}

/* ── Hidden ───────────────────────────────────────────────────── */
.fav-hidden { display: none !important; }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  .fav-col-site {
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
  }
  .fav-col-tags {
    flex: 0 1 auto;
    max-width: 80px;
    min-width: 0;
  }
  .fav-col-actions { flex: none; width: auto; }
  .fav-modal-box { max-width: calc(100% - 24px); margin: 12px auto 0; }
  .fav-data-bar .btn span { display: none; }
}