/* ========================================
   COSMIC THEME - Shared Design System
   Consolidates design tokens and component styles
   for Gopnik Wallet NFT Platform
   ======================================== */

/* ========================================
   DESIGN TOKENS - CSS Custom Properties
   ======================================== */
:root {
  /* Background Colors */
  --cosmic-bg-deep: #080a2e;
  --cosmic-bg-card: rgba(14,16,72,0.7);
  --cosmic-bg-card-solid: #0e1048;

  /* Accent Colors */
  --cosmic-accent-purple: #8b5cf6;
  --cosmic-accent-cyan: #22d3ee;
  --cosmic-accent-green: #10b981;
  --cosmic-accent-green-light: #34d399;
  --cosmic-accent-amber: #f59e0b;
  --cosmic-accent-red: #ef4444;

  /* Text Colors */
  --cosmic-text-primary: #f0f1ff;
  --cosmic-text-secondary: #c8c7e0;
  --cosmic-text-muted: #8b89b8;
  --cosmic-text-dim: #8583ab;  /* bumped from #6b6894 for WCAG AA (≥4.5:1) */

  /* Border & Glass Effects */
  --cosmic-border: rgba(139,92,246,0.18);
  --cosmic-border-hover: rgba(139,92,246,0.35);
  --cosmic-glass-bg: rgba(20,22,80,0.70);
  --cosmic-glass-border: rgba(139,92,246,0.3);

  /* Spacing & Radius */
  --cosmic-radius-sm: 10px;
  --cosmic-radius-md: 14px;
  --cosmic-radius-lg: 18px;

  /* Shadows */
  --cosmic-shadow: 0 8px 32px rgba(139,92,246,0.12);
  --cosmic-shadow-hover: 0 12px 36px rgba(139,92,246,0.15);

  /* Animation */
  --cosmic-transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   BACKGROUND EFFECT
   Radial gradient cosmic background
   ======================================== */
.cosmic-bg::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(139,92,246,0.14) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 75%, rgba(34,211,238,0.08) 0%, transparent 55%),
    #080a2e;
  pointer-events: none;
}

/* ========================================
   SCROLLBAR STYLING
   ======================================== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(139,92,246,0.3);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(139,92,246,0.5);
}

/* ========================================
   SHARED UTILITY CLASSES
   ======================================== */

/* CARDS - Glassmorphic card component */
.cosmic-card {
  background: var(--cosmic-bg-card);
  border: 1px solid var(--cosmic-border);
  border-radius: var(--cosmic-radius-md);
  padding: 1.5rem;
  backdrop-filter: blur(10px);
  transition: var(--cosmic-transition);
  box-shadow: var(--cosmic-shadow);
}

.cosmic-card:hover {
  border-color: var(--cosmic-border-hover);
  box-shadow: var(--cosmic-shadow-hover);
  background: rgba(14,16,72,0.85);
}

/* GRADIENT TEXT */
.cosmic-gradient-text {
  background: linear-gradient(135deg, var(--cosmic-accent-purple), var(--cosmic-accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* BUTTONS - Primary (Gradient Purple) */
.cosmic-btn-primary {
  background: linear-gradient(135deg, var(--cosmic-accent-purple), #a78bfa);
  color: var(--cosmic-text-primary);
  border: none;
  border-radius: var(--cosmic-radius-md);
  padding: 0.75rem 1.5rem;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--cosmic-transition);
  box-shadow: 0 4px 15px rgba(139,92,246,0.3);
}

.cosmic-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(139,92,246,0.5);
}

.cosmic-btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 4px 15px rgba(139,92,246,0.3);
}

.cosmic-btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* BUTTONS - Secondary (Outline) */
.cosmic-btn-secondary {
  background: transparent;
  color: var(--cosmic-accent-purple);
  border: 1.5px solid var(--cosmic-accent-purple);
  border-radius: var(--cosmic-radius-md);
  padding: 0.75rem 1.5rem;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--cosmic-transition);
}

.cosmic-btn-secondary:hover {
  background: rgba(139,92,246,0.1);
  border-color: var(--cosmic-accent-cyan);
  color: var(--cosmic-accent-cyan);
}

.cosmic-btn-secondary:active {
  background: rgba(139,92,246,0.2);
}

.cosmic-btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* BUTTONS - Danger (Red Gradient) */
.cosmic-btn-danger {
  background: linear-gradient(135deg, var(--cosmic-accent-red), #f87171);
  color: var(--cosmic-text-primary);
  border: none;
  border-radius: var(--cosmic-radius-md);
  padding: 0.75rem 1.5rem;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--cosmic-transition);
  box-shadow: 0 4px 15px rgba(239,68,68,0.3);
}

.cosmic-btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(239,68,68,0.5);
}

.cosmic-btn-danger:active {
  transform: translateY(0);
  box-shadow: 0 4px 15px rgba(239,68,68,0.3);
}

.cosmic-btn-danger:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* FORM INPUT - Styled input field */
.cosmic-input {
  background: var(--cosmic-glass-bg);
  border: 1px solid var(--cosmic-glass-border);
  border-radius: var(--cosmic-radius-sm);
  padding: 0.75rem 1rem;
  color: var(--cosmic-text-primary);
  font-size: 0.95rem;
  transition: var(--cosmic-transition);
  outline: none;
}

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

.cosmic-input:focus {
  border-color: var(--cosmic-accent-purple);
  background: rgba(20,22,80,0.85);
  box-shadow: 0 0 0 3px rgba(139,92,246,0.1);
}

/* BADGES - Status badges */
.cosmic-badge-active {
  display: inline-block;
  background: rgba(16,185,129,0.15);
  color: var(--cosmic-accent-green);
  border: 1px solid rgba(16,185,129,0.35);
  border-radius: var(--cosmic-radius-sm);
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.cosmic-badge-inactive {
  display: inline-block;
  background: rgba(107,104,148,0.15);
  color: var(--cosmic-text-muted);
  border: 1px solid rgba(107,104,148,0.35);
  border-radius: var(--cosmic-radius-sm);
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.cosmic-badge-warning {
  display: inline-block;
  background: rgba(245,158,11,0.15);
  color: var(--cosmic-accent-amber);
  border: 1px solid rgba(245,158,11,0.35);
  border-radius: var(--cosmic-radius-sm);
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
}

/* EMPTY STATE */
.cosmic-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 2rem;
  text-align: center;
}

.cosmic-empty-state-icon {
  font-size: 3.5rem;
  margin-bottom: 1.5rem;
  opacity: 0.6;
}

.cosmic-empty-state-title {
  color: var(--cosmic-text-primary);
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.cosmic-empty-state-description {
  color: var(--cosmic-text-muted);
  font-size: 0.95rem;
}

/* SKELETON LOADING - Shimmer animation */
@keyframes cosmic-shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

.cosmic-skeleton {
  background: linear-gradient(
    90deg,
    rgba(139,92,246,0.1) 0%,
    rgba(139,92,246,0.2) 50%,
    rgba(139,92,246,0.1) 100%
  );
  background-size: 1000px 100%;
  animation: cosmic-shimmer 2s infinite;
  border-radius: var(--cosmic-radius-sm);
}

/* FADE IN ANIMATION */
@keyframes cosmic-fade-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.cosmic-fade-in {
  animation: cosmic-fade-in 0.5s ease-out forwards;
}

/* ========================================
   RESET & BASE STYLES
   ======================================== */
* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--cosmic-bg-deep);
  color: var(--cosmic-text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  overflow-x: hidden;
}

button {
  font-family: inherit;
}

input, textarea, select {
  font-family: inherit;
}

a {
  color: var(--cosmic-accent-purple);
  text-decoration: none;
  transition: var(--cosmic-transition);
}

a:hover {
  color: var(--cosmic-accent-cyan);
}

/* ========================================
   RESPONSIVE UTILITIES & BREAKPOINTS
   Mobile-first responsive system
   ======================================== */

/* Responsive font scaling for headings */
h1, .cosmic-h1 { font-size: clamp(1.5rem, 4vw, 2.5rem); }
h2, .cosmic-h2 { font-size: clamp(1.25rem, 3vw, 2rem); }
h3, .cosmic-h3 { font-size: clamp(1.1rem, 2.5vw, 1.5rem); }

/* Touch-friendly tap targets */
.cosmic-tap-target,
.cosmic-btn-primary,
.cosmic-btn-secondary,
.cosmic-btn-danger {
  min-height: 44px;
  min-width: 44px;
}

/* ── Mobile: 0–767px ─────────────────────── */
@media (max-width: 767px) {
  .cosmic-card {
    padding: 1rem;
    border-radius: var(--cosmic-radius-sm);
  }

  .cosmic-btn-primary,
  .cosmic-btn-secondary,
  .cosmic-btn-danger {
    padding: 0.6rem 1rem;
    font-size: 0.88rem;
    width: 100%;
    justify-content: center;
  }

  .cosmic-empty-state {
    padding: 2rem 1rem;
  }

  .cosmic-empty-state-icon {
    font-size: 2.5rem;
  }

  /* Stack layouts by default on mobile */
  .cosmic-row { flex-direction: column !important; }
  .cosmic-hide-mobile { display: none !important; }
}

/* ── Tablet: 768–1023px ──────────────────── */
@media (min-width: 768px) and (max-width: 1023px) {
  .cosmic-card {
    padding: 1.25rem;
  }
  .cosmic-hide-tablet { display: none !important; }
}

/* ── Desktop: 1024px+ ────────────────────── */
@media (min-width: 1024px) {
  .cosmic-hide-desktop { display: none !important; }
}

/* ── NFT Detail Modal responsive ─────────── */
@media (max-width: 767px) {
  #nftDetailModal .modal-dialog {
    max-width: 98vw !important;
    width: 98vw !important;
    margin: 8px auto !important;
  }
  #nftDetailModal table {
    display: block !important;
  }
  #nftDetailModal table tr {
    display: flex !important;
    flex-direction: column !important;
  }
  #nftDetailModal table td {
    display: block !important;
    width: 100% !important;
  }
  #nftDetailModal table td:first-child {
    padding: 16px 12px !important;
  }
  #nftDetailModal table td:first-child div[style*="width:320px"] {
    width: 100% !important;
    max-width: 260px !important;
    height: auto !important;
    aspect-ratio: 1/1;
  }
}

/* ── Swap page responsive ────────────────── */
@media (max-width: 767px) {
  .swap-confirm-card {
    width: 95vw !important;
    max-width: 95vw !important;
    padding: 18px !important;
  }
}

/* ── FAB responsive ──────────────────────── */
@media (max-width: 600px) {
  .fab-wrap {
    bottom: 12px !important;
    padding: 6px 10px !important;
    gap: 4px !important;
    width: calc(100vw - 24px) !important;
    left: 12px !important;
    transform: none !important;
    justify-content: center;
    flex-wrap: wrap;
  }
  .fab-btn {
    padding: 8px 10px !important;
    font-size: 0.72rem !important;
    flex: 1 1 auto;
    min-height: 44px;
    justify-content: center;
  }
  .fab-sep {
    display: none !important;
  }
}

/* ── Portfolio gallery responsive ─────────── */
@media (max-width: 480px) {
  .pg-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)) !important;
    gap: 8px !important;
  }
}

/* ── Incoming offers responsive ──────────── */
@media (max-width: 600px) {
  .io-row {
    flex-wrap: wrap;
    gap: 8px;
  }
  .io-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

/* ── Activity feed responsive ────────────── */
@media (max-width: 480px) {
  .af-row {
    flex-wrap: wrap;
    gap: 6px;
  }
  .af-hash {
    width: 100%;
  }
}

/* Scrollable content padding for FAB on mobile */
@media (max-width: 600px) {
  .db-wrap {
    padding-bottom: 80px !important;
  }
}
