/* ============================================================================
 * css/cain-page.css — shared shell styling for Cain Finance sub-pages
 * ----------------------------------------------------------------------------
 * Lifted from index / Swap / Lending so new pages inherit the same look without
 * copy-pasting it again. Sidebar styling is NOT here — /js/sidebar.js owns that.
 * ========================================================================== */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background-color: #060606; color: #fff;
  -webkit-font-smoothing: antialiased;
  font-family: 'Inter', sans-serif;
}

.dot-grid {
  background-image: radial-gradient(rgba(255,255,255,0.07) 1px, transparent 1px);
  background-size: 24px 24px;
}

/* ── Layout ─────────────────────────────────────────────────────────────── */
.app-shell { display: flex; height: 100vh; overflow: hidden; }
.cain-main { flex: 1; display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.cain-scroll { flex: 1; overflow-y: auto; padding: 40px 32px 80px; }
.cain-content { max-width: 1180px; margin: 0 auto; }

/* ── Topbar ─────────────────────────────────────────────────────────────── */
.cain-topbar {
  height: 64px; padding: 0 32px; display: flex; align-items: center;
  justify-content: space-between; flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.cain-search-wrap { flex: 1; max-width: 420px; position: relative; }

/* ── Field component ────────────────────────────────────────────────────────
 * A real search/entry field, not a bare <input>.
 *
 * SPECIFICITY MATTERS HERE. Tailwind's forms plugin injects
 *   [type="text"], input:where(:not([type])), … { background-color:#fff }
 * at runtime, which lands AFTER this stylesheet in the cascade. A plain
 * `.cain-search` class ties it at (0,0,1,0) and loses, which is exactly how
 * these fields ended up white-on-white. Every rule below is written as
 * `.cain-field > .cain-field-input` (0,0,2,0) or tighter so it wins outright
 * without resorting to !important.
 * ------------------------------------------------------------------------- */
.cain-field {
  position: relative; display: flex; align-items: center; width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  transition: border-color .16s ease, background .16s ease, box-shadow .16s ease;
}
.cain-field:hover { border-color: rgba(255,255,255,0.18); }
.cain-field.is-focused {
  border-color: rgba(0,255,163,0.55);
  background: rgba(255,255,255,0.07);
  box-shadow: 0 0 0 3px rgba(0,255,163,0.10);
}
.cain-field.is-invalid {
  border-color: rgba(255,77,77,0.55);
  box-shadow: 0 0 0 3px rgba(255,77,77,0.10);
}
.cain-field.is-valid { border-color: rgba(0,255,163,0.35); }

.cain-field > .cain-field-icon {
  display: flex; align-items: center; flex-shrink: 0;
  padding-left: 12px; color: #555; pointer-events: none;
  transition: color .16s ease;
}
.cain-field.is-focused > .cain-field-icon { color: #00ffa3; }
.cain-field > .cain-field-icon svg { width: 16px; height: 16px; }

.cain-field > .cain-field-input {
  flex: 1; min-width: 0;
  background: transparent;
  border: none; outline: none; box-shadow: none;
  padding: 9px 10px; margin: 0;
  font-family: 'Inter', sans-serif; font-size: 13px; color: #fff;
  -webkit-appearance: none; appearance: none;
}
.cain-field > .cain-field-input:focus { outline: none; box-shadow: none; }
.cain-field > .cain-field-input::placeholder { color: #4a4a4a; }
.cain-field > .cain-field-input::-webkit-search-cancel-button { display: none; }

/* Trailing slot: chips, counts, clear button, key hint */
.cain-field > .cain-field-tail {
  display: flex; align-items: center; gap: 6px;
  flex-shrink: 0; padding-right: 8px;
}
.cain-field-count {
  font-size: 10px; color: #666; font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.cain-field-chip {
  font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  padding: 3px 7px; border-radius: 999px; white-space: nowrap;
  background: rgba(255,255,255,0.07); color: #888;
}
.cain-field-chip.ok  { background: rgba(0,255,163,0.13); color: #00ffa3; }
.cain-field-chip.bad { background: rgba(255,77,77,0.13); color: #ff6b6b; }

.cain-field-btn {
  display: none; align-items: center; justify-content: center;
  width: 20px; height: 20px; padding: 0; flex-shrink: 0;
  border: none; border-radius: 6px; cursor: pointer;
  background: rgba(255,255,255,0.08); color: #999;
  font-family: 'Inter', sans-serif; line-height: 1;
  transition: background .14s, color .14s;
}
.cain-field-btn:hover { background: rgba(255,255,255,0.16); color: #fff; }
.cain-field-btn.show { display: flex; }
.cain-field-btn svg { width: 11px; height: 11px; }

.cain-field-kbd { display: flex; align-items: center; gap: 3px; }
.cain-field-kbd kbd {
  font-family: 'Inter', sans-serif; font-size: 9px; font-weight: 600; color: #666;
  padding: 2px 5px; border: 1px solid rgba(255,255,255,0.14);
  border-radius: 4px; background: rgba(255,255,255,0.05); line-height: 1.3;
}
.cain-field.is-focused .cain-field-kbd { display: none; }

/* Larger variant for the wallet address entry */
.cain-field.cain-field-lg { border-radius: 14px; }
.cain-field.cain-field-lg > .cain-field-input {
  padding: 13px 12px; font-size: 13.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.cain-field.cain-field-lg > .cain-field-icon { padding-left: 14px; }
.cain-field.cain-field-lg > .cain-field-icon svg { width: 17px; height: 17px; }

.cain-field-hint {
  font-size: 11px; color: #5a5a5a; margin-top: 8px; min-height: 15px;
}
.cain-field-hint.bad { color: #ff6b6b; }
.cain-field-hint.ok  { color: #00ffa3; }
.cain-topbar-actions { display: flex; align-items: center; gap: 12px; }
.cain-icon-btn {
  padding: 8px; color: #555; border-radius: 8px; display: flex;
  background: none; border: none; cursor: pointer; transition: color .15s;
}
.cain-icon-btn:hover { color: #fff; }
.cain-divider { width: 1px; height: 32px; background: rgba(255,255,255,0.1); }

/* ── Dropdown ───────────────────────────────────────────────────────────── */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  display: none; position: absolute; right: 0; top: calc(100% + 8px);
  background: #141414; border: 1px solid #2a2a2a; border-radius: 10px;
  min-width: 160px; z-index: 50; overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.dropdown-menu.open { display: block; }
.dropdown-menu a {
  display: block; padding: 10px 16px; font-size: 13px; color: #bbb;
  text-decoration: none; transition: background .12s, color .12s;
}
.dropdown-menu a:hover { background: #1e1e1e; color: #fff; }

/* ── Page headings ──────────────────────────────────────────────────────── */
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  flex-wrap: wrap; gap: 16px; margin-bottom: 26px;
}
.page-title { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; margin: 0 0 6px; }
.page-sub   { font-size: 12px; color: #555; margin: 0; }
.section-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
  color: #555; margin: 30px 0 12px; font-weight: 600;
}
.section-label:first-child { margin-top: 0; }

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.07);
  border-radius: 18px; padding: 20px;
}
.card-tight { padding: 16px; border-radius: 14px; }
.card-grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1000px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px)  { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }

.stat-label { font-size: 10px; text-transform: uppercase; letter-spacing: .8px; color: #555; margin-bottom: 8px; font-weight: 600; }
.stat-value { font-size: 24px; font-weight: 700; letter-spacing: -0.5px; line-height: 1.1; }
.stat-sub   { font-size: 11px; color: #666; margin-top: 6px; }
.up   { color: #00ffa3; }
.down { color: #ff4d4d; }

/* ── Tables ─────────────────────────────────────────────────────────────── */
.table-wrap {
  border: 1px solid rgba(255,255,255,0.06); border-radius: 20px;
  overflow: hidden; background: rgba(255,255,255,0.015);
}
.cain-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.cain-table thead th {
  text-align: left; padding: 13px 18px; font-size: 10px; text-transform: uppercase;
  letter-spacing: .8px; color: #555; font-weight: 600;
  border-bottom: 1px solid rgba(255,255,255,0.06); white-space: nowrap;
}
.cain-table tbody td {
  padding: 13px 18px; border-bottom: 1px solid rgba(255,255,255,0.04);
  color: #ddd; white-space: nowrap;
}
.cain-table tbody tr:last-child td { border-bottom: none; }
.cain-table tbody tr { transition: background .12s; }
.cain-table tbody tr:hover { background: rgba(255,255,255,0.03); }
.num { font-variant-numeric: tabular-nums; }
.t-right { text-align: right; }
.table-scroll { overflow-x: auto; }

/* ── Pills / tags ───────────────────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px;
  border-radius: 999px; font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .5px;
}
.pill-green { background: rgba(0,255,163,0.12); color: #00ffa3; }
.pill-red   { background: rgba(255,77,77,0.12);  color: #ff4d4d; }
.pill-gray  { background: rgba(255,255,255,0.06); color: #888; }
.pill-gold  { background: rgba(201,184,122,0.14); color: #c9b87a; }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  padding: 9px 18px; border-radius: 12px; font-size: 13px; font-weight: 600;
  cursor: pointer; border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.06); color: #fff;
  font-family: 'Inter', sans-serif; transition: background .15s, border-color .15s;
}
.btn:hover { background: rgba(255,255,255,0.12); }
.btn-primary { background: #fff; color: #060606; border-color: #fff; }
.btn-primary:hover { background: #e6e6e6; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.tabs {
  display: flex; gap: 6px; background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07); border-radius: 14px;
  padding: 4px; width: fit-content;
}
.tab {
  padding: 8px 22px; border-radius: 10px; font-size: 13px; font-weight: 600;
  cursor: pointer; border: none; background: transparent; color: #666;
  transition: all .15s; font-family: 'Inter', sans-serif;
}
.tab.active { background: rgba(255,255,255,0.1); color: #fff; }
.tab:hover:not(.active) { color: #aaa; }

/* ── States ─────────────────────────────────────────────────────────────── */
.state {
  padding: 44px 20px; text-align: center; font-size: 13px; color: #555;
}
.state-error { color: #ff4d4d; }
.spinner {
  display: inline-block; width: 15px; height: 15px; vertical-align: -2px;
  border: 2px solid rgba(255,255,255,0.15); border-top-color: #fff;
  border-radius: 50%; animation: cain-spin .7s linear infinite; margin-right: 8px;
}
@keyframes cain-spin { to { transform: rotate(360deg); } }

.skel {
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.08) 37%, rgba(255,255,255,0.04) 63%);
  background-size: 400% 100%; animation: cain-shimmer 1.3s ease infinite;
  border-radius: 6px; height: 13px;
}
@keyframes cain-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.info-note {
  margin-top: 16px; padding: 14px 16px; background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.05); border-radius: 14px;
  display: flex; gap: 10px; align-items: flex-start;
  font-size: 12px; color: #777; line-height: 1.5;
}
.info-note a { color: #aaa; }

.src-tag { font-size: 10px; color: #444; letter-spacing: .3px; }

/* ============================================================================
 * Wallet connect — copied VERBATIM from index.html (lines 289-424) so the
 * Connect button, its dropdown and the wallet-adapter modal look and behave
 * identically on every page. Do not diverge from index.html here; if that page
 * changes its wallet styling, re-copy this block rather than hand-editing it.
 * ========================================================================== */
  
  #wallet-btn {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 8px 16px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.15s;
    white-space: nowrap;
  }
  #wallet-btn:hover { background: rgba(255,255,255,0.14); }

  
  #wallet-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    background: #111;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 14px;
    min-width: 190px;
    z-index: 200;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0,0,0,0.7);
  }
  #wallet-dropdown.hidden { display: none; }
  #wallet-dropdown a {
    display: block;
    padding: 11px 16px;
    font-size: 13px;
    color: #aaa;
    text-decoration: none;
    transition: background 0.12s, color 0.12s;
  }
  #wallet-dropdown a:hover { background: rgba(255,255,255,0.05); color: #fff; }

  
  .wallet-adapter-modal-overlay {
    background: rgba(0,0,0,0.7) !important;
    backdrop-filter: blur(6px);
  }
  .wallet-adapter-modal-wrapper {
    background: #0f0f0f !important;
    border: 1px solid rgba(255,255,255,0.08) !important;
    border-radius: 24px !important;
    box-shadow: 0 24px 64px rgba(0,0,0,0.7) !important;
    font-family: 'Inter', sans-serif !important;
    
    padding: 28px 24px 24px !important;
    max-width: 400px !important;
    width: calc(100% - 32px) !important;
    box-sizing: border-box !important;
  }
  .wallet-adapter-modal-title {
    color: #fff !important;
    font-size: 18px !important;
    font-weight: 600 !important;
    line-height: 1.4 !important;
    text-align: center !important;
    
    padding: 0 36px !important;
    margin: 2px 0 22px !important;
  }
  
  .wallet-adapter-modal-list {
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    width: 100% !important;
  }
  .wallet-adapter-modal-list li { margin: 0 !important; padding: 0 !important; }
  .wallet-adapter-modal-list .wallet-adapter-button {
    width: 100% !important;
    height: 52px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 12px !important;
    padding: 0 18px !important;
    margin: 0 !important;
    background: rgba(255,255,255,0.03) !important;
    border: 1px solid rgba(255,255,255,0.07) !important;
    border-radius: 14px !important;
    font-size: 15px !important;
    font-weight: 500 !important;
    color: #f5f5f5 !important;
    transition: background .15s, border-color .15s !important;
  }
  .wallet-adapter-modal-list .wallet-adapter-button:hover {
    background: rgba(255,255,255,0.07) !important;
    border-color: rgba(255,255,255,0.14) !important;
  }
  
  .wallet-adapter-modal-list .wallet-adapter-button-start-icon,
  .wallet-adapter-modal-list .wallet-adapter-button-start-icon img,
  .wallet-adapter-modal-list .wallet-adapter-button-start-icon svg {
    width: 26px !important;
    height: 26px !important;
    margin: 0 !important;
  }
  
  .wallet-adapter-modal-list .wallet-adapter-button-end-icon,
  .wallet-adapter-modal-list .wallet-adapter-button span:last-child:not(:first-child) {
    margin-left: auto !important;
  }
  
  .wallet-adapter-modal-list-more {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    margin: 16px auto 0 !important;
    color: #888 !important;
    font-size: 13px !important;
    cursor: pointer !important;
  }
  .wallet-adapter-modal-list-more svg { fill: #888 !important; }
  
  .wallet-adapter-modal-button-close {
    background: rgba(255,255,255,0.05) !important;
    top: 18px !important;
    right: 18px !important;
    padding: 8px !important;
    border-radius: 10px !important;
    transition: background .15s !important;
  }
  .wallet-adapter-modal-button-close:hover { background: rgba(255,255,255,0.1) !important; }

/* ── Site footer ────────────────────────────────────────────────────────────
 * Real <a href> links in the served HTML. The sidebar is injected by
 * /js/sidebar.js, so without this a crawler fetching the page source finds no
 * internal links at all — Googlebot does render JS, but that is a delayed
 * second pass and a poor thing to depend on for discovery.
 * ========================================================================== */
.site-footer {
  margin-top: 56px; padding-top: 26px;
  border-top: 1px solid rgba(255,255,255,0.07);
}
.site-footer-cols {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 26px;
}
@media (max-width: 760px) { .site-footer-cols { grid-template-columns: repeat(2, 1fr); } }
.site-footer h4 {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
  color: #555; font-weight: 600; margin: 0 0 11px;
}
.site-footer a {
  display: block; font-size: 12.5px; color: #888; text-decoration: none;
  padding: 4px 0; transition: color .14s;
}
.site-footer a:hover { color: #fff; }
.site-footer-base {
  margin-top: 26px; padding-top: 18px;
  border-top: 1px solid rgba(255,255,255,0.05);
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 12px;
  font-size: 11px; color: #4a4a4a;
}
