/**
 * ZebraDex Design System — Components
 * Styleguide component styles
 * Theme: Holo Collector (B) + Dense variant (C)
 */

/* ============================================================
   COLOR SWATCHES
   ============================================================ */

.sg-color-swatch {
  height: 80px;
  border-radius: var(--zbd-radius-md);
  display: flex;
  align-items: flex-end;
  padding: 0.5rem;
  margin-bottom: 0.5rem;
}

.sg-color-swatch--text {
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
}

.sg-color-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--zbd-text-primary);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.sg-color-code {
  font-size: 0.8rem;
  color: var(--zbd-text-primary);
}


/* ============================================================
   TYPOGRAPHY
   ============================================================ */

.sg-kpi-value {
  font-size: 36px;
  font-weight: 700;
  color: var(--zbd-text-primary);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.sg-kpi-variation {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 0.25rem;
}

.sg-kpi-variation--positive {
  color: var(--zbd-success);
}

.sg-kpi-variation--negative {
  color: var(--zbd-danger);
}


/* ============================================================
   BUTTONS
   ============================================================ */

/* Primary */
.btn-zbd-primary {
  background: var(--zbd-accent);
  color: #000;
  font-weight: 600;
  border: none;
  border-radius: var(--zbd-radius-md);
  padding: 0.625rem 1.25rem;
  transition: all var(--zbd-transition-fast);
}

.btn-zbd-primary:hover {
  background: var(--zbd-accent-hover);
  color: #000;
  transform: translateY(-1px);
  box-shadow: var(--zbd-shadow-sm);
}

.btn-zbd-primary:active {
  transform: scale(0.98);
}

.btn-zbd-primary:disabled {
  background: #666;
  color: #999;
  cursor: not-allowed;
  transform: none;
}

/* Secondary */
.btn-zbd-secondary {
  background: transparent;
  color: var(--zbd-accent-secondary);
  border: 1.5px solid var(--zbd-accent-secondary);
  border-radius: var(--zbd-radius-md);
  padding: 0.625rem 1.25rem;
  font-weight: 500;
  transition: all var(--zbd-transition-fast);
}

.btn-zbd-secondary:hover {
  background: rgba(88, 166, 255, 0.1);
  color: var(--zbd-accent-secondary);
}

.btn-zbd-secondary:disabled {
  border-color: #444;
  color: #666;
  cursor: not-allowed;
}

/* Ghost */
.btn-zbd-ghost {
  background: transparent;
  color: var(--zbd-text-primary);
  border: none;
  padding: 0.625rem 1rem;
  font-weight: 500;
  transition: all var(--zbd-transition-fast);
  border-radius: var(--zbd-radius-sm);
}

.btn-zbd-ghost:hover {
  background: var(--zbd-surface-2);
  color: var(--zbd-text-primary);
}

.btn-zbd-ghost:disabled {
  color: #666;
  cursor: not-allowed;
}

/* Icon */
.btn-zbd-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--zbd-surface-1);
  border: 1.5px solid var(--zbd-border);
  border-radius: var(--zbd-radius-sm);
  color: var(--zbd-text-muted);
  font-size: 1.1rem;
  transition: all var(--zbd-transition-fast);
}

.btn-zbd-icon:hover {
  background: var(--zbd-surface-2);
  border-color: var(--zbd-accent);
  color: var(--zbd-accent);
}

.btn-zbd-icon--heart.active {
  background: var(--zbd-danger);
  border-color: var(--zbd-danger);
  color: #fff;
}

.btn-zbd-icon--trade.active {
  background: var(--zbd-accent);
  border-color: var(--zbd-accent);
  color: #000;
}

/* Chips */
.btn-zbd-chip {
  background: var(--zbd-surface-1);
  color: var(--zbd-text-primary);
  border: 1px solid var(--zbd-border);
  border-radius: var(--zbd-radius-pill);
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  min-height: var(--zbd-touch-min);
  transition: all var(--zbd-transition-fast);
  white-space: nowrap;
}

.btn-zbd-chip:hover {
  background: var(--zbd-surface-2);
  color: var(--zbd-text-primary);
  border-color: var(--zbd-border-light);
}

.btn-zbd-chip.active {
  background: var(--zbd-accent);
  color: #000;
  border-color: var(--zbd-accent);
  font-weight: 600;
}

/* Period Chips (segmented control style like Binance) */
.sg-period-chips {
  display: inline-flex;
  background: var(--zbd-surface-1);
  border: 1px solid var(--zbd-border);
  border-radius: var(--zbd-radius-sm);
  padding: 3px;
  gap: 2px;
}

.btn-zbd-chip-period {
  background: transparent;
  color: var(--zbd-text-muted);
  border: none;
  border-radius: 4px;
  padding: 0.375rem 0.875rem;
  font-size: 0.8rem;
  font-weight: 500;
  min-height: 32px;
  min-width: 44px;
  text-align: center;
  transition: all var(--zbd-transition-fast);
}

.btn-zbd-chip-period:hover {
  color: var(--zbd-text-primary);
  background: var(--zbd-surface-2);
}

.btn-zbd-chip-period.active {
  background: var(--zbd-accent-secondary);
  color: #fff;
}

.sg-chips-scroll {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  -webkit-overflow-scrolling: touch;
}

.sg-chips-scroll::-webkit-scrollbar {
  height: 4px;
}

.sg-chips-scroll::-webkit-scrollbar-track {
  background: var(--zbd-surface-1);
}

.sg-chips-scroll::-webkit-scrollbar-thumb {
  background: var(--zbd-border);
  border-radius: 2px;
}

/* FAB */
.btn-zbd-fab {
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--zbd-accent);
  color: #000;
  border: none;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  transition: all var(--zbd-transition-fast);
}

.btn-zbd-fab:hover {
  background: var(--zbd-accent-hover);
  color: #000;
  transform: scale(1.05);
}


/* ============================================================
   NAVIGATION PREVIEW
   ============================================================ */

.sg-mobile-preview {
  width: 320px;
  border: 2px solid var(--zbd-border);
  border-radius: 24px;
  overflow: hidden;
  background: var(--zbd-bg);
}

.sg-mobile-preview--small {
  width: 280px;
}

.sg-mobile-screen {
  display: flex;
  flex-direction: column;
  height: 400px;
}

.sg-mobile-preview--small .sg-mobile-screen {
  height: 320px;
}

.sg-mobile-content {
  flex: 1;
  overflow-y: auto;
}

.sg-bottom-nav {
  display: flex;
  background: var(--zbd-surface-1);
  border-top: 1px solid var(--zbd-border);
  padding: 0.5rem 0;
}

.sg-bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem;
  text-decoration: none;
  color: var(--zbd-text-muted);
  font-size: 0.65rem;
  transition: color var(--zbd-transition-fast);
}

.sg-bottom-nav-item i {
  font-size: 1.25rem;
}

.sg-bottom-nav-item:hover,
.sg-bottom-nav-item.active {
  color: var(--zbd-accent);
}

.sg-bottom-nav-item--more {
  color: var(--zbd-text-muted);
}

/* Bottom Sheet */
.sg-sheet-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1;
}

.sg-bottom-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--zbd-surface-1);
  border-radius: 16px 16px 0 0;
  padding: 0.5rem 0 1rem;
  z-index: 2;
}

.sg-bottom-sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--zbd-border-light);
  border-radius: 2px;
  margin: 0 auto 0.75rem;
}

.sg-bottom-sheet-content {
  padding: 0 0.5rem;
}

.sg-sheet-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--zbd-text-primary);
  text-decoration: none;
  border-radius: var(--zbd-radius-sm);
  transition: background var(--zbd-transition-fast);
}

.sg-sheet-item:hover {
  background: var(--zbd-surface-2);
  color: var(--zbd-text-primary);
}

.sg-sheet-item i {
  font-size: 1.25rem;
  color: var(--zbd-text-muted);
  width: 24px;
  text-align: center;
}


/* ============================================================
   FINANCE COMPONENTS
   ============================================================ */

.zbd-hero-kpi {
  background: linear-gradient(135deg, var(--zbd-surface-1) 0%, var(--zbd-surface-2) 100%);
  border: 1px solid var(--zbd-border);
  border-radius: 20px;
  padding: 2rem;
  text-align: center;
}

.zbd-hero-kpi-label {
  color: var(--zbd-text-muted);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.zbd-hero-kpi-value {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--zbd-text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

@media (min-width: 768px) {
  .zbd-hero-kpi-value {
    font-size: 3rem;
  }
}

.zbd-hero-kpi-variation {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 0.5rem;
}

.zbd-hero-kpi-variation--positive {
  color: var(--zbd-success);
}

.zbd-hero-kpi-variation--negative {
  color: var(--zbd-danger);
}

.zbd-hero-kpi-stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--zbd-border);
}

.zbd-hero-kpi-stat {
  text-align: center;
}

.zbd-hero-kpi-stat-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--zbd-text-primary);
}

.zbd-hero-kpi-stat-label {
  font-size: 0.8rem;
  color: var(--zbd-text-muted);
}

/* Portfolio List */
.zbd-portfolio-list {
  background: var(--zbd-surface-1);
  border: 1px solid var(--zbd-border);
  border-radius: var(--zbd-radius-lg);
  overflow: hidden;
}

.zbd-portfolio-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--zbd-border);
  transition: background var(--zbd-transition-fast);
}

.zbd-portfolio-row:last-child {
  border-bottom: none;
}

.zbd-portfolio-row:hover {
  background: var(--zbd-surface-2);
}

.zbd-portfolio-thumb {
  width: 40px;
  height: 56px;
  object-fit: cover;
  border-radius: var(--zbd-radius-sm);
}

.zbd-portfolio-info {
  flex: 1;
  min-width: 0;
}

.zbd-portfolio-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.zbd-portfolio-code {
  font-size: 0.8rem;
  color: var(--zbd-text-muted);
}

.zbd-portfolio-qty {
  color: var(--zbd-text-muted);
  font-size: 0.9rem;
  min-width: 30px;
  text-align: center;
}

.zbd-portfolio-price {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 70px;
  text-align: right;
}

.zbd-portfolio-change {
  font-weight: 600;
  font-size: 0.9rem;
  min-width: 60px;
  text-align: right;
}

.zbd-portfolio-change--positive {
  color: var(--zbd-success);
}

.zbd-portfolio-change--negative {
  color: var(--zbd-danger);
}

/* Chart Placeholder */
.zbd-chart-placeholder {
  background: var(--zbd-surface-1);
  border: 1px solid var(--zbd-border);
  border-radius: var(--zbd-radius-lg);
  height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.zbd-chart-line {
  position: absolute;
  bottom: 40%;
  left: 10%;
  right: 10%;
  height: 2px;
  background: linear-gradient(90deg, var(--zbd-success) 0%, var(--zbd-success) 40%, var(--zbd-danger) 60%, var(--zbd-success) 100%);
  border-radius: 1px;
  opacity: 0.6;
}

.zbd-chart-label {
  color: var(--zbd-text-muted);
  font-size: 0.9rem;
  z-index: 1;
}


/* ============================================================
   TABLES
   ============================================================ */

.table-zbd {
  --bs-table-bg: transparent;
  --bs-table-color: var(--zbd-text-primary);
  margin-bottom: 0;
}

.table-zbd thead th {
  background: var(--zbd-surface-2);
  color: var(--zbd-text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.75rem 1rem;
  border: none;
}

.table-zbd tbody td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--zbd-border);
  vertical-align: middle;
}

.table-zbd tbody tr:hover td {
  background: var(--zbd-surface-2);
}

.zbd-table-thumb {
  width: 32px;
  height: 44px;
  object-fit: cover;
  border-radius: 4px;
}

/* Dense Table */
.table-zbd--dense thead th {
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
}

.table-zbd--dense tbody td {
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
}

.table-zbd--dense .sortable {
  cursor: pointer;
  user-select: none;
  padding-right: 1.5rem !important;
  position: relative;
}

.table-zbd--dense .sortable:hover {
  color: var(--zbd-text-primary);
}

.table-zbd--dense .sortable::after {
  content: '↕';
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.65rem;
  opacity: 0.4;
}

.table-zbd-footer td {
  background: var(--zbd-surface-2);
  border-top: 2px solid var(--zbd-border-light);
}

.zbd-dense-item {
  display: flex;
  flex-direction: column;
}

.zbd-dense-name {
  font-weight: 500;
}

.zbd-dense-code {
  font-size: 0.75rem;
  color: var(--zbd-text-muted);
}

.zbd-var-sm {
  font-size: 0.8rem;
  font-weight: 500;
}

.zbd-var-sm--pos {
  color: var(--zbd-success);
}

.zbd-var-sm--neg {
  color: var(--zbd-danger);
}

.zbd-var-sm--neu {
  color: var(--zbd-text-muted);
}

/* Scroll wrapper - no fixed fade, use shadow on sticky col instead */
.zbd-table-scroll-wrapper {
  position: relative;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--zbd-border) transparent;
}

.zbd-table-scroll-wrapper::-webkit-scrollbar {
  height: 6px;
}

.zbd-table-scroll-wrapper::-webkit-scrollbar-track {
  background: var(--zbd-surface-1);
  border-radius: 3px;
}

.zbd-table-scroll-wrapper::-webkit-scrollbar-thumb {
  background: var(--zbd-border-light);
  border-radius: 3px;
}

.zbd-table-scroll-wrapper::-webkit-scrollbar-thumb:hover {
  background: var(--zbd-text-muted);
}

/* Sticky first column on mobile */
@media (max-width: 767.98px) {

  .table-zbd--dense th:first-child,
  .table-zbd--dense td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: #0A0A0A !important;
    box-shadow: 4px 0 8px rgba(0, 0, 0, 0.5);
  }

  .table-zbd--dense thead th:first-child {
    background: var(--zbd-surface-2) !important;
  }

  .table-zbd--dense tbody tr:hover td:first-child {
    background: #151515 !important;
  }
}

/* Variation */
.zbd-variation {
  font-size: 0.8rem;
  font-weight: 600;
}

.zbd-variation--positive {
  color: var(--zbd-success);
}

.zbd-variation--negative {
  color: var(--zbd-danger);
}

.zbd-variation--neutral {
  color: var(--zbd-text-muted);
}


/* ============================================================
   MOBILE CARDS
   ============================================================ */

.zbd-mobile-card {
  display: flex;
  gap: 0.75rem;
  background: var(--zbd-surface-1);
  border: 1px solid var(--zbd-border);
  border-radius: var(--zbd-radius-md);
  padding: 0.75rem;
}

.zbd-mobile-card-thumb {
  width: 40px;
  height: 56px;
  object-fit: cover;
  border-radius: var(--zbd-radius-sm);
  flex-shrink: 0;
}

.zbd-mobile-card-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.zbd-mobile-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.zbd-mobile-card-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.zbd-mobile-card-code {
  font-size: 0.75rem;
  color: var(--zbd-text-muted);
}

.zbd-mobile-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.zbd-mobile-card-price {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}


/* ============================================================
   ALERTS & BADGES
   ============================================================ */

.alert-zbd-success {
  background: var(--zbd-success-bg);
  border: 1px solid var(--zbd-success);
  color: var(--zbd-success);
  border-radius: var(--zbd-radius-md);
}

.alert-zbd-danger {
  background: var(--zbd-danger-bg);
  border: 1px solid var(--zbd-danger);
  color: var(--zbd-danger);
  border-radius: var(--zbd-radius-md);
}

.alert-zbd-warning {
  background: var(--zbd-warning-bg);
  border: 1px solid var(--zbd-warning);
  color: var(--zbd-warning);
  border-radius: var(--zbd-radius-md);
}

.alert-zbd-info {
  background: var(--zbd-info-bg);
  border: 1px solid var(--zbd-info);
  color: var(--zbd-info);
  border-radius: var(--zbd-radius-md);
}

.badge-zbd-success {
  background: var(--zbd-success);
  color: #fff;
}

.badge-zbd-danger {
  background: var(--zbd-danger);
  color: #fff;
}

.badge-zbd-warning {
  background: var(--zbd-warning);
  color: #000;
}

.badge-zbd-info {
  background: var(--zbd-info);
  color: #fff;
}

.badge-zbd-neutral {
  background: var(--zbd-text-muted);
  color: #fff;
}

.badge-zbd-accent {
  background: var(--zbd-accent);
  color: #000;
}


/* ============================================================
   FORMS
   ============================================================ */

.form-control-zbd,
.form-select-zbd {
  background: var(--zbd-surface-1);
  border: 1px solid var(--zbd-border);
  border-radius: var(--zbd-radius-md);
  color: var(--zbd-text-primary);
  padding: 0.625rem 1rem;
  font-size: 0.95rem;
  min-height: var(--zbd-touch-min);
  transition: all var(--zbd-transition-fast);
}

.form-control-zbd:focus,
.form-select-zbd:focus {
  background: var(--zbd-surface-1);
  border-color: var(--zbd-accent-secondary);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.2);
  color: var(--zbd-text-primary);
  outline: none;
}

.form-control-zbd::placeholder {
  color: var(--zbd-text-muted);
}

.form-control-zbd:disabled {
  background: var(--zbd-surface-2);
  color: var(--zbd-text-muted);
  cursor: not-allowed;
}

.form-control-zbd.is-invalid {
  border-color: var(--zbd-danger);
}

.form-control-zbd.is-invalid:focus {
  box-shadow: 0 0 0 3px rgba(248, 81, 73, 0.2);
}

.form-select-zbd {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%238B949E' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 16px 12px;
  padding-right: 2.5rem;
}

.zbd-focus-preview {
  border-color: var(--zbd-accent-secondary);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.2);
}

.zbd-search-wrapper {
  position: relative;
}

.zbd-search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--zbd-text-muted);
  pointer-events: none;
}

.zbd-search-wrapper .form-control-zbd {
  padding-left: 2.75rem;
}

.zbd-filter-bar {
  background: var(--zbd-surface-1);
  border: 1px solid var(--zbd-border);
  border-radius: var(--zbd-radius-lg);
  padding: 0.75rem;
}

.zbd-filter-bar-scroll {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.25rem;
}

.form-check-zbd .form-check-input {
  background-color: var(--zbd-surface-1);
  border-color: var(--zbd-border);
  width: 1.25rem;
  height: 1.25rem;
}

.form-check-zbd .form-check-input:checked {
  background-color: var(--zbd-accent);
  border-color: var(--zbd-accent);
}

.form-check-zbd .form-check-input:focus {
  box-shadow: 0 0 0 3px rgba(255, 225, 0, 0.2);
}

.form-check-zbd .form-check-label {
  color: var(--zbd-text-primary);
  margin-left: 0.25rem;
}


/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 767.98px) {
  .zbd-hero-kpi {
    padding: 1.5rem;
  }

  .zbd-hero-kpi-stats {
    gap: 1rem;
  }

  .zbd-portfolio-row {
    flex-wrap: wrap;
  }

  .zbd-portfolio-info {
    flex-basis: calc(100% - 60px);
  }

  .zbd-portfolio-qty,
  .zbd-portfolio-price,
  .zbd-portfolio-change {
    flex: 1;
    text-align: center;
    margin-top: 0.5rem;
  }
}


/* FAB Overlay */
.btn-zbd-fab {
  position: absolute;
  bottom: -10px;
  right: -10px;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--zbd-accent);
  color: #000;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  z-index: 20;
  transition: all 0.2s ease;
  backdrop-filter: blur(4px);
}

.btn-zbd-fab:hover {
  transform: scale(1.1);
  background: var(--zbd-accent-hover);
  border-color: rgba(255, 255, 255, 0.4);
  color: #000;
}

.btn-zbd-fab.added {
  background: transparent;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
}

.btn-zbd-fab.added:hover {
  background: transparent;
  transform: scale(1.1);
}

.btn-zbd-fab.added img {
  width: 32px;
  height: 32px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.btn-zbd-fab img {
  border-radius: 50%;
  object-fit: cover;
}