/* ============================================
   CODACOIN — Modern Crypto Dashboard
   Dark theme · Responsive · Future-proof
   ============================================ */

/* ---- Design Tokens ---- */
:root {
    --bg: #08080d;
    --bg-card: #111118;
    --bg-hover: #1a1a26;
    --border: #22222e;
    --text: #d4d4e0;
    --text-dim: #7a7a99;
    --text-muted: #4a4a66;
    --green: #22c55e;
    --green-bg: rgba(34, 197, 94, .12);
    --red: #ef4444;
    --red-bg: rgba(239, 68, 68, .12);
    --accent: #3b82f6;
    --accent-dim: #2563eb;
    --radius: 8px;
    --radius-lg: 12px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --mono: 'SF Mono', 'Fira Code', 'Courier New', monospace;
    --max-w: 860px;
    --gap: 16px;
}

/* ---- Reset ---- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
    overflow-x: hidden;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    padding: 0 var(--gap) 48px;
    max-width: var(--max-w);
    margin: 0 auto;
    min-height: 100vh;
}

a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color .15s;
}

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

img {
    display: inline-block;
    vertical-align: middle;
}

.hidden {
    display: none !important;
}

/* ---- Shared Card ---- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    margin-bottom: var(--gap);
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: .82rem;
    font-weight: 500;
    padding: 7px 14px;
    transition: background .15s, border-color .15s;
}

.btn--accent {
    background: var(--accent);
    color: #fff;
}

.btn--accent:hover {
    background: var(--accent-dim);
}

.btn--ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
}

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

.btn--sm {
    padding: 5px 10px;
    font-size: .78rem;
}

/* ---- Utility Colors ---- */
.up {
    color: var(--green);
}

.down {
    color: var(--red);
}


/* ==============================================================
   HALVING BANNER
   ============================================================== */
.halving-banner {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 8px 14px;
    margin: 10px 0;
    overflow-x: auto;
    font-size: .8rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    scrollbar-width: thin;
}

.halving-banner::-webkit-scrollbar {
    height: 4px;
}

.halving-banner::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.halving-banner__label {
    font-weight: 700;
    color: #f7931a;
    white-space: nowrap;
}

.halving-banner__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    white-space: nowrap;
}

.halving-banner__k {
    font-size: .65rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: .3px;
}

.halving-banner__v {
    font-family: var(--mono);
    color: var(--text-dim);
    font-size: .82rem;
}


/* ==============================================================
   COIN HERO (main price display) — horizontal layout
   ============================================================== */
.coin-hero {
    padding: 20px 0 8px;
}

.coin-hero__loading {
    color: var(--text-muted);
    text-align: center;
}

.coin-hero__wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.coin-hero__icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    flex-shrink: 0;
}

.coin-hero__info {
    display: flex;
    flex-direction: column;
}

.coin-hero__price-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.coin-hero__sym-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.coin-hero__sym {
    font-size: 2.2rem;
    color: var(--text-muted);
    font-weight: 700;
    font-family: var(--mono);
    line-height: 1.1;
}

.coin-hero__name {
    font-size: .55rem;
    color: var(--text-dim);
    font-weight: 500;
    letter-spacing: .5px;
    text-transform: uppercase;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
    margin-top: 1px;
}

.coin-hero__price {
    font-size: 2.2rem;
    font-weight: 700;
    font-family: var(--mono);
    transition: color .25s;
    line-height: 1.1;
}

.coin-hero__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    font-size: .85rem;
    color: var(--text-dim);
    margin-top: 2px;
}

.coin-hero__meta span {
    white-space: nowrap;
}

.hero-change {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.hero-change__label {
    font-size: .65rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: .3px;
}

.chart-hover-price {
    font-family: var(--mono);
    font-size: .78rem;
    color: var(--accent);
}

.coin-hero__price.hovering {
    color: var(--accent);
}


/* ==============================================================
   EXCHANGE TABS
   ============================================================== */
.exchange-tabs {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: 12px;
}

.exchange-tabs__btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 14px;
    color: var(--text-dim);
    font-size: .82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s;
}

.exchange-tabs__btn.has-coin {
    color: var(--text);
}

.exchange-tabs__btn:hover {
    border-color: var(--accent);
    color: var(--text);
}

.exchange-tabs__btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.exchange-tabs__btn.no-coin {
    opacity: .45;
}

.exchange-tabs__btn.no-coin:hover {
    opacity: .75;
}

.exchange-tabs__count {
    font-size: .68rem;
    opacity: .7;
    font-family: var(--mono);
}


/* ==============================================================
   PRICE CHART
   ============================================================== */
.chart-section {
    max-width: 360px;
    margin-left: auto;
    margin-right: auto;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: max-width .25s ease, background .15s, border-color .15s, padding .25s ease, margin .25s ease;
    border-radius: var(--radius);
}

/* ---- Collapsed (default) ---- */
.chart-section.collapsed {
    background: transparent;
    border: 1px solid transparent;
    padding: 0;
    margin-bottom: 4px;
}

.chart-section.collapsed .chart-section__header {
    display: none;
}

.chart-section.collapsed .chart-section__wrap {
    height: 56px;
}

.chart-section.collapsed:hover {
    border-color: var(--border);
}

/* ---- Expanded ---- */
.chart-section.expanded {
    max-width: 520px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 16px;
    margin-bottom: 12px;
}

.chart-section.expanded .chart-section__header {
    display: flex;
}

.chart-section.expanded .chart-section__wrap {
    height: 140px;
}

.chart-section__header {
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 8px;
    gap: 8px;
}

.chart-section__title {
    font-size: .9rem;
    font-weight: 600;
    color: var(--text);
}

.chart-section__stats {
    font-size: .78rem;
    font-family: var(--mono);
    color: var(--text-dim);
}

.chart-section__wrap {
    position: relative;
    transition: height .25s ease;
}

.chart-section__wrap canvas {
    width: 100% !important;
    height: 100% !important;
}


/* ==============================================================
   CONVERTER
   ============================================================== */
.converter {
    max-width: 520px;
    margin-left: auto;
    margin-right: auto;
}

.converter__search-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

.converter__row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.converter__logo img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.converter__input {
    flex: 1;
    min-width: 110px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--mono);
    font-size: 1.05rem;
    padding: 9px 11px;
    outline: none;
    transition: border-color .2s;
}

.converter__input:focus {
    border-color: var(--accent);
}

.input-wrap {
    position: relative;
    display: flex;
    flex: 1;
    min-width: 110px;
    width: 100%;
}

.input-wrap .converter__input {
    width: 100%;
    padding-right: 32px;
}

.input-wrap input[type=number]::-webkit-inner-spin-button,
.input-wrap input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.input-wrap input[type=number] {
    -moz-appearance: textfield;
    appearance: textfield;
}

.btn-clear {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    transition: background 0.1s, color 0.1s;
}

.btn-clear:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.converter__actions-left {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    padding-left: 42px;
    /* aligns under crypto-input: 32px logo + 10px gap */
}

.btn--halving {
    color: #f7931a !important;
    border-color: rgba(247, 147, 26, .35) !important;
    margin-left: auto;
}

.btn--halving:hover {
    border-color: #f7931a !important;
    background: rgba(247, 147, 26, .08) !important;
}

.converter__eq {
    color: var(--text-muted);
    font-size: 1.3rem;
}

.converter__curr-sym {
    color: var(--text-dim);
    font-size: 1.1rem;
    font-weight: 600;
    font-family: var(--mono);
    flex-shrink: 0;
}

.converter__actions {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 10px;
}


/* ==============================================================
   PORTFOLIO
   ============================================================== */
.portfolio {
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
    overflow-x: auto;
}

.portfolio table {
    width: 100%;
    border-collapse: collapse;
}

.portfolio th,
.portfolio td {
    padding: 7px 10px;
    font-size: .85rem;
    text-align: right;
    white-space: nowrap;
}

.portfolio th {
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: .7rem;
    font-weight: 500;
    border-bottom: 1px solid var(--border);
}

.portfolio td:nth-child(1),
.portfolio th:nth-child(1) {
    text-align: center;
}

.portfolio td:nth-child(3),
.portfolio th:nth-child(3) {
    text-align: left;
}

.portfolio .pf-row {
    cursor: pointer;
    transition: background .1s;
}

.portfolio .pf-row:hover {
    background: var(--bg-hover);
}

.portfolio .pf-row.pf-selected {
    background: var(--accent-dim);
    color: #fff;
}

.btn--del {
    background: none;
    border: none;
    color: var(--red);
    cursor: pointer;
    font-size: .9rem;
    padding: 2px 6px;
    border-radius: 4px;
    opacity: .6;
    transition: opacity .15s;
}

.btn--del:hover {
    opacity: 1;
    background: var(--red-bg);
}

.portfolio__total {
    text-align: center;
    padding: 10px 0 2px;
    font-size: 1.4rem;
    font-weight: 700;
    font-family: var(--mono);
    border-top: 1px solid var(--border);
    margin-top: 6px;
}


/* ==============================================================
   TOP COINS
   ============================================================== */
.top-coins {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin-bottom: var(--gap);
}

.top-coins a {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 5px 10px;
    font-size: .78rem;
    transition: background .15s;
}

.top-coins a:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.top-coins img {
    width: 16px;
    height: 16px;
    border-radius: 50%;
}


/* ==============================================================
   COINS BOX — wraps sentiment bar + all-coins ticker
   Full-bleed minus 2px screen gap on each side
   ============================================================== */
.coins-box {
    width: 100vw;
    margin-left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    overflow: hidden;
    margin-bottom: var(--gap);
    padding: 0;
    /* sentiment + all-coins handle their own padding */
}

/* Sentiment bar (sits on top of all-coins, with its own subtle border) */
.sentiment-bar {
    display: flex;
    height: 28px;
    overflow: hidden;
    font-size: .8rem;
    font-weight: 600;
    font-family: var(--mono);
    border-bottom: 1px solid var(--border);
}

.sentiment-bar__up {
    background: var(--green-bg);
    color: var(--green);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 10px;
    transition: width .6s ease;
    white-space: nowrap;
}

.sentiment-bar__down {
    background: var(--red-bg);
    color: var(--red);
    display: flex;
    align-items: center;
    padding: 0 10px;
    transition: width .6s ease;
    white-space: nowrap;
}


/* ==============================================================
   ALL COINS TICKER  (the iconic box with colored arrows)
   Full-bleed: breaks out of body max-width, edge-to-edge
   ============================================================== */
.all-coins {
    padding: 10px 12px;
    line-height: 1.65;
    font-size: .68rem;
    word-break: break-word;
}

.all-coins__count {
    color: var(--text-muted);
    font-size: .62rem;
    margin-left: 2px;
}

/* Individual coin link in the ticker */
.coin-tag {
    display: inline;
    white-space: nowrap;
    margin-right: 1px;
    transition: color .12s;
}

.coin-tag:hover {
    color: var(--accent) !important;
}

.coin-tag__name {
    font-weight: 600;
    font-size: .66rem;
}

.coin-tag__price {
    font-family: var(--mono);
    font-size: .64rem;
}

.coin-tag__arrow {
    font-weight: 700;
    font-size: .62rem;
}

.coin-tag__pct {
    font-family: var(--mono);
    font-size: .6rem;
}

.coin-sep {
    color: var(--text-muted);
    margin: 0 1px;
    user-select: none;
    font-size: .55rem;
    opacity: .4;
}


/* ==============================================================
   SEARCH (inside converter)
   ============================================================== */
.search-box {
    position: relative;
    flex: 1;
}

#coin-search {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 7px 12px;
    width: 100%;
    font-size: .88rem;
    outline: none;
}

#coin-search:focus {
    border-color: var(--accent);
}

.ctrl-label {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--text-dim);
    font-size: .82rem;
}

select {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 4px 8px;
    font-size: .82rem;
    cursor: pointer;
}

select:focus {
    outline: none;
    border-color: var(--accent);
}

/* Search Dropdown */
.search-dd {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 300;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-height: 320px;
    overflow-y: auto;
    list-style: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
}

/* Styled scrollbar */
.search-dd::-webkit-scrollbar {
    width: 6px;
}

.search-dd::-webkit-scrollbar-track {
    background: var(--bg-card);
    border-radius: 0 var(--radius) var(--radius) 0;
}

.search-dd::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.search-dd::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.search-dd {
    scrollbar-width: thin;
    scrollbar-color: var(--border) var(--bg-card);
}

.search-dd__item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background .1s;
}

.search-dd__item:hover,
.search-dd__item.active {
    background: var(--bg-hover);
}

.search-dd__item img {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    flex-shrink: 0;
}

.search-dd__sym {
    font-weight: 600;
    color: var(--text);
    font-size: .85rem;
    min-width: 50px;
}

.search-dd__name {
    color: var(--text-dim);
    font-size: .78rem;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-dd__price {
    font-family: var(--mono);
    font-size: .78rem;
    color: var(--text-dim);
}

.search-dd__empty {
    padding: 12px;
    color: var(--text-muted);
    font-size: .82rem;
    text-align: center;
}

/* Footer Bar */
.footer-bar {
    display: flex;
    align-items: center;
    padding: 10px 0 16px;
    font-size: .75rem;
}

.footer-bar__left,
.footer-bar__right {
    flex: 1;
}

.footer-bar__left {
    color: var(--text-muted);
}

.footer-bar__right {
    text-align: right;
    color: var(--text-muted);
}

.footer-bar__ts {
    color: var(--text-muted);
}

/* ── mytools.studio credit footer ── */
.mytools-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.mytools-footer__link {
    display: flex;
    align-items: center;
    gap: 7px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: lowercase;
    transition: color 0.15s;
}

.mytools-footer__link:hover { color: var(--text-dim); }

.mytools-footer__logo {
    width: 20px;
    height: 20px;
    border-radius: 5px;
    opacity: 0.75;
    transition: opacity 0.15s;
    flex-shrink: 0;
}

.mytools-footer__link:hover .mytools-footer__logo { opacity: 1; }

.mytools-footer__label {
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 1px;
    transition: border-color 0.15s, color 0.15s;
}

.mytools-footer__link:hover .mytools-footer__label {
    border-bottom-color: var(--accent);
    color: var(--accent);
}

.mytools-footer__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
    flex-shrink: 0;
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5);
    animation: mts-pulse 2.4s ease-in-out infinite;
}

@keyframes mts-pulse {
    0%   { opacity: 1;    box-shadow: 0 0 0 0   rgba(34, 197, 94, 0.55); }
    50%  { opacity: 0.6;  box-shadow: 0 0 0 5px rgba(34, 197, 94, 0);    }
    100% { opacity: 1;    box-shadow: 0 0 0 0   rgba(34, 197, 94, 0.55); }
}


/* ==============================================================
   RESPONSIVE
   ============================================================== */
@media (max-width: 600px) {
    body {
        padding: 0 10px 32px;
        font-size: 14px;
    }

    .exchange-tabs {
        gap: 4px;
    }

    .exchange-tabs__btn {
        padding: 5px 8px;
        font-size: .72rem;
        gap: 3px;
    }

    .exchange-tabs__count {
        display: none;
    }

    .coin-hero__price {
        font-size: 1.7rem;
    }

    .coin-hero__icon {
        width: 44px;
        height: 44px;
    }

    .halving-banner {
        gap: 10px;
        font-size: .72rem;
    }

    #coin-search {
        font-size: .82rem;
    }

    .converter__row {
        gap: 6px;
    }

    .converter__input {
        min-width: 90px;
        font-size: .95rem;
        padding: 8px;
    }

    .coins-box {
        width: 100vw;
        margin-left: 50%;
        transform: translateX(-50%);
    }

    .all-coins {
        font-size: .62rem;
        line-height: 1.55;
        padding: 6px 8px;
    }

    .portfolio th,
    .portfolio td {
        font-size: .78rem;
        padding: 5px 6px;
    }
}