/* ============================================================
   Craft Tries — Styles v1.1
   ============================================================ */

:root {
  --ct-primary:      #6c3fc5;
  --ct-primary-dark: #5530a3;
  --ct-accent:       #f5b800;
  --ct-text:         #1a1a2e;
  --ct-muted:        #6b7280;
  --ct-border:       #e2e8f0;
  --ct-bg:           #ffffff;
  --ct-radius:       8px;
  --ct-shadow:       0 4px 20px rgba(0,0,0,.15);
  --ct-transition:   .25s ease;
  --ct-drawer-z:     9999;
}

.craft-tries *,
.craft-tries *::before,
.craft-tries *::after { box-sizing: border-box; }

/* ── Compteur ─────────────────────────────────────────────── */
.ct-count { font-size: .85rem; color: var(--ct-muted); }
.ct-count-num { font-weight: 600; color: var(--ct-text); }

/* ── Prix range (partagé) ─────────────────────────────────── */
.ct-price-range { display: flex; align-items: center; gap: 8px; }
.ct-price-range input {
  width: 0; flex: 1;
  padding: 9px 12px;
  border: 1.5px solid var(--ct-border);
  border-radius: var(--ct-radius);
  font-size: .9rem;
  color: var(--ct-text);
  background: #f8f9fa;
  transition: border-color var(--ct-transition);
}
.ct-price-range input:focus { outline: none; border-color: var(--ct-primary); background: #fff; }
.ct-price-range span { color: var(--ct-muted); font-weight: 600; flex-shrink: 0; }

/* ── Spinner ─────────────────────────────────────────────── */
.ct-loading-bar { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--ct-muted); }
.ct-spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid var(--ct-border); border-top-color: var(--ct-primary);
  border-radius: 50%; animation: ct-spin .7s linear infinite;
}
@keyframes ct-spin { to { transform: rotate(360deg); } }

/* ============================================================
   MOBILE — [craft_tries_mobile]
   ============================================================ */

.craft-tries-mobile {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 8px 0;
}
.ct-mobile-top { display: flex; align-items: center; justify-content: space-between; width: 100%; gap: 12px; }

/* Bouton */
.ct-mobile-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 18px;
  background: var(--ct-primary); color: #fff;
  border: none; border-radius: 50px;
  font-size: .92rem; font-weight: 600; cursor: pointer;
  transition: background var(--ct-transition); position: relative;
}
.ct-mobile-btn:hover { background: var(--ct-primary-dark); }
.ct-active-badge {
  position: absolute; top: -5px; right: -5px;
  background: var(--ct-accent); color: #000;
  border-radius: 50%; width: 18px; height: 18px;
  font-size: .7rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* Overlay */
.ct-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: calc(var(--ct-drawer-z) - 1);
  backdrop-filter: blur(2px);
}
.ct-overlay.is-open { display: block; }

/* Drawer */
.ct-drawer {
  position: fixed; bottom: 0; left: 0; right: 0;
  z-index: var(--ct-drawer-z);
  background: var(--ct-bg);
  border-radius: 16px 16px 0 0;
  transform: translateY(100%);
  transition: transform .35s cubic-bezier(.32,.72,0,1);
  display: flex; flex-direction: column; max-height: 90dvh;
}
.ct-drawer.is-open { transform: translateY(0); }

.ct-drawer-handle {
  width: 40px; height: 4px;
  background: var(--ct-border); border-radius: 4px;
  margin: 10px auto 0; flex-shrink: 0;
}
.ct-drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--ct-border); flex-shrink: 0;
}
.ct-drawer-header strong { font-size: 1rem; color: var(--ct-text); }
.ct-drawer-close {
  background: none; border: none; font-size: 1.2rem;
  cursor: pointer; color: var(--ct-muted); padding: 4px; line-height: 1;
}
.ct-drawer-body {
  overflow-y: auto; flex: 1; padding: 0 20px;
  -webkit-overflow-scrolling: touch;
}

/* Sections accordion */
.ct-section { border-bottom: 1px solid var(--ct-border); padding: 12px 0; }
.ct-section-header {
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; font-weight: 600; color: var(--ct-text); font-size: .95rem;
}
.ct-section-toggle {
  background: none; border: none; font-size: 1.1rem;
  cursor: pointer; color: var(--ct-muted);
  transform: rotate(0deg); transition: transform var(--ct-transition);
  line-height: 1; padding: 2px 4px;
}
.ct-section-toggle.is-collapsed { transform: rotate(180deg); }
.ct-section-body { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.ct-section-body.is-collapsed { display: none; }

/* Radios */
.ct-radio-label { display: flex; align-items: center; gap: 12px; padding: 10px 0; cursor: pointer; }
.ct-radio-label input[type="radio"] { display: none; }
.ct-radio-circle {
  width: 22px; height: 22px; border: 2px solid var(--ct-border);
  border-radius: 50%; flex-shrink: 0; position: relative;
  transition: border-color var(--ct-transition);
}
.ct-radio-circle::after {
  content: ''; position: absolute; inset: 3px;
  background: var(--ct-primary); border-radius: 50%;
  opacity: 0; transition: opacity var(--ct-transition);
}
.ct-radio-label input[type="radio"]:checked ~ .ct-radio-circle { border-color: var(--ct-primary); }
.ct-radio-label input[type="radio"]:checked ~ .ct-radio-circle::after { opacity: 1; }
.ct-radio-text { font-size: .93rem; color: var(--ct-text); }

/* Footer drawer */
.ct-drawer-footer {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 20px; border-top: 1px solid var(--ct-border); flex-shrink: 0;
}
.ct-reset {
  flex: 0 0 auto; padding: 12px 18px;
  background: none; border: 1.5px solid var(--ct-border);
  border-radius: 50px; font-size: .9rem; cursor: pointer;
  color: var(--ct-muted); transition: border-color var(--ct-transition), color var(--ct-transition);
}
.ct-reset:hover { border-color: var(--ct-primary); color: var(--ct-primary); }
.ct-apply {
  flex: 1; padding: 12px 20px;
  background: var(--ct-accent); color: #000;
  border: none; border-radius: 50px;
  font-size: .95rem; font-weight: 700; cursor: pointer;
  transition: background var(--ct-transition);
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.ct-apply:hover { background: #e0a800; }
.ct-apply-count { font-size: .85rem; opacity: .8; }

/* ============================================================
   DESKTOP — [craft_tries_desktop]
   ============================================================ */

.craft-tries-desktop {
  display: flex; align-items: center; gap: 20px;
  padding: 12px 20px;
  background: var(--ct-bg);
  border: 1px solid var(--ct-border);
  border-radius: var(--ct-radius);
  flex-wrap: wrap;
}

.ct-bar-controls {
  display: flex; align-items: center;
  gap: 16px; flex-wrap: wrap; flex: 1; min-width: 0;
}

.ct-bar-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }

.ct-bar-label { font-size: .85rem; color: var(--ct-muted); white-space: nowrap; }

.ct-select-wrap { position: relative; }
.ct-select-wrap::after {
  content: '▾'; position: absolute; right: 10px; top: 50%;
  transform: translateY(-50%); pointer-events: none;
  color: var(--ct-muted); font-size: .8rem;
}
.ct-sort-select {
  padding: 8px 32px 8px 12px;
  border: 1.5px solid var(--ct-border); border-radius: var(--ct-radius);
  font-size: .9rem; color: var(--ct-text); background: #fff;
  appearance: none; cursor: pointer;
  transition: border-color var(--ct-transition); min-width: 200px;
}
.ct-sort-select:focus { outline: none; border-color: var(--ct-primary); }

.ct-bar-apply {
  padding: 8px 16px;
  background: var(--ct-primary); color: #fff;
  border: none; border-radius: var(--ct-radius);
  font-size: .9rem; font-weight: 600; cursor: pointer;
  transition: background var(--ct-transition); white-space: nowrap;
}
.ct-bar-apply:hover { background: var(--ct-primary-dark); }

/* ── Responsive desktop bar ─────────────────────────────── */

/* Tablette large 900–1199px */
@media (max-width: 1199px) {
  .craft-tries-desktop { gap: 12px 16px; padding: 12px 16px; }
  .ct-bar-controls { width: 100%; }
  .ct-sort-select { min-width: 160px; }
}

/* Tablette petite 769–899px : empilement vertical */
@media (min-width: 769px) and (max-width: 899px) {
  .craft-tries-desktop { flex-direction: column; align-items: flex-start; gap: 10px; }
  .ct-bar-controls { flex-direction: column; align-items: flex-start; gap: 10px; width: 100%; }
  .ct-bar-group { width: 100%; flex-wrap: nowrap; }
  .ct-select-wrap { flex: 1; min-width: 0; }
  .ct-sort-select { flex: 1; min-width: 0; width: 100%; }
  .ct-price-range { flex: 1; }
  .ct-price-range input { flex: 1; min-width: 60px; }
  .ct-count { width: 100%; }
}

/* ============================================================
   Chargement global
   ============================================================ */
.craft-tries-loading .products,
.craft-tries-loading ul.products {
  opacity: .4; pointer-events: none; transition: opacity .2s;
}

/* ============================================================
   Responsive visibility
   ============================================================ */
@media (max-width: 768px) {
  .craft-tries-desktop { display: none; }
}
@media (min-width: 769px) {
  .craft-tries-mobile { display: none; }
}
