/* ─── Responsive: desktop · tablet · mobile ─── */

/* Tablet (≤1024px) */
@media (max-width: 1024px) {
  .container,
  .container-wide {
    padding: 0 1.25rem;
  }

  .section {
    padding: 3.5rem 0;
  }

  .features-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .testimonials-carousel {
    padding: 0 2.5rem 2rem;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .dashboard-header h1 {
    font-size: 1.65rem;
  }

  .auth-card {
    max-width: 100%;
  }

  .cta-banner-content {
    padding: 2.5rem 1.5rem;
  }

  .cta-banner-content h2 {
    font-size: 1.65rem;
  }

  .admin .stats-grid,
  #adminApp .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Mobile nav breakpoint (≤992px) — drawer replaces hidden nav-center */
@media (max-width: 992px) {
  .nav-center {
    display: none;
  }

  .nav-mobile-toggle {
    display: flex;
  }

  .nav-mobile-menu-item {
    display: list-item;
  }

  .navbar .container-wide,
  .navbar .container {
    gap: 0.75rem;
  }

  .logo {
    font-size: 1.25rem;
    flex-shrink: 0;
    --brand-logo-size: 22px;
  }

  .nav-links {
    gap: 0.5rem;
    margin-left: auto;
  }

  .navbar .nav-links > li.nav-auth-item,
  .navbar .nav-links > li:has(> a[href*="login"]),
  .navbar .nav-links > li:has(> a[href*="register"]) {
    display: none;
  }

  .user-dropdown-name {
    display: none;
  }

  .user-dropdown-toggle {
    padding: 0.35rem;
  }

  .navbar .nav-links #balance {
    font-size: 0.8rem !important;
  }
}

/* Mobile (≤768px) */
@media (max-width: 768px) {
  :root {
    --nav-h: 64px;
    --ticker-h: 36px;
  }

  html {
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
  }

  body {
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
  }

  main,
  .page-main {
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
  }

  .container,
  .container-wide {
    width: 100%;
    max-width: 100%;
    padding: 0 1rem;
    padding-left: max(1rem, env(safe-area-inset-left, 0px));
    padding-right: max(1rem, env(safe-area-inset-right, 0px));
  }

  .navbar {
    overflow-x: clip;
    max-width: 100%;
  }

  .navbar .container,
  .navbar .container-wide {
    min-width: 0;
    gap: 0.5rem;
  }

  .nav-links {
    min-width: 0;
    flex-shrink: 0;
    gap: 0.35rem;
  }

  .navbar .lang-switcher-icon {
    display: none;
  }

  .navbar .lang-select {
    max-width: 7.25rem;
    min-width: 0;
    padding: 0.4rem 1.35rem 0.4rem 0.45rem;
    font-size: 0.72rem;
  }

  .nav-mobile-toggle {
    width: 40px;
    height: 40px;
    min-height: 40px;
    font-size: 1.2rem;
  }

  .ticker-wrap {
    overflow-x: clip;
    max-width: 100%;
  }

  .page-main {
    padding-bottom: 2rem;
  }

  .hero {
    padding: 2.5rem 0 3.5rem;
  }

  .hero h1 {
    font-size: clamp(2rem, 8vw, 2.75rem);
  }

  .hero-sub {
    font-size: 1rem;
  }

  .hero-cta {
    flex-direction: column;
    width: 100%;
  }

  .hero-cta .btn {
    width: 100%;
  }

  .hero-split {
    padding: 2rem 0 3rem;
    gap: 2rem;
  }

  .phone-mockup {
    max-width: 280px;
  }

  .features-grid {
    grid-template-columns: 1fr;
  }

  .stats-bar {
    grid-template-columns: 1fr 1fr;
  }

  .stats-bar-item {
    padding: 1.25rem 1rem;
  }

  .stats-bar-item .num {
    font-size: 1.5rem;
  }

  .section-header h2 {
    font-size: 1.5rem;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .footer-bottom {
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
  }

  .steps-grid {
    grid-template-columns: 1fr;
  }

  .contact-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .stat-card .value,
  .balance-display {
    font-size: 1.75rem !important;
  }

  .dashboard-header {
    margin-bottom: 1.25rem;
  }

  .dashboard-header h1 {
    font-size: 1.45rem;
  }

  .dashboard-header p {
    font-size: 0.9rem;
  }

  .card {
    padding: 1.25rem;
  }

  .card-title {
    font-size: 0.95rem;
  }

  th,
  td {
    padding: 0.65rem 0.75rem;
    font-size: 0.8rem;
  }

  table {
    font-size: 0.8rem;
  }

  .table-wrap {
    -webkit-overflow-scrolling: touch;
    margin: 0 -0.25rem;
  }

  .tabs {
    margin-left: -1rem;
    margin-right: -1rem;
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .tab {
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
  }

  .admin .stats-grid,
  #adminApp .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .testimonials-carousel {
    padding: 0 2rem 2rem;
  }

  .carousel-btn {
    width: 36px;
    height: 36px;
    font-size: 1.2rem;
  }

  .showcase-split {
    gap: 2rem;
  }

  .showcase-content h2 {
    font-size: 1.45rem;
  }

  .market-gallery {
    grid-template-columns: 1fr;
    max-width: none;
    margin: 0;
  }

  .market-overview-table-wrap {
    max-height: none;
  }

  .market-overview-table {
    font-size: 0.8rem;
  }

  .crypto-news-grid {
    grid-template-columns: 1fr;
  }

  .crypto-news-carousel {
    padding: 0 0 1.75rem;
    margin: 0;
    max-width: 100%;
  }

  .crypto-news-home-meta {
    padding: 0 0.25rem;
    margin-bottom: 1rem;
  }

  .crypto-news-home::before,
  .crypto-news-home::after {
    display: none;
  }

  .crypto-news-carousel .carousel-btn {
    display: none;
  }

  .crypto-news-item-carousel {
    flex-basis: min(280px, 100%);
  }

  .crypto-news-carousel-sm .crypto-news-item-carousel {
    flex-basis: min(200px, 100%);
  }

  .crypto-news-item:not(.crypto-news-item-carousel) {
    flex-direction: column;
  }

  .crypto-news-thumb,
  .crypto-news-thumb-fallback {
    width: 100%;
    height: 140px;
  }

  .market-overview-table th:nth-child(5),
  .market-overview-table td:nth-child(5),
  .market-overview-table th:nth-child(6),
  .market-overview-table td:nth-child(6) {
    display: none;
  }

  body > .theme-toggle {
    top: 0.75rem;
    right: 0.75rem;
  }

  .auth-page {
    align-items: flex-start;
    justify-content: flex-start;
    padding: 1rem;
    padding-top: calc(var(--nav-h) + 0.75rem);
    padding-bottom: max(1.25rem, env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .auth-card {
    padding: 1.25rem;
    max-width: 100%;
  }

  .auth-card h1 {
    font-size: 1.35rem;
    line-height: 1.25;
  }

  .auth-card > p {
    font-size: 0.85rem;
    margin-bottom: 1.25rem;
  }

  .auth-page .form-control {
    font-size: 16px;
  }

  .auth-page .form-group {
    margin-bottom: 1rem;
  }

  .auth-divider {
    font-size: 0.78rem;
    line-height: 1.5;
    margin: 1rem 0 0;
  }

  .auth-page::before {
    width: min(280px, 85vw);
    height: min(280px, 85vw);
  }

  .ticker-item {
    padding: 0 1.25rem;
    font-size: 0.75rem;
  }

  .user-dropdown-menu {
    right: -0.5rem;
    min-width: 220px;
  }

  .profile-grid {
    grid-template-columns: 1fr;
  }

  .trader-card-header {
    flex-direction: column;
    text-align: center;
  }

  .actions {
    flex-direction: column;
  }

  .actions .btn {
    width: 100%;
  }
}

/* Small mobile (≤480px) */
@media (max-width: 480px) {
  .stats-bar {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .admin .stats-grid,
  #adminApp .stats-grid {
    grid-template-columns: 1fr;
  }

  .nav-links .btn {
    padding: 0.4rem 0.75rem;
    font-size: 0.72rem;
  }

  .nav-links .btn-sm {
    padding: 0.35rem 0.65rem;
  }

  .app-topbar-user span {
    display: none;
  }

  .live-badge {
    font-size: 0.68rem;
    padding: 0.3rem 0.6rem;
  }

  .showcase-photo-lg {
    width: 100%;
  }

  .showcase-photo-sm {
    width: 55%;
  }

  .grid-2[style] {
    grid-template-columns: 1fr !important;
  }

  .feature-card[style*="grid-column"] {
    grid-column: auto !important;
  }

  #copyModal {
    padding: 1rem;
    align-items: flex-end !important;
  }

  #copyModal .card {
    max-height: 90vh;
    overflow-y: auto;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
  }

  .modal-overlay,
  [style*="position:fixed"][style*="inset:0"] .card {
    max-width: 100% !important;
  }
}

/* Mobile navigation drawer — base styles */
.nav-mobile-menu-item {
  list-style: none;
}

.nav-mobile-toggle {
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-solid);
  color: var(--text);
  font-size: 1.35rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.2s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Desktop: hide hamburger */
@media (min-width: 993px) {
  .nav-mobile-menu-item,
  .nav-mobile-toggle {
    display: none;
  }
}

.nav-mobile-toggle:hover {
  border-color: var(--cyan);
}

.nav-mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 1001;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.nav-mobile-overlay.open {
  display: block;
  opacity: 1;
}

.nav-mobile-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(300px, 88vw);
  background: var(--surface-solid);
  border-right: 1px solid var(--border-strong);
  z-index: 1002;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.nav-mobile-drawer.open {
  transform: translateX(0);
}

.nav-mobile-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.nav-mobile-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
}

.nav-mobile-links {
  list-style: none;
  padding: 0.75rem;
  flex: 1;
}

.nav-mobile-links a {
  display: block;
  padding: 0.85rem 1rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius);
  transition: background 0.2s, color 0.2s;
}

.nav-mobile-links a:hover,
.nav-mobile-links a.active {
  background: rgba(0, 242, 255, 0.08);
  color: var(--cyan);
}

.nav-mobile-links .nav-mobile-auth a {
  color: var(--text);
  font-weight: 600;
}

.nav-mobile-links .nav-mobile-auth-divider {
  margin-top: 0.35rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.nav-mobile-links .nav-mobile-auth + .nav-mobile-auth a {
  color: var(--cyan);
}

.nav-mobile-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav-mobile-footer .btn {
  width: 100%;
}

.nav-mobile-theme-slot {
  width: 100%;
}

.nav-mobile-theme-mount {
  width: 100%;
}

.nav-mobile-theme-mount .theme-toggle.theme-toggle-row {
  width: 100%;
  height: auto;
  min-height: 44px;
  border-radius: var(--radius);
  padding: 0.65rem 0.85rem;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.65rem;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
  box-shadow: none;
}

.nav-mobile-theme-mount .theme-toggle.theme-toggle-row:hover {
  transform: none;
  border-color: var(--cyan);
  box-shadow: 0 0 12px var(--cyan-glow);
}

.nav-mobile-theme-mount .theme-toggle-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.2;
}

body.nav-mobile-open {
  overflow: hidden;
}

/* Touch-friendly targets */
@media (max-width: 768px) {
  .btn,
  .form-control,
  select.form-control {
    min-height: 44px;
  }

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

/* Landscape phones */
@media (max-width: 896px) and (orientation: landscape) {
  .auth-page {
    padding-top: 1rem;
    padding-bottom: 1rem;
  }

  .hero {
    padding: 2rem 0;
  }
}
