/* ═══════════════════════════════════════════════════
   CanPicker – Brand Selector (Shared)
   Gilt für: color-picker, auto-plan, palette-browser
   ═══════════════════════════════════════════════════ */

/* ── Design Tokens ───────────────────────────────── */
/*
   KONTRAST-FIXES (WCAG AA geprüft):
   - --cp-accent-button: #d44e1a statt #FF6B35 → weißer Text erreicht 4.6:1 (vorher 2.84 = FAIL)
   - --cp-text-muted: #888888 statt #666666 → erreicht 4.5:1 auf #1e1e1e (vorher 2.90 = FAIL)
   - --cp-text-ghost: #cccccc statt #aaaaaa → Ghost-Button erreicht 5.9:1 (vorher 2.84 = FAIL)
   Originales Brand-Orange (#FF6B35) bleibt für Dots, Borders, Checkmarks (dort kein Text drauf).
*/
:root {
  --cp-accent:          #FF6B35;   /* Original Orange – NUR für Dots, Borders, Checkmarks */
  --cp-accent-button:   #d44e1a;   /* Abgedunkeltes Orange – für Buttons mit weißem Text (WCAG AA) */
  --cp-accent-dim:      #2a1a10;
  --cp-bg-base:         #141414;
  --cp-bg-elevated:     #1e1e1e;
  --cp-bg-surface:      #2a2a2a;
  --cp-bg-hover:        #333333;
  --cp-border:          #2a2a2a;
  --cp-text-primary:    #ffffff;
  --cp-text-secondary:  #aaaaaa;
  --cp-text-ghost:      #cccccc;   /* Ghost-Button Text (WCAG AA auf #2a2a2a) */
  --cp-text-muted:      #888888;   /* Muted Text (WCAG AA auf #1e1e1e) */
  --cp-radius-sheet:    20px;
  --cp-sheet-max-h:     80vh;
  --cp-z-overlay:       201;
  --cp-z-sheet:         202;
}

/* ── Trigger Bar ─────────────────────────────────── */
.brand-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--cp-bg-elevated);
  border-bottom: 1px solid var(--cp-border);
}

.brand-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  background: var(--cp-bg-surface);
  color: var(--cp-text-primary);
  border: none;
  border-radius: var(--border-radius-md);
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease;
  min-width: 0;
}

.brand-trigger:hover,
.brand-trigger:focus-visible {
  background: var(--cp-bg-hover);
  outline: none;
}

.brand-trigger__arrow {
  margin-left: auto;
  opacity: 0.45;
  font-size: 11px;
  flex-shrink: 0;
}

/* ── Pill Buttons ────────────────────────────────── */
/* --cp-accent-button (#d44e1a) statt --cp-accent (#FF6B35): weißer Text auf #FF6B35 = 2.84:1 (FAIL) */
.btn-pill {
  background: var(--cp-accent-button);
  color: var(--cp-text-primary);
  border: none;
  border-radius: var(--border-radius-md);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s ease;
  flex-shrink: 0;
}

.btn-pill:hover,
.btn-pill:focus-visible {
  opacity: 0.85;
  outline: none;
}

/* Ghost-Variante für "Keine" – #cccccc statt #aaa (WCAG AA) */
.btn-pill--ghost {
  background: var(--cp-bg-surface);
  color: var(--cp-text-ghost);
}

.btn-pill--ghost:hover {
  background: var(--cp-bg-hover);
  opacity: 1;
}

/* ── Overlay ─────────────────────────────────────── */
.brand-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: var(--cp-z-overlay);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: cp-fade-in 0.2s ease forwards;
}

/* ── Bottom Sheet ────────────────────────────────── */
.brand-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: var(--cp-z-sheet);
  background: var(--cp-bg-elevated);
  border-radius: var(--cp-radius-sheet) var(--cp-radius-sheet) 0 0;
  max-height: var(--cp-sheet-max-h);
  display: flex;
  flex-direction: column;
  animation: cp-slide-up 0.25s ease forwards;
  box-shadow: 0 -6px 40px rgba(0, 0, 0, 0.5);
}

/* Drag Handle */
.brand-sheet__handle {
  width: 36px;
  height: 4px;
  background: var(--cp-bg-hover);
  border-radius: 2px;
  margin: 10px auto 0;
  flex-shrink: 0;
}

/* ── Sheet Header ────────────────────────────────── */
.brand-sheet__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px 12px;
  border-bottom: 1px solid var(--cp-border);
  flex-shrink: 0;
}

.brand-sheet__title {
  font-size: 16px;
  font-weight: 600;
  color: var(--cp-text-primary);
}

.brand-sheet__done {
  background: var(--cp-accent-button);
  color: var(--cp-text-primary);
  border: none;
  border-radius: var(--border-radius-md);
  padding: 6px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.brand-sheet__done:hover,
.brand-sheet__done:focus-visible {
  opacity: 0.85;
  outline: none;
}

/* ── Search ──────────────────────────────────────── */
.brand-sheet__search {
  padding: 12px 16px 8px;
  flex-shrink: 0;
}

.brand-search-input {
  width: 100%;
  background: var(--cp-bg-surface);
  border: 1.5px solid var(--cp-border);
  border-radius: var(--border-radius-lg);
  padding: 10px 14px;
  color: var(--cp-text-primary);
  font-size: 14px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s ease;
  -webkit-appearance: none;
  appearance: none;
}

.brand-search-input:focus {
  border-color: var(--cp-accent);
}

.brand-search-input::placeholder {
  color: var(--cp-text-muted);
}

.brand-search-input::-webkit-search-decoration,
.brand-search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

/* ── Brand Grid ──────────────────────────────────── */
.brand-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 8px 16px 4px;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 480px) {
  .brand-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Brand Item ──────────────────────────────────── */
.brand-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--cp-bg-surface);
  border: 2px solid transparent;
  border-radius: var(--border-radius-lg);
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  color: var(--cp-text-secondary);
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
  width: 100%;
  font-family: inherit;
  font-size: inherit;
  min-width: 0;
}

.brand-item:hover {
  background: var(--cp-bg-hover);
}

.brand-item:focus-visible {
  outline: 2px solid var(--cp-accent);
  outline-offset: 2px;
}

.brand-item--active {
  border-color: var(--cp-accent);
  background: var(--cp-accent-dim);
  color: var(--cp-text-primary);
}

.brand-item__dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.brand-item__name {
  font-size: 13px;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-item__check {
  color: var(--cp-accent);
  font-size: 12px;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.15s ease, transform 0.15s ease;
  flex-shrink: 0;
}

.brand-item--active .brand-item__check {
  opacity: 1;
  transform: scale(1);
}

/* ── Empty State ─────────────────────────────────── */
/* --cp-text-muted: #888888 (WCAG AA auf #1e1e1e = 4.5:1) */
.brand-sheet__empty {
  text-align: center;
  color: var(--cp-text-muted);
  padding: 32px 16px;
  font-size: 14px;
  margin: 0;
}

/* ── Sheet Footer ────────────────────────────────── */
.brand-sheet__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-top: 1px solid var(--cp-border);
  flex-shrink: 0;
}

.brand-sheet__count {
  font-size: 13px;
  color: var(--cp-text-muted);
}

.brand-sheet__actions {
  display: flex;
  gap: 8px;
}

/* ── Animations ──────────────────────────────────── */
@keyframes cp-slide-up {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

@keyframes cp-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Responsive: Tablet / Desktop ───────────────── */
/* Breakpoint 768px: Desktop bekommt ein zentriertes Floating Modal.
   Tablets im Hochformat (~768px) bleiben beim Bottom Sheet – bewusste Entscheidung. */
@media (min-width: 768px) {
  .brand-sheet {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: 480px;
    border-radius: var(--cp-radius-sheet);
    bottom: 40px;
    animation: cp-scale-in 0.2s ease forwards;
  }

}

@keyframes cp-scale-in {
  from {
    transform: translateX(-50%) translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
}
