/* ══════════════════════════════════════════════════════
   Pearl Earnings Calculator — TailAdmin-inspired Dark Theme
   Design System: Outfit font, rounded-2xl cards, subtle borders,
   clean spacing, muted labels, Chart.js integrated
   ══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ── CSS Variables ── */
:root {
  --bg-body: #0c111d;
  --bg-card: rgba(255,255,255,0.03);
  --bg-card-hover: rgba(255,255,255,0.05);
  --bg-input: #1a2231;
  --bg-icon-box: #1d2939;
  --bg-header: #101828;
  --border: rgba(255,255,255,0.05);
  --border-light: rgba(255,255,255,0.08);
  --text-primary: rgba(255,255,255,0.9);
  --text-secondary: #98a2b3;
  --text-muted: #667085;
  --text-dim: #475467;

  --brand: #465fff;
  --brand-light: rgba(70,95,255,0.12);
  --pearl: #6fd5e4;
  --pearl-bg: rgba(111,213,228,0.12);
  --success: #12b76a;
  --success-bg: rgba(18,183,106,0.12);
  --error: #f04438;
  --error-bg: rgba(240,68,56,0.12);
  --warning: #f79009;
  --warning-bg: rgba(247,144,9,0.12);
  --gold: #f7d978;
  --gold-bg: rgba(247,217,120,0.12);

  --font-main: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 8px -2px rgba(16,24,40,0.1), 0 2px 4px -2px rgba(16,24,40,0.06);
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: var(--font-main);
  background: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}
a { color: var(--pearl); text-decoration: none; }
a:hover { text-decoration: underline; }
input, button { font-family: var(--font-main); }
.mono { font-family: var(--font-mono); }

/* ── Layout ── */
.app-wrapper { display: flex; flex-direction: column; min-height: 100vh; }
.app-header {
  position: sticky; top: 0; z-index: 999;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  height: 64px;
  display: flex; align-items: center;
  padding: 0 24px;
}
.header-brand {
  font-size: 18px; font-weight: 800;
  color: var(--text-primary);
  white-space: nowrap;
  margin-right: 24px;
}
.header-brand em { font-style: normal; color: var(--pearl); }
.header-search {
  flex: 1; max-width: 600px;
  position: relative;
}
.header-search input {
  width: 100%;
  height: 40px;
  padding: 0 16px 0 40px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color .2s;
}
.header-search input:focus { border-color: var(--pearl); caret-color: var(--pearl); }
.header-search::before {
  content: '🔍'; position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%); font-size: 14px; opacity: .5;
}
.header-actions {
  margin-left: auto;
  display: flex; align-items: center; gap: 12px;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 18px;
  font-size: 14px; font-weight: 600;
  border: none; border-radius: var(--radius-sm);
  cursor: pointer; transition: all .15s;
  gap: 6px;
}
.btn-brand { background: var(--brand); color: #fff; }
.btn-brand:hover { background: #3641f5; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-outline {
  background: transparent; border: 1px solid var(--border-light);
  color: var(--text-secondary);
}
.btn-outline:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); }
.btn-outline.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-outline-warning { border-color: rgba(247,144,9,.3); color: var(--warning); }
.btn-outline-warning:hover { background: var(--warning-bg); }
.btn-outline-error { border-color: rgba(240,68,56,.3); color: var(--error); }
.btn-outline-error:hover { background: var(--error-bg); }
.btn-outline-dim { border-color: var(--border-light); color: var(--text-muted); }
.btn-outline-dim:hover { color: var(--text-primary); background: rgba(255,255,255,0.04); }

.sync-pill {
  font-size: 12px; color: var(--pearl);
  display: flex; align-items: center; gap: 4px;
}

.main-content { flex: 1; padding: 24px; max-width: 1400px; margin: 0 auto; width: 100%; }
.footer-bar {
  padding: 20px 24px; text-align: center;
  font-size: 12px; color: var(--text-muted);
  border-top: 1px solid var(--border);
}

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: background .2s;
}
.card:hover { background: var(--bg-card-hover); }
.card-body { padding: 20px 24px; }
.card-title {
  font-size: 16px; font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
}
.card-title small { font-weight: 400; font-size: 12px; color: var(--warning); margin-left: 8px; }

/* ── Metric Cards (TailAdmin-style) ── */
.metric-grid { display: grid; gap: 16px; margin-bottom: 24px; }
.metric-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.metric-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.metric-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.metric-grid.cols-6 { grid-template-columns: repeat(6, 1fr); }

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: all .2s;
}
.metric-card:hover { background: var(--bg-card-hover); }
.metric-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  margin-bottom: 16px;
}
.metric-icon.bg-pearl { background: var(--pearl-bg); }
.metric-icon.bg-success { background: var(--success-bg); }
.metric-icon.bg-warning { background: var(--warning-bg); }
.metric-icon.bg-error { background: var(--error-bg); }
.metric-icon.bg-brand { background: var(--brand-light); }
.metric-icon.bg-gold { background: var(--gold-bg); }
.metric-label {
  font-size: 12px; font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.metric-value {
  font-family: var(--font-mono);
  font-size: 24px; font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}
.metric-value small { font-size: 14px; font-weight: 500; color: var(--text-secondary); }
.metric-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* Color accents for metric values */
.text-pearl { color: var(--pearl) !important; }
.text-success { color: var(--success) !important; }
.text-error { color: var(--error) !important; }
.text-warning { color: var(--warning) !important; }
.text-gold { color: var(--gold) !important; }
.text-brand { color: var(--brand) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-dim { color: var(--text-dim) !important; }
.text-right { text-align: right; }
.text-center { text-align: center; }

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

/* ── Tabs ── */
.tabs {
  display: flex; align-items: center;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  gap: 4px;
  overflow-x: auto;
}
.tab-btn {
  padding: 10px 20px;
  font-size: 14px; font-weight: 500;
  color: var(--text-muted);
  background: none; border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer; transition: all .15s;
  white-space: nowrap;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Profit Sub-tabs + Time Range ── */
.profit-controls {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
  margin-bottom: 20px;
}
.pill-group {
  display: flex; gap: 4px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 3px;
}
.pill-btn {
  padding: 6px 16px;
  font-size: 12px; font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: none; border-radius: 6px;
  cursor: pointer; transition: all .15s;
  letter-spacing: .03em;
}
.pill-btn:hover { color: var(--text-primary); }
.pill-btn.active {
  background: var(--brand);
  color: #fff;
}
.range-group {
  display: flex; gap: 4px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 3px;
}
.range-btn {
  padding: 6px 14px;
  font-size: 12px; font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: none; border-radius: 6px;
  cursor: pointer; transition: all .15s;
}
.range-btn:hover { color: var(--text-primary); }
.range-btn.active {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

/* ── Tables ── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-card);
}
.table-wrap.scroll { max-height: 600px; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  position: sticky; top: 0;
  padding: 12px 16px;
  font-size: 12px; font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .04em;
  text-align: left;
  border-bottom: 1px solid var(--border);
  background: var(--bg-input);
  white-space: nowrap;
}
tbody td {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-family: var(--font-mono);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.02); }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px;
  font-size: 11px; font-weight: 600;
  border-radius: 999px;
  letter-spacing: .02em;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-error { background: var(--error-bg); color: var(--error); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-brand { background: var(--brand-light); color: var(--brand); }
.badge-pearl { background: var(--pearl-bg); color: var(--pearl); }
.badge-dim { background: rgba(255,255,255,0.05); color: var(--text-muted); }

/* ── Input Row ── */
.input-row {
  display: flex; align-items: center; gap: 8px;
}
.input-sm {
  width: 90px; height: 36px;
  padding: 0 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
}
.input-sm:focus { border-color: var(--brand); }

/* ── Miner Info Bar ── */
.miner-bar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--pearl);
  border-radius: var(--radius-lg);
  padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
  margin-bottom: 24px;
}
.miner-addr {
  font-family: var(--font-mono);
  font-size: 12px; color: var(--pearl);
  word-break: break-all;
}

/* ── Landing ── */
.landing-card {
  text-align: center; padding: 80px 30px;
}
.landing-card h2 { font-size: 28px; font-weight: 800; margin-bottom: 12px; }
.landing-card h2 em { font-style: normal; color: var(--pearl); }
.landing-card p { color: var(--text-secondary); max-width: 500px; margin: 0 auto; }
.badge-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 20px; }
.badge-row .badge { padding: 6px 14px; font-size: 12px; }

/* ── Charts ── */
.chart-container { position: relative; height: 220px; }

/* ── Price/Cost Bar ── */
.config-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.config-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
}
.config-left h6 { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.config-left .val { font-family: var(--font-mono); font-size: 22px; font-weight: 700; }
.config-left .sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-body); }
::-webkit-scrollbar-thumb { background: #344054; border-radius: 3px; }

/* ── Toast Notifications ── */
#toastContainer {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-main);
  color: #fff;
  backdrop-filter: blur(16px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.06);
  transform: translateX(120%);
  opacity: 0;
  animation: toastSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  max-width: 420px;
  min-width: 280px;
}
.toast.toast-out {
  animation: toastSlideOut 0.35s cubic-bezier(0.55, 0, 1, 0.45) forwards;
}
.toast-success {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.92), rgba(5, 150, 105, 0.88));
  border: 1px solid rgba(52, 211, 153, 0.3);
}
.toast-error {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.92), rgba(220, 38, 38, 0.88));
  border: 1px solid rgba(252, 165, 165, 0.3);
}
.toast-info {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.92), rgba(8, 145, 178, 0.88));
  border: 1px solid rgba(103, 232, 249, 0.3);
}
.toast-icon {
  font-size: 18px;
  flex-shrink: 0;
}
.toast-body {
  flex: 1;
  line-height: 1.4;
}
.toast-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  font-size: 16px;
  padding: 2px;
  flex-shrink: 0;
  transition: color 0.15s;
}
.toast-close:hover {
  color: #fff;
}
@keyframes toastSlideIn {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes toastSlideOut {
  from { transform: translateX(0);    opacity: 1; }
  to   { transform: translateX(120%); opacity: 0; }
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .metric-grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .metric-grid.cols-6 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-2 { grid-template-columns: 1fr; }
  .grid.cols-3 { grid-template-columns: 1fr; }
  .config-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .main-content { padding: 16px; }
  .app-header { padding: 0 12px; }
  .metric-grid.cols-4 { grid-template-columns: 1fr; }
  .metric-grid.cols-6 { grid-template-columns: 1fr; }
  .header-brand { display: none; }
}

/* ── Market Cards Link Underline Override ── */
#marketPricesRow a, 
#marketPricesRow a * {
  text-decoration: none !important;
}
