/**
 * PREMIUM COMPONENTS
 * Mobile-first, clean, sophisticated
 */

/* ============================================
   CARDS - Premium style
   ============================================ */
.card {
  background: var(--bg-primary);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  padding: var(--space-6);
  transition: all var(--transition-base);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card--interactive {
  cursor: pointer;
}

.card--interactive:active {
  transform: scale(0.98);
}

.card--flat {
  box-shadow: none;
  border: 1px solid var(--border-primary);
}

.card--elevated {
  box-shadow: var(--shadow-lg);
}

/* ============================================
   BUTTONS - Clean & Premium
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-base);
  font-weight: var(--font-medium);
  line-height: 1;
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-base);
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.96);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Button variants */
.btn--primary {
  background: var(--accent-primary);
  color: var(--color-white);
}

.btn--primary:hover {
  background: var(--accent-hover);
}

.btn--secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn--secondary:hover {
  background: var(--border-secondary);
}

.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn--ghost:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn--danger {
  background: var(--color-error-500);
  color: var(--color-white);
}

.btn--danger:hover {
  background: var(--color-error-600);
}

/* Button sizes */
.btn--sm {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
}

.btn--lg {
  padding: var(--space-4) var(--space-6);
  font-size: var(--text-lg);
}

.btn--icon {
  padding: var(--space-3);
  width: 40px;
  height: 40px;
}

/* ============================================
   FLOATING ACTION BUTTON (FAB)
   ============================================ */
.fab {
  position: fixed;
  bottom: calc(var(--space-6) + var(--safe-area-inset-bottom));
  right: var(--space-4);
  width: 56px;
  height: 56px;
  background: var(--accent-primary);
  color: var(--color-white);
  border: none;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-float);
  cursor: pointer;
  z-index: var(--z-fab);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  transition: transform 140ms cubic-bezier(0.4, 0, 0.2, 1), box-shadow 140ms cubic-bezier(0.4, 0, 0.2, 1);
  -webkit-tap-highlight-color: transparent;
}

.fab:hover {
  box-shadow: var(--shadow-float-lg);
  transform: scale(1.05);
}

.fab:active {
  transform: scale(0.95);
}

.fab--extended {
  width: auto;
  padding: 0 var(--space-6);
  gap: var(--space-3);
  font-size: var(--text-base);
  font-weight: var(--font-medium);
}

/* FAB Speed Dial Menu */
.fab-menu {
  position: fixed;
  bottom: calc(88px + var(--safe-area-inset-bottom));
  right: var(--space-4);
  z-index: calc(var(--z-fab) - 1);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity 140ms cubic-bezier(0.4, 0, 0.2, 1), transform 140ms cubic-bezier(0.4, 0, 0.2, 1), visibility 140ms cubic-bezier(0.4, 0, 0.2, 1);
  will-change: opacity, transform;
}

.fab-menu.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.fab-menu__item {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
}

.fab-menu__label {
  background: var(--bg-primary);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  box-shadow: var(--shadow-md);
  white-space: nowrap;
}

.fab-menu__button {
  width: 48px;
  height: 48px;
  background: var(--bg-primary);
  color: var(--text-primary);
  border: none;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: transform 120ms cubic-bezier(0.4, 0, 0.2, 1), box-shadow 120ms cubic-bezier(0.4, 0, 0.2, 1);
  -webkit-tap-highlight-color: transparent;
}

.fab-menu__button:hover {
  box-shadow: var(--shadow-lg);
  transform: scale(1.1);
}

.fab-menu__button:active {
  transform: scale(0.95);
}

/* FAB Backdrop */
.fab-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  visibility: hidden;
  transition: opacity 140ms cubic-bezier(0.4, 0, 0.2, 1), visibility 140ms cubic-bezier(0.4, 0, 0.2, 1);
  z-index: calc(var(--z-fab) - 2);
}

.fab-backdrop.active {
  opacity: 1;
  visibility: visible;
}

/* ============================================
   INPUTS & FORMS - Clean Premium
   ============================================ */
.input,
.textarea,
.select {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-base);
  font-family: var(--font-primary);
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  transition: all var(--transition-fast);
  -webkit-appearance: none;
  appearance: none;
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-tertiary);
}

.textarea {
  min-height: 100px;
  resize: vertical;
}

.label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

/* ============================================
   BOTTOM SHEET / MODAL - Mobile Premium
   ============================================ */
.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-primary);
  border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
  box-shadow: var(--shadow-xl);
  padding: var(--space-6);
  padding-bottom: calc(var(--space-6) + var(--safe-area-inset-bottom));
  z-index: var(--z-modal);
  transform: translateY(100%);
  transition: transform 200ms cubic-bezier(0.32, 0.72, 0, 1);
  will-change: transform;
  max-height: 90vh;
  overflow-y: auto;
}

.bottom-sheet.active {
  transform: translateY(0);
}

.bottom-sheet__handle {
  width: 40px;
  height: 4px;
  background: var(--border-secondary);
  border-radius: var(--radius-full);
  margin: 0 auto var(--space-6);
}

.bottom-sheet__title {
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-6);
}

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: calc(var(--z-modal) - 1);
  opacity: 0;
  visibility: hidden;
  transition: opacity 160ms cubic-bezier(0.4, 0, 0.2, 1), visibility 160ms cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-backdrop.active {
  opacity: 1;
  visibility: visible;
}

/* ============================================
   LIST ITEMS - iOS Style
   ============================================ */
.list-item {
  display: flex;
  align-items: center;
  padding: var(--space-4);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-primary);
  cursor: pointer;
  transition: background var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.list-item:first-child {
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.list-item:last-child {
  border-bottom: none;
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

.list-item:only-child {
  border-radius: var(--radius-xl);
}

.list-item:active {
  background: var(--bg-tertiary);
}

.list-item__content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.list-item__title {
  font-size: var(--text-base);
  font-weight: var(--font-medium);
  color: var(--text-primary);
}

.list-item__subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.list-item__icon {
  font-size: 20px;
  margin-right: var(--space-3);
  color: var(--text-secondary);
}

.list-item__chevron {
  font-size: 16px;
  color: var(--text-tertiary);
  margin-left: var(--space-2);
}

/* ============================================
   BADGES & CHIPS
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.badge--primary {
  background: var(--color-primary-100);
  color: var(--color-primary-700);
}

.badge--success {
  background: var(--color-success-50);
  color: var(--color-success-600);
}

.badge--warning {
  background: var(--color-warning-50);
  color: var(--color-warning-600);
}

.badge--error {
  background: var(--color-error-50);
  color: var(--color-error-600);
}

/* ============================================
   LOADING SPINNER
   ============================================ */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-primary);
  border-top-color: var(--accent-primary);
  border-radius: var(--radius-full);
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast {
  position: fixed;
  top: calc(var(--space-4) + var(--safe-area-inset-top));
  left: var(--space-4);
  right: var(--space-4);
  background: var(--bg-primary);
  padding: var(--space-4);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-tooltip);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  transform: translateY(-120%);
  transition: transform var(--transition-slow) var(--spring);
}

.toast.active {
  transform: translateY(0);
}

.toast__icon {
  font-size: 20px;
  flex-shrink: 0;
}

.toast__message {
  flex: 1;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
}

.toast--success { border-left: 4px solid var(--color-success-500); }
.toast--error { border-left: 4px solid var(--color-error-500); }
.toast--info { border-left: 4px solid var(--color-info-500); }

/* ============================================
   RESPONSIVE - Desktop
   ============================================ */
@media (min-width: 768px) {
  .fab {
    right: var(--space-8);
    bottom: var(--space-8);
  }

  .fab-menu {
    right: var(--space-8);
    bottom: calc(var(--space-8) + 88px);
  }

  .bottom-sheet {
    left: 50%;
    transform: translate(-50%, 100%);
    max-width: 600px;
  }

  .bottom-sheet.active {
    transform: translate(-50%, 0);
  }

  .toast {
    left: 50%;
    right: auto;
    transform: translate(-50%, -120%);
    max-width: 400px;
  }

  .toast.active {
    transform: translate(-50%, 0);
  }
}

/* ============================================
   iOS TOGGLE SWITCH
   ============================================ */
.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 26px;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-track {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--border-card, #38383a);
  border-radius: 26px;
  transition: background 0.25s ease;
  cursor: pointer;
}

.toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.25s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle input:checked + .toggle-track {
  background: var(--accent, #7c5cfc);
}

.toggle input:checked + .toggle-track::after {
  transform: translateX(18px);
}

/* Toggle in a row with label */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 0;
  cursor: pointer;
}

.toggle-row .toggle-label {
  font-size: 0.875rem;
  color: var(--text-primary);
  flex: 1;
}
