/* General Styles */
* {
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --success-gradient: linear-gradient(135deg, #0cebeb 0%, #20e3b2 100%);
  --danger-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --card-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --card-shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.15);
}

body {
  font-family: 'Heebo', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  overflow-x: hidden;
  background: linear-gradient(180deg, #f8f9fa 0%, #e9ecef 100%);
  min-height: 100vh;
}

/* iOS Safe Area Support */
@supports (padding: max(0px)) {
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
}

/* Navbar - App-like */
.navbar {
  background: rgba(255, 255, 255, 0.95) !important;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.navbar-brand {
  font-size: 1.5rem;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Hero - Modern Gradient */
.hero {
  background: var(--primary-gradient);
  position: relative;
  overflow: hidden;
  min-height: 40vh;
  color: #fff;
  display: grid;
  place-items: center;
  text-shadow: 0 2px 12px rgba(0,0,0,.3);
}

.hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 120"><path d="M0,0V46.29c47.79,22.2,103.59,32.17,158,28,70.36-5.37,136.33-33.31,206.8-37.5C438.64,32.43,512.34,53.67,583,72.05c69.27,18,138.3,24.88,209.4,13.08,36.15-6,69.85-17.84,104.45-29.34C989.49,25,1113-14.29,1200,52.47V0Z" opacity=".25" fill="%23ffffff"></path><path d="M0,0V15.81C13,36.92,27.64,56.86,47.69,72.05,99.41,111.27,165,111,224.58,91.58c31.15-10.15,60.09-26.07,89.67-39.8,40.92-19,84.73-46,130.83-49.67,36.26-2.85,70.9,9.42,98.6,31.56,31.77,25.39,62.32,62,103.63,73,40.44,10.79,81.35-6.69,119.13-24.28s75.16-39,116.92-43.05c59.73-5.85,113.28,22.88,168.9,38.84,30.2,8.66,59,6.17,87.09-7.5,22.43-10.89,48-26.93,60.65-49.24V0Z" opacity=".5" fill="%23ffffff"></path><path d="M0,0V5.63C149.93,59,314.09,71.32,475.83,42.57c43-7.64,84.23-20.12,127.61-26.46,59-8.63,112.48,12.24,165.56,35.4C827.93,77.22,886,95.24,951.2,90c86.53-7,172.46-45.71,248.8-84.81V0Z" fill="%23ffffff"></path></svg>') no-repeat bottom;
  background-size: cover;
  opacity: 0.1;
}

.hero .container {
  position: relative;
  z-index: 1;
}

.hero h1 {
  font-weight: 800;
  letter-spacing: .5px;
  animation: fadeInDown 0.8s ease-out;
  font-size: clamp(1.75rem, 5vw, 2.5rem);
}

.hero p {
  animation: fadeInUp 0.8s ease-out 0.2s both;
  font-size: clamp(0.9rem, 2.5vw, 1.125rem);
}

/* Modern Card Design */
.coin-card {
  animation: fadeInUp 0.5s ease-out both;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  background: white;
  border: none !important;
  border-radius: 16px !important;
  box-shadow: var(--card-shadow) !important;
  overflow: hidden;
  position: relative;
}

.coin-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary-gradient);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.coin-card:hover::before,
.coin-card:active::before {
  transform: scaleX(1);
}

.coin-card:hover,
.coin-card:active {
  transform: translateY(-8px) scale(1.02);
  box-shadow: var(--card-shadow-hover) !important;
}

.coin-card .card-body {
  padding: 1.25rem;
}

.coin-card img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

/* Mobile Optimized Cards */
@media (max-width: 576px) {
  .coin-card {
    border-radius: 12px !important;
  }

  .coin-card .card-body {
    padding: 1rem;
  }

  .coin-card:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
  }
}

/* Modern Sticky Search */
.sticky-search {
  position: sticky;
  top: 0;
  z-index: 1040;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 2px 12px rgba(0,0,0,.06);
  transition: all 0.3s ease;
}

.sticky-search .form-control {
  border-radius: 12px;
  border: 2px solid #e9ecef;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  transition: all 0.3s ease;
}

.sticky-search .form-control:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
  transform: translateY(-1px);
}

.sticky-search .btn {
  border-radius: 12px;
  padding: 0.75rem 1.5rem;
  font-weight: 600;
}

.sticky-search .badge {
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font-weight: 600;
}

/* Badges */
.fav-badge {
  font-size: .8rem;
  transition: all 0.3s ease;
}

/* Rotation Animation */
.rotate {
  transition: transform .25s ease;
}

.rotate.open {
  transform: rotate(180deg);
}

/* Modern Button Styling */
.btn {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 10px;
  font-weight: 600;
  border: none;
  padding: 0.5rem 1rem;
  position: relative;
  overflow: hidden;
}

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

.btn:active::before {
  width: 300px;
  height: 300px;
}

.btn-primary {
  background: var(--primary-gradient);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.btn-warning {
  background: linear-gradient(135deg, #ffc107 0%, #ff9800 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(255, 193, 7, 0.3);
}

.btn-outline-warning {
  border: 2px solid #ffc107;
  color: #ffc107;
}

.btn-outline-warning:hover {
  background: linear-gradient(135deg, #ffc107 0%, #ff9800 100%);
  border-color: transparent;
  color: white;
}

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

/* Loading Animation */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.progress-bar-animated {
  animation: pulse 1.5s ease-in-out infinite;
}

/* Fade In Animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Chart Container - Modern Design */
#chartContainer {
  animation: fadeIn 0.8s ease-out;
  border-radius: 16px;
  padding: 1.25rem;
  background: white;
  box-shadow: var(--card-shadow);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

/* Loading Skeleton Animation */
@keyframes skeleton-loading {
  0% {
    background-position: -200px 0;
  }
  100% {
    background-position: calc(200px + 100%) 0;
  }
}

.skeleton {
  animation: skeleton-loading 1.5s ease-in-out infinite;
  background: linear-gradient(90deg, #f0f0f0 0px, #f8f8f8 40px, #f0f0f0 80px);
  background-size: 200px 100%;
  border-radius: 8px;
}

.skeleton-card {
  height: 200px;
  margin-bottom: 1rem;
}

.skeleton-text {
  height: 16px;
  margin-bottom: 8px;
}

.skeleton-title {
  height: 24px;
  width: 60%;
  margin-bottom: 12px;
}

/* More Info Section */
.more-content {
  animation: fadeIn 0.4s ease-out;
}

/* Badge Hover Effects */
.badge {
  transition: transform 0.2s ease;
}

.badge:hover {
  transform: scale(1.05);
}

/* Navbar */
.navbar {
  transition: background-color 0.3s ease;
}

.nav-link {
  transition: color 0.3s ease;
  position: relative;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: #0d6efd;
  transition: width 0.3s ease;
}

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

/* Modal Animations */
.modal.fade .modal-dialog {
  transition: transform 0.3s ease-out;
}

/* Responsive */
@media (max-width: 576px) {
  .hero {
    min-height: 35vh;
  }

  .coin-card {
    animation-delay: 0s !important;
  }
}

/* Staggered Animation for Cards */
.coin-card:nth-child(1) { animation-delay: 0.05s; }
.coin-card:nth-child(2) { animation-delay: 0.1s; }
.coin-card:nth-child(3) { animation-delay: 0.15s; }
.coin-card:nth-child(4) { animation-delay: 0.2s; }
.coin-card:nth-child(5) { animation-delay: 0.25s; }
.coin-card:nth-child(6) { animation-delay: 0.3s; }

/* Scroll to Top Button - Modern */
#scrollTopBtn {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  background: var(--primary-gradient) !important;
  border: none;
  box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
}

#scrollTopBtn:hover {
  transform: translateY(-5px) scale(1.1) !important;
  box-shadow: 0 8px 28px rgba(102, 126, 234, 0.5) !important;
}

#scrollTopBtn:active {
  transform: scale(0.95) !important;
}

#scrollTopBtn i {
  font-size: 1.3rem;
  animation: bounce 2s infinite;
}

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

/* Toast Notifications - Modern */
.toast {
  min-width: 280px;
  border-radius: 12px !important;
  border: none !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15) !important;
  backdrop-filter: blur(10px);
  animation: slideInRight 0.3s ease-out;
}

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

.toast-body {
  padding: 1rem 1.25rem;
  font-weight: 500;
}

/* Search Input Focus */
#search:focus {
  border-color: #0d6efd;
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Favorites Section - Premium Design */
#favorites {
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  border-radius: 20px;
  padding: 2rem 0;
  margin: 2rem 0;
  position: relative;
}

#favRow .card {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 16px !important;
  border: none !important;
  box-shadow: var(--card-shadow) !important;
  background: white;
  overflow: hidden;
  position: relative;
}

#favRow .card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--success-gradient);
}

#favRow .card:hover,
#favRow .card:active {
  transform: translateY(-8px) scale(1.03);
  box-shadow: var(--card-shadow-hover) !important;
}

@media (max-width: 576px) {
  #favRow .card:active {
    transform: scale(0.97);
  }
}

/* Chart Status Badge */
#chartStatus {
  transition: all 0.3s ease;
  font-size: 0.85rem;
  padding: 0.4rem 0.8rem;
}

#chartStatus i {
  margin-left: 4px;
}

/* Chart Empty Message */
#chartEmptyMessage {
  animation: fadeIn 0.5s ease-out;
}

/* Pulsing animation for loading status */
@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

#chartStatus.bg-primary {
  animation: pulse-badge 2s ease-in-out infinite;
}

/* ============================================
   MOBILE OPTIMIZATIONS
   ============================================ */

@media (max-width: 768px) {
  /* Container spacing */
  .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  /* Hero adjustments */
  .hero {
    min-height: 35vh;
    padding: 2rem 0;
  }

  .hero h1 {
    font-size: 1.75rem;
  }

  .hero p {
    font-size: 0.95rem;
  }

  /* Touch-friendly buttons */
  .btn {
    min-height: 44px;
    min-width: 44px;
  }

  .btn-sm {
    min-height: 38px;
  }

  /* Sticky search mobile */
  .sticky-search {
    padding: 0.75rem 0 !important;
  }

  .sticky-search .form-control,
  .sticky-search .btn {
    font-size: 1rem;
  }

  /* Card grid spacing */
  #coinsGrid .col-12,
  #coinsGrid .col-sm-6,
  #coinsGrid .col-lg-4 {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  /* Favorites cards */
  #favRow .card .card-body {
    padding: 0.875rem;
  }

  /* Chart mobile */
  #chartContainer {
    padding: 0.75rem;
    margin-left: -0.5rem;
    margin-right: -0.5rem;
  }

  /* Modal mobile */
  .modal-dialog {
    margin: 0.5rem;
  }

  /* Footer mobile */
  footer {
    text-align: center;
  }

  footer .row > div {
    text-align: center !important;
  }
}

/* Extra small devices */
@media (max-width: 400px) {
  .coin-card .card-body {
    padding: 0.875rem;
  }

  .sticky-search .badge {
    font-size: 0.7rem;
    padding: 0.35rem 0.5rem;
  }

  #scrollTopBtn {
    width: 45px !important;
    height: 45px !important;
    right: 0.75rem !important;
    bottom: 0.75rem !important;
  }
}

/* ============================================
   ACCESSIBILITY & PERFORMANCE
   ============================================ */

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

/* High contrast mode */
@media (prefers-contrast: high) {
  .coin-card,
  #favRow .card,
  #chartContainer {
    border: 2px solid currentColor;
  }
}

/* Dark mode support (future-ready) */
@media (prefers-color-scheme: dark) {
  /* Can be implemented later */
}

/* ============================================
   ACCESSIBILITY FEATURES
   ============================================ */

/* Accessibility Button Animation */
#accessibilityBtn {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#accessibilityBtn:hover {
  transform: scale(1.1) rotate(5deg);
  box-shadow: 0 8px 24px rgba(102, 126, 234, 0.3) !important;
}

#accessibilityBtn i {
  transition: transform 0.3s ease;
}

#accessibilityBtn:hover i {
  transform: scale(1.2);
}

/* Accessibility Panel */
#accessibilityPanel {
  transition: all 0.3s ease;
}

/* Text Size Options */
body.text-small {
  font-size: 14px;
}

body.text-large {
  font-size: 18px;
}

body.text-xlarge {
  font-size: 22px;
}

/* High Contrast Mode */
body.contrast-high {
  filter: contrast(1.5);
}

body.contrast-high .card,
body.contrast-high .btn {
  border: 2px solid currentColor !important;
}

/* Dark Contrast Mode */
body.contrast-dark {
  background: #1a1a1a !important;
  color: #ffffff !important;
}

body.contrast-dark .navbar,
body.contrast-dark .sticky-search,
body.contrast-dark .card,
body.contrast-dark #accessibilityPanel,
body.contrast-dark .modal-content {
  background: #2a2a2a !important;
  color: #ffffff !important;
  border-color: #444 !important;
}

body.contrast-dark .hero {
  background: linear-gradient(135deg, #1a1a1a 0%, #2a2a2a 100%) !important;
}

body.contrast-dark .btn-primary {
  background: #667eea !important;
  color: #fff !important;
}

body.contrast-dark .form-control {
  background: #333 !important;
  color: #fff !important;
  border-color: #555 !important;
}

body.contrast-dark .text-secondary,
body.contrast-dark .text-muted {
  color: #ccc !important;
}

/* Line Height Options */
body.line-height-medium {
  line-height: 1.8;
}

body.line-height-large {
  line-height: 2.2;
}

/* Letter Spacing Options */
body.letter-spacing-wide {
  letter-spacing: 0.1em;
}

body.letter-spacing-wide .btn,
body.letter-spacing-wide .badge {
  letter-spacing: 0.05em;
}

/* Big Cursor */
body.big-cursor,
body.big-cursor * {
  cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32"><path fill="%23000" stroke="%23fff" stroke-width="2" d="M3 3 L25 15 L15 17 L10 27 Z"/></svg>') 4 4, auto !important;
}

body.big-cursor button,
body.big-cursor a,
body.big-cursor .btn {
  cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32"><path fill="%23667eea" stroke="%23fff" stroke-width="2" d="M16 3 L16 29 M3 16 L29 16"/></svg>') 16 16, pointer !important;
}

/* Reading Guide Animation */
#readingGuideLine {
  transition: top 0.05s linear;
}

/* Accessibility Panel Mobile */
@media (max-width: 576px) {
  #accessibilityPanel {
    width: calc(100vw - 2rem) !important;
    left: 1rem !important;
    right: 1rem !important;
    margin-right: 0 !important;
    margin-left: 0 !important;
    bottom: 80px !important;
  }

  #accessibilityBtn {
    width: 50px !important;
    height: 50px !important;
    margin: 0.75rem !important;
  }
}
