/* ================================
   1. Global Reset & Variables
================================ */
:root {
  --bg-dark: #0a0e17;
  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --input-bg: rgba(0, 0, 0, 0.2);
  --input-text: #ffffff;
  --card-bg: rgba(255, 255, 255, 0.03);
  --card-hover: rgba(255, 255, 255, 0.08);

  --primary: #6366f1;
  --accent: #ec4899;
  --success: #10b981;
  --danger: #ef4444;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;

  --font-main: 'Inter', sans-serif;
  --font-display: 'Outfit', sans-serif;
}

[data-theme="light"] {
  --bg-dark: #f0f4f8;
  --glass-bg: rgba(255, 255, 255, 0.85);
  --glass-border: rgba(0, 0, 0, 0.08);
  --glass-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  --input-bg: rgba(0, 0, 0, 0.04);
  --input-text: #1e293b;
  --card-bg: rgba(0, 0, 0, 0.03);
  --card-hover: rgba(0, 0, 0, 0.06);
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --primary: #4f46e5;
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  transition: background-color 0.3s, color 0.3s;
}

/* ================================
   2. Background Blobs (Ambient)
================================ */
.background-blobs {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  overflow: hidden;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.4;
  animation: float 10s infinite ease-in-out;
}

.blob-1 {
  width: 400px;
  height: 400px;
  background: var(--primary);
  top: -100px;
  left: -100px;
}

.blob-2 {
  width: 500px;
  height: 500px;
  background: var(--accent);
  bottom: -150px;
  right: -100px;
  animation-delay: 2s;
}

.blob-3 {
  width: 300px;
  height: 300px;
  background: #3b82f6;
  top: 40%;
  left: 30%;
  opacity: 0.2;
  animation-delay: 4s;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(30px, -30px); }
}

/* ================================
   3. Glass Components
================================ */
.glass-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 5%;
  background: rgba(10, 14, 23, 0.7);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--glass-border);
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background 0.3s, border-color 0.3s;
}

[data-theme="light"] .glass-nav {
  background: rgba(255, 255, 255, 0.9);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 2rem;
  box-shadow: var(--glass-shadow);
  transition: background 0.3s, border-color 0.3s, box-shadow 0.3s;
}

/* ================================
   4. Typography & Elements
================================ */
.logo {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.highlight {
  color: var(--primary);
}

.nav-links {
  display: flex;
  gap: 2.5rem;
  list-style: none;
}

.nav-links a {
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 500;
  transition: color 0.3s;
}

.nav-links a.active,
.nav-links a:hover {
  color: var(--text-main);
}

.btn-connect {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--glass-border);
  color: white;
  padding: 0.6rem 1.2rem;
  border-radius: 50px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s;
}

.btn-connect:hover {
  background: rgba(255, 255, 255, 0.2);
}

.small {
  width: 36px;
  height: 36px;
  padding: 0;
}

/* ================================
   5. Dashboard Layout
================================ */
.dashboard-container {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  padding: 3rem 5%;
  max-width: 1400px;
  margin: 0 auto;
}

.top-section {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 2rem;
  width: 100%;
}

/* ================================
   6. Converter Section
================================ */
.converter-section {
  width: 100%;
}

.slider-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: 500px; /* Match converter height approx */
}

.bottom-section {
  width: 100%;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.card-header h2, .card-header h3 {
  font-family: var(--font-display);
  font-weight: 600;
}

.live-badge {
  font-size: 0.75rem;
  color: var(--success);
  background: rgba(16, 185, 129, 0.1);
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.currency-input-group {
  background: var(--input-bg);
  border-radius: 16px;
  padding: 1.2rem;
  border: 1px solid transparent;
  transition: border-color 0.3s, background 0.3s;
}

.currency-input-group:focus-within {
  border-color: var(--primary);
}

.label-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.8rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.input-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

input[type="number"],
input[type="text"] {
  background: transparent;
  border: none;
  color: var(--input-text);
  font-size: 1.8rem;
  font-weight: 600;
  width: 60%;
  font-family: var(--font-display);
  transition: color 0.3s;
}

input:focus {
  outline: none;
}

.select-wrapper {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  background: var(--glass-bg);
  padding: 0.5rem 1rem;
  border-radius: 50px;
  cursor: pointer;
  min-width: 140px;
  position: relative;
  border: 1px solid var(--glass-border);
  transition: all 0.3s ease;
}

.select-wrapper:hover,
.select-wrapper:focus-within {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.flag-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

select {
  background: transparent;
  border: none;
  color: var(--input-text);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  transition: all 0.3s;
  padding: 0.5rem 2rem 0.5rem 0.5rem;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  background-size: 1.2em;
}

select option {
  background-color: var(--bg-dark);
  color: var(--text-main);
  padding: 12px;
}

select:focus {
  outline: none;
}

/* Swap Button */
.swap-container {
  display: flex;
  justify-content: center;
  margin: -1rem 0;
  position: relative;
  z-index: 10;
}

.btn-icon {
  background: var(--glass-bg);
  border: 2px solid var(--glass-border);
  color: var(--primary);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center; /* FIXED: Centers icon horizontally */
  cursor: pointer;
  transition: transform 0.3s, background 0.3s, border-color 0.3s;
}

.btn-icon:hover {
  border-color: var(--primary);
  background: var(--glass-border);
}

/* Rate Info */
.rate-info {
  display: flex;
  justify-content: space-between;
  margin: 1.5rem 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Main Action Button */
.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  border: none;
  padding: 1.2rem;
  border-radius: 16px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s;
}

.btn-primary:hover {
  transform: translateY(-2px);
}

.glow-effect {
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
}

/* ================================
   7. Live Rate Slider
================================ */
.slider-container {
  flex: 1;
  overflow: hidden;
  position: relative;
  mask-image: linear-gradient(to bottom, transparent, black 10%, black 90%, transparent);
  -webkit-mask-image: linear-gradient(to bottom, transparent, black 10%, black 90%, transparent);
}

.slider-track {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  animation: scrollUp 30s linear infinite; /* Slower animation for readability */
}

.slider-track:hover {
  animation-play-state: paused;
}

.slider-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: var(--card-bg);
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  transition: background 0.3s;
}

.slider-item:hover {
  background: var(--card-hover);
}

.pair-info {
  display: flex;
  flex-direction: column;
}

.pair-info .code {
  font-weight: 700;
  color: var(--text-main);
  font-size: 1rem;
}

.pair-info .name {
  font-size: 0.75rem;
  color: var(--text-muted);
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.slider-item .rate {
  font-family: var(--font-display);
  color: var(--primary);
  font-weight: 600;
  font-size: 1.1rem;
}

@keyframes scrollUp {
  0% { transform: translateY(0); }
  100% { transform: translateY(-50%); }
}

/* ================================
   8. Chart & Stats Section
================================ */
.chart-card {
  height: 400px;
  display: flex;
  flex-direction: column;
  margin-bottom: 2rem;
}

.time-filters {
  display: flex;
  gap: 0.5rem;
  background: var(--input-bg);
  padding: 0.3rem;
  border-radius: 12px;
}

.filter-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-btn.active,
.filter-btn:hover {
  padding: 12px;
}

select:focus {
  outline: none;
}

/* Swap Button */
.swap-container {
  display: flex;
  justify-content: center;
  margin: -1rem 0;
  position: relative;
  z-index: 10;
}

.btn-icon {
  background: var(--glass-bg);
  border: 2px solid var(--glass-border);
  color: var(--primary);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center; /* FIXED: Centers icon horizontally */
  cursor: pointer;
  transition: transform 0.3s, background 0.3s, border-color 0.3s;
}

.btn-icon:hover {
  border-color: var(--primary);
  background: var(--glass-border);
}

/* Rate Info */
.rate-info {
  display: flex;
  justify-content: space-between;
  margin: 1.5rem 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Main Action Button */
.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  border: none;
  padding: 1.2rem;
  border-radius: 16px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s;
}

.btn-primary:hover {
  transform: translateY(-2px);
}

.glow-effect {
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
}

/* ================================
   7. Live Rate Slider
================================ */
.slider-container {
  flex: 1;
  overflow: hidden;
  position: relative;
  mask-image: linear-gradient(to bottom, transparent, black 10%, black 90%, transparent);
  -webkit-mask-image: linear-gradient(to bottom, transparent, black 10%, black 90%, transparent);
}

.slider-track {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  animation: scrollUp 30s linear infinite; /* Slower animation for readability */
}

.slider-track:hover {
  animation-play-state: paused;
}

.slider-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: var(--card-bg);
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  transition: background 0.3s;
}

.slider-item:hover {
  background: var(--card-hover);
}

.pair-info {
  display: flex;
  flex-direction: column;
}

.pair-info .code {
  font-weight: 700;
  color: var(--text-main);
  font-size: 1rem;
}

.pair-info .name {
  font-size: 0.75rem;
  color: var(--text-muted);
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.slider-item .rate {
  font-family: var(--font-display);
  color: var(--primary);
  font-weight: 600;
  font-size: 1.1rem;
}

@keyframes scrollUp {
  0% { transform: translateY(0); }
  100% { transform: translateY(-50%); }
}

/* ================================
   8. Chart & Stats Section
================================ */
.chart-card {
  height: 400px;
  display: flex;
  flex-direction: column;
  margin-bottom: 2rem;
}

.time-filters {
  display: flex;
  gap: 0.5rem;
  background: var(--input-bg);
  padding: 0.3rem;
  border-radius: 12px;
}

.filter-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-btn.active,
.filter-btn:hover {
  background: var(--glass-bg);
  color: var(--text-main);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.chart-container {
  flex: 1;
  position: relative;
  width: 100%;
}

/* ================================
   9. Responsive
================================ */
@media (max-width: 900px) {
  .top-section {
    grid-template-columns: 1fr;
  }
  
  .dashboard-container {
    padding: 1.5rem;
  }

  .nav-links {
    display: none;
  }
}

@media (max-width: 600px) {
  .input-row {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  input[type="number"],
  input[type="text"] {
    width: 100%;
    font-size: 2rem; /* Larger font for mobile readability */
  }

  .select-wrapper {
    width: 100%;
    justify-content: space-between;
  }
  
  .currency-input-group {
    padding: 1rem;
  }
}