/* ==========================================================================
   TovTalk Reusable Components
   TikTok flat design — minimal shadows, clean borders, soft rounded corners.
   All values reference CSS custom properties from tokens.css.
   ========================================================================== */

/* ==========================================================================
   1. Material Symbols
   ========================================================================== */

.material-symbols-rounded {
  font-family: 'Material Symbols Rounded';
  font-size: var(--icon-md);
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  display: inline-block;
  vertical-align: middle;
  user-select: none;
}

.icon-filled {
  font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.icon-sm { font-size: var(--icon-sm); }
.icon-lg { font-size: var(--icon-lg); }
.icon-xl { font-size: var(--icon-xl); }

/* ==========================================================================
   2. Buttons
   ========================================================================== */

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--overlay-light);
  color: var(--text-primary);
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-button);
  cursor: pointer;
  font-size: var(--text-body-md);
  font-weight: var(--weight-medium);
  transition:
    transform var(--duration-fast) var(--ease-standard),
    background var(--duration-fast) var(--ease-standard),
    border-color var(--duration-fast) var(--ease-standard);
  min-height: var(--btn-height-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
}

.btn:hover {
  background: var(--overlay-medium);
}

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

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

/* -- Variants -- */

.btn-primary {
  background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
  border-color: transparent;
  color: var(--text-on-brand);
}

.btn-primary:hover {
  filter: brightness(1.1);
}

.btn-secondary {
  border-color: var(--brand);
  color: var(--brand);
  background: transparent;
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
}

.btn-danger {
  border-color: var(--error);
  color: var(--error);
  background: transparent;
}

/* -- Sizes -- */

.btn-sm {
  min-height: var(--btn-height-sm);
  padding: var(--space-xxs) var(--space-sm);
  font-size: var(--text-body-sm);
}

.btn-lg {
  min-height: var(--btn-height-lg);
  padding: var(--space-sm) var(--space-lg);
  font-size: var(--text-body-lg);
}

.btn-full {
  width: 100%;
}

/* ==========================================================================
   3. Cards
   ========================================================================== */

.card {
  background: var(--surface-elevated);
  border-radius: var(--radius-card);
  padding: var(--card-padding);
}

.card-flat {
  box-shadow: none;
}

/* ==========================================================================
   4. Inputs
   ========================================================================== */

.input {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  color: var(--text-primary);
  font-size: var(--text-body-md);
  outline: none;
  transition: border-color var(--duration-fast);
}

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

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

.textarea {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  color: var(--text-primary);
  font-size: var(--text-body-md);
  outline: none;
  transition: border-color var(--duration-fast);
  min-height: 80px;
  resize: vertical;
}

.textarea:focus {
  border-color: var(--brand);
}

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

/* ==========================================================================
   5. Avatars
   ========================================================================== */

.avatar {
  border-radius: var(--radius-full);
  object-fit: cover;
  display: block;
  background: var(--bg-secondary);
}

.avatar-xs  { width: var(--avatar-xs);  height: var(--avatar-xs); }
.avatar-sm  { width: var(--avatar-sm);  height: var(--avatar-sm); }
.avatar-md  { width: var(--avatar-md);  height: var(--avatar-md); }
.avatar-lg  { width: var(--avatar-lg);  height: var(--avatar-lg); }
.avatar-xl  { width: var(--avatar-xl);  height: var(--avatar-xl); }
.avatar-xxl { width: var(--avatar-xxl); height: var(--avatar-xxl); }
.avatar-profile { width: var(--avatar-profile); height: var(--avatar-profile); }

/* ==========================================================================
   6. Badges
   ========================================================================== */

.badge {
  min-width: 18px;
  height: 18px;
  border-radius: var(--radius-full);
  background: var(--error);
  color: white;
  font-size: var(--text-label-sm);
  font-weight: var(--weight-semibold);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

/* ==========================================================================
   7. Skeleton Loading
   ========================================================================== */

.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-secondary) 25%,
    var(--surface-elevated) 50%,
    var(--bg-secondary) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text {
  height: 14px;
  margin-bottom: var(--space-xs);
}

.skeleton-text-short {
  width: 60%;
}

.skeleton-circle {
  border-radius: var(--radius-full);
}

/* ==========================================================================
   8. Modals / Bottom Sheets
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay-scrim);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-card {
  background: var(--surface-elevated);
  border-radius: var(--radius-xl);
  padding: var(--space-lg);
  max-width: 400px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: var(--drawer-scrim);
  z-index: 200;
}

.sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface-elevated);
  border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
  max-height: 85vh;
  overflow-y: auto;
  z-index: 201;
}

.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--text-disabled);
  border-radius: var(--radius-full);
  margin: var(--space-xs) auto var(--space-sm);
}

/* ==========================================================================
   9. Dividers
   ========================================================================== */

.divider {
  height: var(--divider-thickness);
  background: var(--border);
  margin: var(--space-xs) 0;
  border: none;
}

/* ==========================================================================
   10. Empty States
   ========================================================================== */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-xxl);
  gap: var(--space-md);
  text-align: center;
}

.empty-state-icon {
  font-size: 48px;
  color: var(--text-tertiary);
}

.empty-state-text {
  color: var(--text-secondary);
  font-size: var(--text-body-md);
}

/* ==========================================================================
   11. Toggle Switch
   ========================================================================== */

.toggle-switch {
  position: relative;
  width: 48px;
  height: 28px;
  appearance: none;
  background: var(--border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-standard);
  border: none;
  outline: none;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  background: var(--text-primary);
  border-radius: var(--radius-full);
  transition: transform var(--duration-fast) var(--ease-standard);
}

.toggle-switch:checked {
  background: var(--brand);
}

.toggle-switch:checked::after {
  transform: translateX(20px);
}

/* ==========================================================================
   12. List Items (settings-style)
   ========================================================================== */

.list-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  cursor: pointer;
  transition: background var(--duration-fast);
  min-height: var(--min-touch);
}

.list-item:hover {
  background: var(--overlay-light);
}

.list-item-icon {
  color: var(--text-secondary);
  flex-shrink: 0;
}

.list-item-label {
  flex: 1;
  font-size: var(--text-body-md);
  color: var(--text-primary);
}

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

.list-item-chevron {
  color: var(--text-tertiary);
}

.list-item-danger .list-item-label {
  color: var(--error);
}

.list-item-danger .list-item-icon {
  color: var(--error);
}

/* ==========================================================================
   13. Grids (thumbnail grids)
   ========================================================================== */

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
}

.grid-5 {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 2px;
}

.grid-banner-row {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 8px 0;
}

.grid-banner-row iframe {
    border: none;
    border-radius: 8px;
    height: 80px;
    flex: 1;
    max-width: 300px;
}

.grid-item {
  aspect-ratio: 15 / 20;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--surface-overlay);
  position: relative;
}

.grid-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ==========================================================================
   14. Accessibility
   ========================================================================== */

/* Accessibility: Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* Focus visible */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
button:focus:not(:focus-visible) {
  outline: none;
}

/* ==========================================================================
   15. Centered Form (tablet/desktop constraint)
   ========================================================================== */

.centered-form {
    max-width: 500px;
    margin: 0 auto;
    padding: 16px;
    width: 100%;
    box-sizing: border-box;
}
