/* KOVAT Theme Bridge — Connect design system tokens to v19 theme */
:root { --accent-blue: var(--theme-primary, #e63946); --kovat-accent-blue: var(--theme-primary, #e63946); }
/* ══════════════════════════════════════════════════════════════
   KOVAT UI Polish — Fixes resizing, theming, animations
   Loads AFTER all other CSS to override v19 !important rules
   ══════════════════════════════════════════════════════════════ */

/* ── Base page fixes ── */
html { scroll-behavior: smooth; }

/* ── BUTTONS: Override v19 16px radius → 8px per design system ── */
.nav button, .admin-link, .ghost, .danger, .primary, .v19-pill,
button.primary, button.ghost, button.danger,
.plan-card .controls button, .shop-card button,
.modal-card button, .auth-card button,
.chat-tabs button, .segmented button, .tabs button,
.trade-tabs button, .admin-tabs button,
#clipRecordBtn, #clipStopBtn,
.incoming-call-box button {
  border-radius: 8px !important;
}

/* Buttons: proper design-system colors (override v19 var(--theme-*) with --accent-*) */
button.primary, .primary, #clipRecordBtn, .clip-action-bar .primary {
  background: var(--accent-blue, #4A7AFF) !important;
  color: #fff !important;
  border: none !important;
}
button.primary:hover, .primary:hover {
  background: #5B8BFF !important;
  box-shadow: 0 4px 16px rgba(74, 122, 255, 0.35);
}

button.ghost, .ghost {
  background: transparent !important;
  color: var(--accent-blue, #4A7AFF) !important;
  border: 1px solid var(--border, #2A2A38) !important;
}
button.ghost:hover, .ghost:hover {
  background: var(--surface-raised, #1A1A22) !important;
}

button.danger, .danger, #clipStopBtn {
  background: var(--accent-red, #EF4444) !important;
  color: #fff !important;
  border: none !important;
}
button.danger:hover, .danger:hover {
  background: #F56565 !important;
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.35);
}

/* ── BUTTON ANIMATIONS: Rich hover/focus effects ── */
button, .primary, .ghost, .danger, .v19-pill,
.nav button, .admin-link, .chat-tabs button,
.segmented button, .trade-tabs button, .admin-tabs button,
.shop-card button, .plan-card button, .modal-card button,
.clip-reaction-btn, .msg-actions button,
#clipRecordBtn, #clipStopBtn, .incoming-call-box button {
  transition: transform 0.18s cubic-bezier(.34,1.56,.64,1), 
              box-shadow 0.18s ease, 
              background 0.18s ease, 
              border-color 0.18s ease, 
              opacity 0.18s ease !important;
  cursor: pointer;
}
button:hover, .primary:hover, .ghost:hover, .danger:hover, .v19-pill:hover,
.nav button:hover, .admin-link:hover, .chat-tabs button:hover,
.segmented button:hover, .trade-tabs button:hover, .admin-tabs button:hover,
.shop-card button:hover, .plan-card button:hover, .clip-reaction-btn:hover {
  transform: translateY(-2px) scale(1.02);
}

/* Active/press effect */
button:active, .primary:active, .ghost:active, .danger:active,
.nav button:active, .chat-tabs button:active {
  transform: translateY(0px) scale(0.98);
}

/* Disabled buttons */
button:disabled, .primary:disabled, .ghost:disabled, .danger:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* ── INPUTS: Design-system styling ── */
input, textarea, select, .field {
  background: var(--surface-raised, #1A1A22) !important;
  color: var(--text-primary, #F0F0F8) !important;
  border: 1px solid var(--border, #2A2A38) !important;
  border-radius: 8px !important;
  padding: 10px 14px !important;
  font-size: 15px !important;
  font-family: inherit !important;
  transition: border-color 0.18s ease, box-shadow 0.18s ease !important;
}
input:focus, textarea:focus, select:focus, .field:focus {
  border-color: var(--accent-blue, #4A7AFF) !important;
  box-shadow: 0 0 0 3px rgba(74, 122, 255, 0.15);
  outline: none;
}
input.error, textarea.error, .field.error {
  border-color: var(--accent-red, #EF4444) !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}
/* Search input: override 999px radius from v19 */
.search-wrap input {
  border-radius: 8px !important;
}

/* ── CARDS: Design-system consistency ── */
.panel, .glass, .card, .shop-card, .friend-card, .update-card, .chat-card,
.modal-card, .side-panel, .auth-card, .plan-card, .profile-stat-card,
.badge-item, .group-list-item, .clip-card, .goal-card {
  background: var(--surface, #0F0F14) !important;
  border: 1px solid var(--border, #2A2A38) !important;
  border-radius: 10px !important;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}
.shop-card:hover, .friend-card:hover, .clip-card:hover, .plan-card:hover {
  border-color: var(--accent-blue, #4A7AFF);
  box-shadow: 0 4px 20px rgba(74, 122, 255, 0.12);
  transform: translateY(-2px);
}

/* ── MODALS: Smooth entry animation ── */
.modal-overlay, .modal {
  animation: modalFadeIn 0.2s cubic-bezier(.34,1.56,.64,1);
}
.modal-card, .modal-content {
  animation: modalScaleIn 0.22s cubic-bezier(.34,1.56,.64,1);
}
@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes modalScaleIn {
  from { opacity: 0; transform: scale(0.94) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── TOASTS: Slide-in animation ── */
.toast {
  animation: toastSlideIn 0.25s cubic-bezier(.34,1.56,.64,1);
  border-radius: 8px !important;
}
@keyframes toastSlideIn {
  from { opacity: 0; transform: translateY(16px) translateX(20px); }
  to { opacity: 1; transform: translateY(0) translateX(0); }
}

/* ── NAV: Active tab indicator ── */
.nav button.active {
  position: relative;
  color: var(--accent-blue, #4A7AFF) !important;
  font-weight: 600;
}
.nav button.active::before {
  content: '';
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 3px;
  background: var(--accent-blue, #4A7AFF);
  border-radius: 0 3px 3px 0;
  animation: navIndicatorIn 0.2s ease;
}
@keyframes navIndicatorIn {
  from { transform: scaleY(0); }
  to { transform: scaleY(1); }
}

/* ── MESSAGES: Typing indicator bounce ── */
.typing-dot {
  animation: typingBounce 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ── SCROLL-TO-BOTTOM button ── */
.scroll-bottom-btn {
  animation: scrollBtnPulse 1.8s infinite;
}
@keyframes scrollBtnPulse {
  0%, 100% { box-shadow: 0 2px 8px rgba(74, 122, 255, 0.2); }
  50% { box-shadow: 0 2px 20px rgba(74, 122, 255, 0.45); }
}

/* ── BADGES: Pill animation ── */
.badge, .level-badge, .unread-pill, #chatBadge.show, #inviteCount.show, #adminBadge.show,
.profile-level-badge {
  animation: badgePopIn 0.3s cubic-bezier(.34,1.56,.64,1);
}
@keyframes badgePopIn {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ── MOBILE FIXES: Better sidebar behavior ── */
@media (max-width: 900px) {
  .app-shell { 
    overflow-y: auto !important;
  }
  .sidebar {
    max-height: 50vh !important;  /* was 42vh — more room for tabs */
    overflow-y: auto !important;
    border-bottom: 1px solid var(--border, #2A2A38);
  }
  .content {
    height: auto !important;
    min-height: 60vh !important;
  }
  .view {
    min-height: 50vh !important;
  }
  /* Clips grid: 2 columns on mobile */
  .clips-feed { 
    grid-template-columns: repeat(2, 1fr) !important; 
  }
  /* Profile page: single column */
  .profile-stats { 
    grid-template-columns: repeat(2, 1fr) !important;
  }
  /* Cards: tighter spacing */
  .cards, .shop-grid {
    gap: 10px;
  }
  /* Modal: more screen real estate */
  .modal-card {
    width: 94vw !important;
    max-height: 88vh !important;
  }
}

/* Extra small screens */
@media (max-width: 480px) {
  .clips-feed {
    grid-template-columns: 1fr !important;
  }
  .profile-stats {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .sidebar {
    max-height: 44vh !important;
    padding: 8px !important;
  }
  .content {
    padding: 8px !important;
  }
  .nav button {
    padding: 8px 10px !important;
    font-size: 13px;
  }
}

/* ── SCROLLBARS: Themed ── */
.view::-webkit-scrollbar, .sidebar::-webkit-scrollbar, .messages::-webkit-scrollbar,
.modal-card::-webkit-scrollbar, .panel::-webkit-scrollbar {
  width: 6px;
}
.view::-webkit-scrollbar-track, .sidebar::-webkit-scrollbar-track, .messages::-webkit-scrollbar-track {
  background: transparent;
}
.view::-webkit-scrollbar-thumb, .sidebar::-webkit-scrollbar-thumb, .messages::-webkit-scrollbar-thumb {
  background: var(--border, #2A2A38);
  border-radius: 3px;
  transition: background 0.2s ease;
}
.view::-webkit-scrollbar-thumb:hover {
  background: var(--accent-blue, #4A7AFF);
}

/* ── SKELETON LOADING: Pulse animation ── */
.skeleton-text, .skeleton-card, .skeleton-avatar {
  background: linear-gradient(90deg, 
    var(--surface-raised, #1A1A22) 25%, 
    var(--surface-overlay, #22222C) 50%, 
    var(--surface-raised, #1A1A22) 75%
  ) !important;
  background-size: 200% 100% !important;
  animation: skeletonShimmer 1.5s infinite !important;
  border-radius: 8px;
}
@keyframes skeletonShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── EMPTY STATES: Gentle fade-in ── */
.empty-state {
  animation: emptyFadeIn 0.4s ease;
}
@keyframes emptyFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── LINKS: Transition ── */
a {
  transition: color 0.18s ease, opacity 0.18s ease;
}
a:hover {
  opacity: 0.85;
}

/* ── CHAT BUBBLES: Micro-interaction ── */
.message {
  animation: msgSlideIn 0.25s cubic-bezier(.34,1.56,.64,1);
}
@keyframes msgSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── AVATAR: Hover glow ── */
.avatar-wrap:hover, .profile-avatar-lg:hover {
  box-shadow: 0 0 0 3px var(--accent-blue, #4A7AFF), 0 0 16px rgba(74, 122, 255, 0.3);
  transition: box-shadow 0.2s ease;
}

/* ── SHOP CARDS: Consistent styling ── */
.shop-card {
  overflow: hidden;
}
.shop-card img {
  transition: transform 0.3s ease;
}
.shop-card:hover img {
  transform: scale(1.05);
}

/* ── PROFILE OVERLAY ANIMATIONS ── */
@keyframes kovatPulse {
  0%, 100% { box-shadow: 0 0 0 2px var(--theme-primary, #ff224a), 0 0 16px var(--theme-primary, #ff224a); }
  50% { box-shadow: 0 0 0 4px var(--theme-primary, #ff224a), 0 0 28px var(--theme-primary, #ff224a); }
}
@keyframes kovatSpinGlow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
@keyframes kovatSpark {
  0%, 100% { box-shadow: 0 0 0 2px #ffbf47, 0 0 18px #ffbf47; opacity: 1; }
  50% { box-shadow: 0 0 0 5px #ffbf47, 0 0 32px #ffbf47; opacity: 0.7; }
}

/* ── TOOLTIPS ── */
[title] {
  position: relative;
}

/* ── FOCUS VISIBLE: Accessibility ── */
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent-blue, #4A7AFF);
  outline-offset: 2px;
}

/* ── CLOSE BUTTONS: Consistent styling ── */
.close-btn, .modal-header .close-btn {
  background: var(--surface-overlay, #22222C) !important;
  border: none !important;
  border-radius: 50% !important;
  width: 36px !important;
  height: 36px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 20px !important;
  color: var(--text-secondary, #9090A8) !important;
  cursor: pointer !important;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}
.close-btn:hover, .modal-header .close-btn:hover {
  background: var(--accent-red, #EF4444) !important;
  color: #fff !important;
  transform: rotate(90deg);
}

/* ── XP PROGRESS BAR: Animated fill ── */
.xp-progress-fill, .goal-bar-fill {
  transition: width 0.6s cubic-bezier(.34,1.56,.64,1) !important;
}

/* ── TAB CONTENT: Fade transition ── */
.view > div, .view > * {
  animation: tabContentIn 0.15s ease;
}
@keyframes tabContentIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ── CLIP PLAYER: Full-width on mobile ── */
@media (max-width: 600px) {
  .clip-player-modal {
    width: 100vw !important;
    max-width: 100vw !important;
    border-radius: 0 !important;
  }
  #clipPlayerContent video {
    border-radius: 0 !important;
  }
}

/* ── COMBO: Group invite/reaction highlight ── */
.reaction-chip:hover, .mention:hover {
  filter: brightness(1.2);
  transition: filter 0.15s ease;
}
