/* ═══════════════════════════════════════════════════════
   🧩 ELDEEB COIN — Shared Components
   Cards, Buttons, Forms, Tables, Modals, Badges
   ═══════════════════════════════════════════════════════ */

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(10px);
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-glow), transparent);
  opacity: 0;
  transition: var(--transition);
}

.card:hover {
  border-color: var(--border-accent);
  box-shadow: var(--shadow-md);
}
.card:hover::before { opacity: 1; }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .card-icon { font-size: 1.1rem; }

/* ── Stat Cards ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: -50%;
  right: -20px;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--stat-color, var(--accent));
  opacity: 0.04;
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-accent);
  box-shadow: var(--shadow-md);
}

.stat-card:hover::after { opacity: 0.08; }

.stat-card .stat-icon {
  font-size: 1.4rem;
  margin-bottom: 10px;
}

.stat-card .stat-value {
  font-family: 'Fira Code', monospace;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
  line-height: 1.2;
}

.stat-card .stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-card .stat-change {
  font-size: 0.7rem;
  font-family: 'Fira Code', monospace;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.stat-change.up { color: var(--accent-light); }
.stat-change.down { color: var(--red); }

/* ── KPI Cards (enhanced) ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}

.kpi-card:hover {
  border-color: var(--border-accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.kpi-card .kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.kpi-card .kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.kpi-icon.green { background: rgba(16, 185, 129, 0.1); }
.kpi-icon.cyan { background: rgba(6, 182, 212, 0.1); }
.kpi-icon.amber { background: rgba(245, 158, 11, 0.1); }
.kpi-icon.red { background: rgba(239, 68, 68, 0.1); }
.kpi-icon.purple { background: rgba(139, 92, 246, 0.1); }

.kpi-card .kpi-value {
  font-family: 'Fira Code', monospace;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 4px;
}

.kpi-card .kpi-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.kpi-card .kpi-trend {
  font-size: 0.7rem;
  font-family: 'Fira Code', monospace;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 20px;
  margin-top: 4px;
}

.kpi-trend.positive { background: rgba(16, 185, 129, 0.1); color: var(--accent-light); }
.kpi-trend.negative { background: rgba(239, 68, 68, 0.1); color: var(--red); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  background: var(--bg-glass);
  color: var(--text-primary);
  white-space: nowrap;
}
.btn:hover {
  background: var(--bg-glass-hover);
  border-color: var(--border-accent);
  transform: translateY(-1px);
}
.btn:active { transform: translateY(0); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent-dark), var(--accent));
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 2px 12px var(--accent-glow);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--red);
}
.btn-danger:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: var(--red);
}

.btn-sm { padding: 6px 12px; font-size: 0.75rem; }
.btn-lg { padding: 14px 28px; font-size: 0.95rem; }
.btn-icon { padding: 8px; min-width: 36px; }

.btn-ghost {
  background: transparent;
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--bg-glass);
  border-color: var(--border);
}

/* ── Form Elements ── */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.input, .select, .textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  transition: var(--transition);
  outline: none;
}

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

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

.select { cursor: pointer; appearance: none; }

.textarea { resize: vertical; min-height: 80px; }

/* ── Tables ── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead {
  background: var(--bg-tertiary);
}

th {
  padding: 12px 16px;
  text-align: right;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}

tr:hover td {
  background: rgba(16, 185, 129, 0.02);
}

tr:last-child td { border-bottom: none; }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-success { background: rgba(16, 185, 129, 0.12); color: var(--accent-light); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-warning { background: rgba(245, 158, 11, 0.12); color: var(--amber); border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-danger { background: rgba(239, 68, 68, 0.12); color: var(--red); border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-info { background: rgba(6, 182, 212, 0.12); color: var(--cyan); border: 1px solid rgba(6, 182, 212, 0.3); }
.badge-neutral { background: rgba(148, 163, 184, 0.12); color: var(--text-secondary); border: 1px solid rgba(148, 163, 184, 0.2); }

/* ── Panels ── */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: var(--transition);
}

.panel:hover { border-color: var(--border-accent); }

.panel-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
}

.panel-body { padding: 20px; }

/* ── Grid Layouts ── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Progress Bar ── */
.progress {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
  background: linear-gradient(90deg, var(--accent-dark), var(--accent-light));
}

.progress-fill.animated {
  background-size: 200% 100%;
  animation: progressShimmer 2s infinite;
}

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

/* ── Skeleton Loading ── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-glass) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

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

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 20px;
}

.tab {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  border: none;
  background: none;
  font-family: inherit;
}
.tab:hover { color: var(--text-primary); }
.tab.active {
  background: var(--bg-card);
  color: var(--accent-light);
  box-shadow: var(--shadow-sm);
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 540px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95);
  transition: var(--transition);
}

.modal-overlay.active .modal { transform: scale(1); }

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 { font-size: 1.1rem; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
  transition: var(--transition);
}
.modal-close:hover { color: var(--text-primary); }

.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-start;
  gap: 8px;
}

/* ── Live Indicators ── */
.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--red);
  border-radius: 50%;
  animation: liveBlink 1s ease-in-out infinite;
  box-shadow: 0 0 6px var(--red-glow);
}

@keyframes liveBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ── Empty States ── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-state .empty-text {
  font-size: 0.9rem;
}

/* ── Utilities ── */
.text-accent { color: var(--accent-light); }
.text-cyan { color: var(--cyan); }
.text-amber { color: var(--amber); }
.text-red { color: var(--red); }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.text-mono { font-family: 'Fira Code', monospace; }

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }

.w-full { width: 100%; }
.hidden { display: none !important; }
