/* ==================== ENHANCED CSS with ANIMATIONS ==================== */

/* Base Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
}

/* ==================== ANIMATIONS ==================== */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(100%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

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

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

@keyframes bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

@keyframes glow {
  0%,
  100% {
    box-shadow: 0 0 5px rgba(59, 130, 246, 0.3);
  }
  50% {
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.6);
  }
}

/* ==================== PAGE TRANSITIONS ==================== */
.page {
  display: none;
  opacity: 0;
}

.page.active {
  display: block;
  animation: fadeInUp 0.4s ease forwards;
}

body {
  transition: opacity 0.16s ease, filter 0.16s ease;
}

body.page-transition-out {
  opacity: 0.9;
  filter: blur(1px);
}

@media (prefers-reduced-motion: reduce) {
  body,
  body.page-transition-out {
    transition: none !important;
    filter: none !important;
    opacity: 1 !important;
  }
}

/* ==================== STAT CARDS ==================== */
.stat-card {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  animation: fadeInUp 0.5s ease backwards;
}

.stat-card:nth-child(1) {
  animation-delay: 0.1s;
}
.stat-card:nth-child(2) {
  animation-delay: 0.2s;
}
.stat-card:nth-child(3) {
  animation-delay: 0.3s;
}
.stat-card:nth-child(4) {
  animation-delay: 0.4s;
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  border-color: #3d3d3d;
}

.stat-card .stat-icon {
  transition: transform 0.3s ease;
}

.stat-card:hover .stat-icon {
  transform: scale(1.1);
}

/* ==================== NAV LINKS ==================== */
.nav-link {
  position: relative;
  transition: all 0.2s ease;
}

/* Desktop: underline animation */
@media (min-width: 768px) {
  .nav-link::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: #3b82f6;
    transition: all 0.3s ease;
    transform: translateX(-50%);
  }

  .nav-link:hover::after,
  .nav-link.active::after {
    width: 80%;
  }
}

/* Mobile: simple dot indicator */
@media (max-width: 767px) {
  .nav-link.active::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 50%;
    width: 4px;
    height: 4px;
    background: #3b82f6;
    border-radius: 50%;
    transform: translateX(-50%);
  }
}

.nav-link.active {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
}

/* Touch feedback for mobile */
@media (hover: none) and (pointer: coarse) {
  .nav-link:active {
    transform: scale(0.95);
    transition: transform 0.1s;
  }
}

/* ==================== BUTTONS ==================== */
.btn-primary,
.btn-secondary {
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.btn-primary::before,
.btn-secondary::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition:
    width 0.6s,
    height 0.6s;
}

.btn-primary:hover::before,
.btn-secondary:hover::before {
  width: 300px;
  height: 300px;
}

.btn-primary:active,
.btn-secondary:active {
  transform: scale(0.97);
}

/* ==================== MODAL ==================== */
.modal {
  display: none;
  opacity: 0;
}

.modal.active {
  display: flex;
  animation: fadeIn 0.3s ease forwards;
}

.modal.active .modal-content {
  animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@media (min-width: 768px) {
  .modal.active .modal-content {
    animation: scaleIn 0.3s ease forwards;
  }
}

.modal-overlay {
  transition: opacity 0.3s ease;
}

/* ==================== TOAST ==================== */
.toast {
  padding: 0.875rem 1rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  animation: slideInRight 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(10px);
}

.toast.success {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #10b981;
}

.toast.error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #ef4444;
}

.toast.info {
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #3b82f6;
}

.toast.hide {
  animation: slideOutRight 0.3s ease forwards;
}

@keyframes slideOutRight {
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

/* ==================== TABLE ==================== */
.trades-table {
  animation: fadeIn 0.5s ease;
}

.trades-table tbody tr {
  transition: all 0.2s ease;
  animation: fadeInUp 0.4s ease backwards;
}

.trades-table tbody tr:nth-child(1) {
  animation-delay: 0.05s;
}
.trades-table tbody tr:nth-child(2) {
  animation-delay: 0.1s;
}
.trades-table tbody tr:nth-child(3) {
  animation-delay: 0.15s;
}
.trades-table tbody tr:nth-child(4) {
  animation-delay: 0.2s;
}
.trades-table tbody tr:nth-child(5) {
  animation-delay: 0.25s;
}

.trades-table tbody tr:hover {
  background: rgba(59, 130, 246, 0.05);
  transform: scale(1.005);
}

.trades-table td {
  padding: 0.875rem 0.5rem;
  vertical-align: middle;
}

.trades-empty-row {
  animation: none;
}

.trades-empty-row:hover {
  transform: none;
  background: transparent;
}

.trades-empty-cell::before {
  content: none !important;
}

.trades-empty-state {
  min-height: 120px;
  text-align: center;
}

/* ==================== BADGES ==================== */
.badge-long,
.badge-short,
.badge-win,
.badge-loss,
.badge-pending,
.badge-be {
  padding: 0.25rem 0.625rem;
  border-radius: 0.375rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.2s ease;
}

.badge-long {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}
.badge-short {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}
.badge-win {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}
.badge-loss {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}
.badge-pending {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}
.badge-be {
  background: rgba(107, 114, 128, 0.15);
  color: #9ca3af;
}

/* PnL colors */
.pnl-positive {
  color: #10b981;
  font-weight: 600;
}
.pnl-negative {
  color: #ef4444;
  font-weight: 600;
}

/* ==================== ACTION BUTTONS ==================== */
.action-btn {
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  border: 1px solid #2d2d2d;
  background: #1c1c1c;
  color: #f5f5f5;
  cursor: pointer;
  transition: all 0.2s ease;
}

.action-btn:hover {
  background: #252525;
  border-color: #3d3d3d;
  transform: translateY(-1px);
}

.action-btn:active {
  transform: translateY(0);
}

/* ==================== NEWS CARDS ==================== */
.news-card {
  padding: 1.25rem;
  background: linear-gradient(135deg, #1c1c1c 0%, #161616 100%);
  border: 1px solid #2d2d2d;
  border-radius: 1rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  animation: fadeInUp 0.5s ease backwards;
}

.news-card:nth-child(1) {
  animation-delay: 0.1s;
}
.news-card:nth-child(2) {
  animation-delay: 0.15s;
}
.news-card:nth-child(3) {
  animation-delay: 0.2s;
}
.news-card:nth-child(4) {
  animation-delay: 0.25s;
}
.news-card:nth-child(5) {
  animation-delay: 0.3s;
}

.news-card:hover {
  border-color: rgba(59, 130, 246, 0.3);
  transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.news-card h4 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  line-height: 1.4;
  transition: color 0.2s ease;
}

.news-card:hover h4 {
  color: #3b82f6;
}

.news-card p {
  font-size: 0.8rem;
  color: #9ca3af;
  margin-bottom: 0.75rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
}

.news-card .news-meta {
  font-size: 0.7rem;
  color: #6b7280;
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.news-card a {
  color: #3b82f6;
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.news-card a:hover {
  color: #60a5fa;
}

/* ==================== CHAT ==================== */
.chat-welcome {
  animation: fadeInUp 0.6s ease;
}

.chat-shell {
  min-height: 460px;
}

.chat-mode-switch {
  scrollbar-width: none;
}

.chat-mode-switch::-webkit-scrollbar {
  display: none;
}

.chat-suggestions button {
  min-height: 42px;
}

/* Message container - full width like ChatGPT */
.message {
  display: flex;
  padding: 1.25rem 0;
  animation: fadeInUp 0.3s ease;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.message:last-child {
  border-bottom: none;
}

/* User message - right aligned with blue bubble */
.message.user-message {
  justify-content: flex-end;
  background: transparent;
  border-bottom: none;
  padding: 0.75rem 0;
}

/* Bot message - full width with subtle background */
.message.bot-message {
  justify-content: flex-start;
  background: rgba(255, 255, 255, 0.02);
  margin: 0 -1rem;
  padding: 1.25rem 1rem;
  border-radius: 0.75rem;
}

/* Message content wrapper */
.message-content {
  max-width: 100%;
  font-size: 0.9rem;
  line-height: 1.7;
  color: #e5e5e5;
}

.message-content p {
  margin-bottom: 0.75rem;
}

.message-content p:last-child {
  margin-bottom: 0;
}

/* User message bubble */
.user-message .message-content {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  padding: 0.75rem 1rem;
  border-radius: 1.25rem;
  border-bottom-right-radius: 0.375rem;
  max-width: 75%;
  box-shadow: 0 2px 10px rgba(59, 130, 246, 0.2);
}

.user-message .message-content p {
  margin-bottom: 0;
}

/* Bot message content - clean, no bubble */
.bot-message .message-content {
  padding: 0;
  max-width: 100%;
}

/* Bot message header with icon */
.bot-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  font-weight: 600;
  font-size: 0.85rem;
  color: #a5a5a5;
}

.bot-header .bot-icon {
  width: 24px;
  height: 24px;
  background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bot-header .bot-icon svg {
  width: 14px;
  height: 14px;
  color: white;
}

/* Chat list styling */
.chat-list {
  list-style: none;
  padding-left: 0;
  margin: 0.75rem 0;
}

.chat-list li {
  position: relative;
  padding-left: 1.25rem;
  margin-bottom: 0.5rem;
  color: #d1d5db;
}

.chat-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.6em;
  width: 5px;
  height: 5px;
  background: #3b82f6;
  border-radius: 50%;
}

.chat-list li.sub {
  padding-left: 2.5rem;
  font-size: 0.85rem;
  color: #9ca3af;
}

.chat-list li.sub::before {
  left: 1.25rem;
  width: 4px;
  height: 4px;
  background: #6b7280;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 5px;
  padding: 0.5rem 0;
  align-items: center;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: #3b82f6;
  border-radius: 50%;
  animation: bounce 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}
.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

/* Suggestion chips */
.chip {
  transition: all 0.2s ease;
}

.chip:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

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

/* ==================== LOADING ==================== */
.loading-spinner {
  display: inline-block;
  width: 1.25rem;
  height: 1.25rem;
  border: 2.5px solid #3d3d3d;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.skeleton {
  background: linear-gradient(90deg, #1c1c1c 25%, #252525 50%, #1c1c1c 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 0.5rem;
}

/* ==================== TRADE DETAIL ==================== */
.detail-section {
  background: linear-gradient(135deg, #1c1c1c 0%, #161616 100%);
  border: 1px solid #2d2d2d;
  border-radius: 1rem;
  padding: 1.25rem;
  margin-bottom: 1rem;
  animation: fadeInUp 0.4s ease backwards;
}

.detail-section:nth-child(1) {
  animation-delay: 0.1s;
}
.detail-section:nth-child(2) {
  animation-delay: 0.2s;
}
.detail-section:nth-child(3) {
  animation-delay: 0.3s;
}

.detail-section h3 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: #9ca3af;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
}

.detail-item {
  transition: all 0.2s ease;
  padding: 0.5rem;
  border-radius: 0.5rem;
}

.detail-item:hover {
  background: rgba(59, 130, 246, 0.05);
}

.detail-item label {
  display: block;
  font-size: 0.65rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.25rem;
}

.detail-item span {
  font-size: 0.95rem;
  font-weight: 500;
}

.trade-detail-container {
  width: 100%;
}

.trade-detail-grid {
  gap: 0.75rem;
}

.trade-detail-stats {
  gap: 0.75rem;
}

/* ==================== FORM INPUTS ==================== */
input,
select,
textarea {
  transition: all 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* ==================== CHARTS ==================== */
.chart-card {
  animation: fadeInUp 0.5s ease backwards;
}

.chart-card:nth-child(1) {
  animation-delay: 0.2s;
}
.chart-card:nth-child(2) {
  animation-delay: 0.3s;
}

/* ==================== SCROLLBAR ==================== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #3d3d3d;
  border-radius: 3px;
  transition: background 0.2s;
}
::-webkit-scrollbar-thumb:hover {
  background: #4d4d4d;
}

/* ==================== RESPONSIVE - MOBILE FIRST ==================== */

/* ---- Small phones (max 379px) ---- */
@media (max-width: 379px) {
  .nav-link span:last-child {
    font-size: 0.6rem;
  }
  .nav-link {
    padding: 0.375rem 0.25rem;
  }
  .time-filter-scroll .time-filter-btn {
    min-width: 32px;
    padding: 0.375rem 0.5rem;
  }
}

/* ---- Phones (max 640px) ---- */
@media (max-width: 640px) {
  /* General typography tightening */
  body {
    font-size: 14px;
    -webkit-text-size-adjust: 100%;
  }

  .main-shell {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }

  /* Messages */
  .message p {
    max-width: 90%;
    font-size: 0.85rem;
  }

  /* Detail page grid */
  .detail-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }

  .trade-detail-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .trade-detail-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .trade-detail-container .bg-dark-card {
    padding: 0.9rem !important;
  }

  .trade-detail-container .break-all {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  /* No hover effects on mobile (causes sticky states) */
  .stat-card:hover,
  .news-card:hover,
  .hover-lift:hover {
    transform: none;
    box-shadow: none;
  }

  /* Trades table - card view on mobile */
  .trades-table thead {
    display: none;
  }
  .trades-table,
  .trades-table tbody,
  .trades-table tr,
  .trades-table td {
    display: block;
    width: 100%;
  }
  .trades-table {
    min-width: 0 !important;
  }
  .trades-table tbody tr {
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border: 1px solid #2d2d2d;
    border-radius: 0.75rem;
    background: #161616;
    position: relative;
  }
  .trades-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem 0;
    border: none;
    font-size: 0.8rem;
  }
  .trades-table td::before {
    content: attr(data-label);
    font-size: 0.65rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    flex-shrink: 0;
    margin-right: 0.75rem;
  }
  .trades-table td:empty {
    display: none;
  }
  /* Action buttons row in card view */
  .trades-table td.td-actions {
    justify-content: flex-end;
    gap: 0.5rem;
    padding-top: 0.5rem;
    margin-top: 0.25rem;
    border-top: 1px solid #2d2d2d;
  }
  .trades-table td.td-actions::before {
    display: none;
  }

  .trades-table tbody tr.trades-empty-row {
    padding: 0;
    margin-bottom: 0;
    border: 0;
    background: transparent;
  }

  .trades-table td.trades-empty-cell {
    display: block;
    text-align: center;
    padding: 1.25rem 0.75rem;
  }

  .trades-table td.trades-empty-cell::before {
    display: none;
    content: none;
  }

  .trades-empty-state {
    min-height: 110px;
  }

  /* Modal: full-screen on mobile for better UX */
  .modal-content {
    max-height: 95vh;
    border-radius: 1rem 1rem 0 0;
  }

  /* Chat page height fix */
  .chat-shell {
    height: calc(100vh - 118px);
    height: calc(100dvh - 118px);
    min-height: 420px;
  }

  .chat-header {
    gap: 0.75rem;
  }

  .chat-mode-switch {
    width: 100%;
  }

  .chat-mode-switch .chat-mode-btn {
    min-width: 88px;
  }

  #analysisContextBar {
    align-items: flex-start;
  }

  #chatMessages {
    padding: 0.75rem;
  }

  #chatForm {
    gap: 0.5rem;
  }

  #chatInput {
    font-size: 0.875rem;
  }

  .chat-message-bubble {
    max-width: 92% !important;
  }

  #sendBtn {
    flex-shrink: 0;
  }

  .chat-suggestions button {
    width: 100%;
  }

  /* Toast position above navbar */
  .toast {
    font-size: 0.8rem;
    padding: 0.75rem 0.875rem;
  }

  /* Charts slightly smaller */
  .chart-card canvas {
    max-height: 200px;
  }

  /* Better touch targets - buttons & links at least 44px */
  .action-btn {
    min-height: 36px;
    min-width: 36px;
  }

  /* Time filter horizontal scroll area */
  .time-filter-scroll {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 0.375rem;
    padding-bottom: 0.25rem;
  }
  .time-filter-scroll::-webkit-scrollbar {
    display: none;
  }
  .time-filter-scroll .time-filter-btn {
    flex-shrink: 0;
  }

  /* Bybit sync - stack buttons */
  .bybit-sync-actions {
    flex-direction: column;
    width: 100%;
  }
  .bybit-sync-actions button {
    width: 100%;
    justify-content: center;
  }

  /* News list in dashboard */
  .news-list {
    max-height: 250px !important;
  }

  /* Economic calendar widget */
  .tradingview-widget-container {
    height: 320px !important;
  }
  .tradingview-widget-container iframe {
    height: 320px !important;
  }

  /* Detail page action buttons */
  #detail-page .detail-actions {
    flex-direction: column;
  }
  #detail-page .detail-actions button {
    width: 100%;
    justify-content: center;
  }
}

/* ---- Tablets & small desktop (max 768px) ---- */
@media (max-width: 768px) {
  /* Fix bottom navbar safe-area */
  nav.fixed.bottom-0 {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  /* Main content padding to avoid navbar overlap */
  main {
    padding-bottom: calc(5rem + env(safe-area-inset-bottom, 0px)) !important;
  }

  main.main-shell {
    padding-left: 0.875rem !important;
    padding-right: 0.875rem !important;
  }

  /* Stat card secondary row - 3 cols on tablet, 2 on phone */
  .secondary-stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  /* Performance breakdown - stack */
  .performance-grid > div {
    min-width: 100%;
  }
}

@media (max-width: 480px) {
  .secondary-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

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

/* ==================== SAFE AREA (iOS notch etc.) ==================== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  nav.fixed.bottom-0 {
    padding-bottom: env(safe-area-inset-bottom);
  }
  main {
    padding-bottom: calc(5rem + env(safe-area-inset-bottom));
  }
}

/* ==================== MOBILE TOUCH IMPROVEMENTS ==================== */
@media (hover: none) and (pointer: coarse) {
  /* Disable hover effects that cause sticky states on touch */
  .stat-card:hover,
  .news-card:hover,
  .hover-lift:hover,
  .trades-table tbody tr:hover {
    transform: none;
    box-shadow: none;
    background: inherit;
  }

  /* Bigger tap targets */
  .nav-link {
    min-height: 44px;
  }
  button,
  a,
  [role="button"] {
    min-height: 38px;
  }

  /* Active states instead of hover (visual feedback on tap) */
  .stat-card:active {
    transform: scale(0.98);
    transition: transform 0.1s;
  }
  .news-card:active {
    transform: scale(0.99);
    transition: transform 0.1s;
  }
  .action-btn:active {
    transform: scale(0.95);
    transition: transform 0.1s;
  }
}

/* ==================== UTILITY CLASSES ==================== */
/* Line clamp for text truncation */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Hide scrollbar but keep functionality */
.scrollbar-hide {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.scrollbar-hide::-webkit-scrollbar {
  display: none;
}

/* Custom gradient text */
.text-gradient {
  background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Glass morphism effect */
.glass {
  background: rgba(26, 26, 26, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* Smooth hover elevation */
.hover-lift {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.hover-lift:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

/* Glow effects */
.glow-blue {
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
}

.glow-green {
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.3);
}

.glow-red {
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.3);
}

.toast-modal {
  bottom: 140px !important; /* naik supaya tidak menimpa form PIN */
}

/* ==================== AUTH MODAL MOBILE OPTIMIZATIONS ==================== */
#authModal {
  -webkit-overflow-scrolling: touch;
}

#authModal > div {
  /* Smooth scroll for modal content */
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

#authModal > div::-webkit-scrollbar {
  width: 4px;
}

#authModal > div::-webkit-scrollbar-track {
  background: transparent;
}

#authModal > div::-webkit-scrollbar-thumb {
  background: #3d3d3d;
  border-radius: 2px;
}

/* Prevent iOS zoom on input focus */
@media (max-width: 640px) {
  #authModal input[type="email"],
  #authModal input[type="password"],
  #authModal input[type="text"] {
    font-size: 16px; /* Prevents iOS zoom */
  }

  /* Better autocomplete styling on mobile */
  #authModal input:-webkit-autofill,
  #authModal input:-webkit-autofill:hover,
  #authModal input:-webkit-autofill:focus {
    -webkit-text-fill-color: #f5f5f5;
    -webkit-box-shadow: 0 0 0px 1000px #1c1c1c inset;
    transition: background-color 5000s ease-in-out 0s;
  }

  /* Landscape mode optimization */
  @media (max-height: 500px) {
    #authModal > div {
      max-height: 85vh;
      padding-top: 1rem;
      padding-bottom: 1rem;
    }

    #authModal .text-center.mb-4 {
      margin-bottom: 0.75rem !important;
    }

    #authModal form {
      margin-top: 0.5rem;
    }
  }
}

/* Better focus states for touch devices */
@media (hover: none) and (pointer: coarse) {
  #authModal input:focus {
    transform: scale(1.01);
    transition: transform 0.2s ease;
  }

  #authModal button:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
  }
}

/* Prevent body scroll when modal is open */
body.modal-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
}
