/* =========================================================
   ALPHA MARKETS
   Clean Minimal Market Interface
   File: public_html/markets.css
   Styled to match Assets section
   ========================================================= */


/* =========================================================
   1. DESIGN TOKENS
   ========================================================= */

:root {
    --alpha-yellow: #F0B90B;
    --alpha-yellow-hover: #DFAE00;
    --alpha-yellow-soft: #FFF8DB;

    --alpha-bg: #FFFFFF;
    --alpha-soft-bg: #F7F8FA;

    --alpha-text: #181A20;
    --alpha-muted: #707A8A;
    --alpha-light-muted: #9AA1AC;

    --alpha-border: #EAECEF;
    --alpha-border-strong: #D8DCE1;

    --alpha-success: #0ECB81;
    --alpha-success-soft: #EAFBF4;

    --alpha-danger: #F6465D;
    --alpha-danger-soft: #FFF0F2;

    --alpha-warning: #B58400;
    --alpha-warning-soft: #FFF8DB;

    --safe-top:
        env(safe-area-inset-top, 0px);

    --safe-bottom:
        env(safe-area-inset-bottom, 0px);

    --header-height: 60px;
    --bottom-nav-height: 76px;

    --content-width: 980px;

    --transition: 160ms ease;
}


/* =========================================================
   2. RESET
   ========================================================= */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    width: 100%;
    min-width: 320px;
    min-height: 100%;

    overflow-x: hidden;

    background: var(--alpha-bg);

    scroll-behavior: smooth;

    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    width: 100%;
    min-width: 320px;
    min-height: 100vh;

    margin: 0;

    overflow-x: hidden;

    background: var(--alpha-bg);
    color: var(--alpha-text);

    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Helvetica,
        Arial,
        sans-serif;

    font-size: 14px;
    line-height: 1.5;

    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body.markets-page {
    padding-bottom:
        calc(
            var(--bottom-nav-height)
            + var(--safe-bottom)
            + 26px
        );
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

button {
    margin: 0;
}

button:not(:disabled),
a {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

a {
    color: inherit;
    text-decoration: none;
}

img,
svg {
    display: block;
    max-width: 100%;
}

h1,
h2,
h3,
p {
    margin: 0;
}

[hidden] {
    display: none !important;
}

::selection {
    background: rgba(240, 185, 11, 0.22);
    color: var(--alpha-text);
}


/* =========================================================
   3. FOCUS
   ========================================================= */

button:focus-visible,
a:focus-visible,
input:focus-visible {
    outline: 3px solid rgba(240, 185, 11, 0.26);
    outline-offset: 2px;
}


/* =========================================================
   4. CONTAINER
   ========================================================= */

.markets-container {
    width: min(
        calc(100% - 28px),
        var(--content-width)
    );

    margin-inline: auto;
}


/* =========================================================
   5. ALERT
   ========================================================= */

.markets-alert {
    position: fixed;

    top:
        calc(
            var(--safe-top)
            + var(--header-height)
            + 9px
        );

    left: 50%;
    z-index: 1600;

    width: min(
        calc(100% - 28px),
        420px
    );

    padding: 10px 13px;

    border: 1px solid var(--alpha-border);
    border-radius: 10px;

    background: #FFFFFF;
    color: var(--alpha-text);

    box-shadow:
        0 10px 28px
        rgba(24, 26, 32, 0.10);

    font-size: 12px;
    font-weight: 600;
    text-align: center;

    transform: translateX(-50%);
}

.markets-alert.is-success {
    border-color: rgba(14, 203, 129, 0.28);
    color: #087A4F;
}

.markets-alert.is-error {
    border-color: rgba(246, 70, 93, 0.28);
    color: #C92E44;
}

.markets-alert.is-warning {
    border-color: rgba(240, 185, 11, 0.35);
    color: #806000;
}


/* =========================================================
   6. HEADER
   ========================================================= */

.markets-header {
    position: sticky;
    top: 0;
    z-index: 700;

    width: 100%;

    padding-top: var(--safe-top);

    border-bottom: 1px solid var(--alpha-border);

    background: rgba(255, 255, 255, 0.97);

    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.markets-header__inner {
    min-height: var(--header-height);

    display: grid;

    grid-template-columns:
        38px
        minmax(0, 1fr)
        38px;

    align-items: center;

    gap: 8px;
}

.header-back-button,
.header-refresh-button {
    width: 38px;
    height: 38px;

    display: grid;
    place-items: center;

    padding: 0;

    border: 0;
    border-radius: 50%;

    background: transparent;
    color: var(--alpha-text);

    transition:
        background var(--transition),
        transform var(--transition);
}

.header-back-button:hover,
.header-refresh-button:hover {
    background: var(--alpha-soft-bg);
}

.header-back-button:active,
.header-refresh-button:active {
    transform: scale(0.95);
}

.header-back-button svg,
.header-refresh-button svg {
    width: 21px;
    height: 21px;
}

.header-refresh-button.is-loading svg {
    animation:
        alpha-market-spin
        0.8s
        linear
        infinite;
}

@keyframes alpha-market-spin {
    to {
        transform: rotate(360deg);
    }
}

.markets-page-title {
    min-width: 0;

    overflow: hidden;

    color: var(--alpha-text);

    font-size: 20px;
    line-height: 1.2;
    font-weight: 600;

    letter-spacing: -0.3px;

    text-overflow: ellipsis;
    white-space: nowrap;
}


/* =========================================================
   7. MAIN
   ========================================================= */

.markets-main {
    width: 100%;

    padding:
        24px
        0
        28px;
}


/* =========================================================
   8. INTRO
   ========================================================= */

.markets-intro {
    width: 100%;

    display: flex;
    align-items: flex-start;
    justify-content: space-between;

    gap: 16px;

    padding-bottom: 20px;

    border-bottom: 1px solid var(--alpha-border);
}

.markets-intro__copy {
    min-width: 0;
}

.markets-intro__copy h2 {
    color: var(--alpha-text);

    font-size: 18px;
    line-height: 1.25;
    font-weight: 600;

    letter-spacing: -0.25px;
}

.markets-intro__copy p {
    margin-top: 5px;

    color: var(--alpha-muted);

    font-size: 11px;
    line-height: 1.5;
    font-weight: 400;
}

.market-status {
    min-height: 29px;

    flex: 0 0 auto;

    display: inline-flex;
    align-items: center;

    gap: 6px;

    padding:
        0
        9px;

    border: 1px solid var(--alpha-border);
    border-radius: 999px;

    background: #FFFFFF;
    color: var(--alpha-muted);

    font-size: 9px;
    line-height: 1;
    font-weight: 600;
}

.market-status__dot {
    width: 7px;
    height: 7px;

    flex: 0 0 auto;

    border-radius: 50%;

    background: var(--alpha-light-muted);
}

.market-status.is-live {
    color: #087A4F;

    border-color:
        rgba(
            14,
            203,
            129,
            0.25
        );

    background: var(--alpha-success-soft);
}

.market-status.is-live
.market-status__dot {
    background: var(--alpha-success);
}

.market-status.is-error {
    color: #C92E44;

    border-color:
        rgba(
            246,
            70,
            93,
            0.25
        );

    background: var(--alpha-danger-soft);
}

.market-status.is-error
.market-status__dot {
    background: var(--alpha-danger);
}


/* =========================================================
   9. SEARCH
   ========================================================= */

.market-search-section {
    width: 100%;

    padding-top: 20px;
}

.market-search {
    width: 100%;
    min-height: 44px;

    display: grid;

    grid-template-columns:
        20px
        minmax(0, 1fr)
        34px;

    align-items: center;

    gap: 8px;

    padding:
        0
        5px
        0
        12px;

    border: 1px solid var(--alpha-border);
    border-radius: 10px;

    background: var(--alpha-soft-bg);

    transition:
        border-color var(--transition),
        background var(--transition),
        box-shadow var(--transition);
}

.market-search:focus-within {
    border-color: var(--alpha-yellow);

    background: #FFFFFF;

    box-shadow:
        0 0 0 3px
        rgba(240, 185, 11, 0.10);
}

.market-search > svg {
    width: 18px;
    height: 18px;

    color: var(--alpha-muted);
}

.market-search input {
    width: 100%;
    height: 42px;

    padding: 0;

    border: 0;
    outline: 0;

    background: transparent;
    color: var(--alpha-text);

    font-size: 12px;
    line-height: 1;
    font-weight: 500;
}

.market-search input::placeholder {
    color: var(--alpha-light-muted);
    font-weight: 400;
}

.market-search__clear {
    width: 32px;
    height: 32px;

    display: grid;
    place-items: center;

    padding: 0;

    border: 0;
    border-radius: 50%;

    background: transparent;
    color: var(--alpha-muted);
}

.market-search__clear:hover {
    background: #FFFFFF;
    color: var(--alpha-text);
}

.market-search__clear svg {
    width: 17px;
    height: 17px;
}


/* =========================================================
   10. FILTERS
   ========================================================= */

.market-filter-section {
    width: 100%;

    padding-top: 13px;
}

.market-filter-tabs {
    width: 100%;

    display: flex;
    align-items: center;

    gap: 20px;

    overflow-x: auto;

    border-bottom: 1px solid var(--alpha-border);

    scrollbar-width: none;
}

.market-filter-tabs::-webkit-scrollbar {
    display: none;
}

.market-filter-tab {
    position: relative;

    min-height: 42px;

    flex: 0 0 auto;

    padding:
        0
        1px;

    border: 0;

    background: transparent;
    color: var(--alpha-muted);

    font-size: 12px;
    line-height: 1;
    font-weight: 500;

    white-space: nowrap;
}

.market-filter-tab.is-active {
    color: var(--alpha-text);

    font-weight: 600;
}

.market-filter-tab.is-active::after {
    content: "";

    position: absolute;

    right: 0;
    bottom: -1px;
    left: 0;

    height: 2px;

    border-radius:
        999px
        999px
        0
        0;

    background: var(--alpha-yellow);
}


/* =========================================================
   11. MARKET LIST SECTION
   ========================================================= */

.market-list-section {
    width: 100%;
}


/* =========================================================
   12. TABLE HEADER
   ========================================================= */

.market-list-header {
    width: 100%;
    min-height: 38px;

    display: grid;

    grid-template-columns:
        minmax(0, 1fr)
        minmax(88px, auto)
        minmax(62px, auto);

    align-items: center;

    gap: 10px;

    color: var(--alpha-light-muted);

    font-size: 9px;
    line-height: 1;
    font-weight: 500;

    border-bottom: 1px solid var(--alpha-border);
}

.market-list-header span:nth-child(2),
.market-list-header span:nth-child(3) {
    text-align: right;
}


/* =========================================================
   13. MARKET LIST
   ========================================================= */

.market-list {
    width: 100%;
}


/* =========================================================
   14. MARKET ROW
   ========================================================= */

.market-row {
    width: 100%;
    min-height: 68px;

    display: grid;

    grid-template-columns:
        minmax(0, 1fr)
        minmax(88px, auto)
        minmax(62px, auto);

    align-items: center;

    gap: 10px;

    padding:
        10px
        0;

    border-bottom: 1px solid var(--alpha-border);

    background: transparent;

    transition:
        opacity var(--transition),
        background var(--transition);
}

.market-row:hover {
    background: transparent;
}

.market-row:active {
    opacity: 0.72;
}

.market-row__asset {
    min-width: 0;

    display: flex;
    align-items: center;

    gap: 10px;
}

.market-row__icon {
    width: 36px;
    height: 36px;

    flex: 0 0 auto;

    display: grid;
    place-items: center;

    border: 1px solid rgba(240, 185, 11, 0.22);
    border-radius: 50%;

    background: var(--alpha-yellow-soft);
    color: #8A6900;

    font-size: 9px;
    line-height: 1;
    font-weight: 700;

    letter-spacing: -0.2px;
}

.market-row__identity {
    min-width: 0;

    display: flex;
    flex-direction: column;

    gap: 1px;
}

.market-row__symbol {
    overflow: hidden;

    color: var(--alpha-text);

    font-size: 13px;
    line-height: 1.35;
    font-weight: 650;

    text-overflow: ellipsis;
    white-space: nowrap;
}

.market-row__name {
    overflow: hidden;

    color: var(--alpha-muted);

    font-size: 10px;
    line-height: 1.35;
    font-weight: 400;

    text-overflow: ellipsis;
    white-space: nowrap;
}

.market-row__price-group,
.market-row__change-group {
    min-width: 0;

    display: flex;
    flex-direction: column;
    align-items: flex-end;

    text-align: right;
}

.market-row__price {
    width: 100%;
    max-width: 150px;

    overflow: hidden;

    color: var(--alpha-text);

    font-size: 12px;
    line-height: 1.35;
    font-weight: 650;

    font-variant-numeric: tabular-nums;

    text-overflow: ellipsis;
    white-space: nowrap;
}

.market-row__volume {
    width: 100%;
    max-width: 150px;

    overflow: hidden;

    margin-top: 2px;

    color: var(--alpha-light-muted);

    font-size: 8px;
    line-height: 1.3;
    font-weight: 400;

    text-overflow: ellipsis;
    white-space: nowrap;
}

.market-row__change {
    font-size: 11px;
    line-height: 1.35;
    font-weight: 650;

    font-variant-numeric: tabular-nums;

    white-space: nowrap;
}

.market-row__change.is-positive {
    color: var(--alpha-success);
}

.market-row__change.is-negative {
    color: var(--alpha-danger);
}

.market-row__change.is-neutral {
    color: var(--alpha-muted);
}


/* =========================================================
   15. LOADING SKELETON
   ========================================================= */

.market-list-loading {
    width: 100%;
}

.market-skeleton-row {
    width: 100%;
    min-height: 68px;

    display: grid;

    grid-template-columns:
        36px
        minmax(0, 1fr)
        78px
        58px;

    align-items: center;

    gap: 10px;

    padding:
        10px
        0;

    border-bottom: 1px solid var(--alpha-border);
}

.market-skeleton-group {
    min-width: 0;

    display: flex;
    flex-direction: column;

    gap: 6px;
}

.market-skeleton {
    display: block;

    border-radius: 999px;

    background:
        linear-gradient(
            90deg,
            #F0F1F3 25%,
            #F7F8FA 50%,
            #F0F1F3 75%
        );

    background-size: 200% 100%;

    animation:
        market-skeleton-shimmer
        1.2s
        linear
        infinite;
}

.market-skeleton--circle {
    width: 36px;
    height: 36px;

    border-radius: 50%;
}

.market-skeleton--name {
    width: 58%;
    height: 10px;
}

.market-skeleton--small {
    width: 40%;
    height: 8px;
}

.market-skeleton--price {
    width: 72px;
    height: 10px;

    justify-self: end;
}

.market-skeleton--change {
    width: 52px;
    height: 10px;

    justify-self: end;
}

@keyframes market-skeleton-shimmer {
    to {
        background-position: -200% 0;
    }
}


/* =========================================================
   16. EMPTY / ERROR STATES
   ========================================================= */

.market-empty-state,
.market-error-state {
    width: 100%;
    min-height: 220px;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    padding:
        28px
        18px;

    border-bottom: 1px solid var(--alpha-border);

    background: transparent;

    text-align: center;
}

.market-empty-state__icon,
.market-error-state__icon {
    width: 42px;
    height: 42px;

    display: grid;
    place-items: center;

    margin-bottom: 10px;

    border-radius: 50%;

    background: var(--alpha-soft-bg);
    color: var(--alpha-muted);
}

.market-error-state__icon {
    background: var(--alpha-danger-soft);
    color: var(--alpha-danger);
}

.market-empty-state__icon svg,
.market-error-state__icon svg {
    width: 20px;
    height: 20px;
}

.market-empty-state strong,
.market-error-state strong {
    color: var(--alpha-text);

    font-size: 12px;
    line-height: 1.35;
    font-weight: 600;
}

.market-empty-state > span:last-child,
.market-error-state > span {
    max-width: 260px;

    margin-top: 4px;

    color: var(--alpha-muted);

    font-size: 10px;
    line-height: 1.5;
    font-weight: 400;
}

.market-error-state button {
    min-height: 38px;

    margin-top: 13px;

    padding:
        0
        14px;

    border: 0;
    border-radius: 8px;

    background: var(--alpha-yellow);
    color: var(--alpha-text);

    font-size: 11px;
    line-height: 1;
    font-weight: 600;

    transition:
        background var(--transition),
        transform var(--transition);
}

.market-error-state button:hover {
    background: var(--alpha-yellow-hover);
}

.market-error-state button:active {
    transform: scale(0.97);
}


/* =========================================================
   17. BOTTOM NAVIGATION
   EXACT ASSETS STYLE
   ========================================================= */

.bottom-navigation {
    position: fixed;

    right: 0;
    bottom: 0;
    left: 0;

    z-index: 800;

    padding-bottom: var(--safe-bottom);

    border-top: 1px solid rgba(234, 236, 239, 0.95);

    background: rgba(255, 255, 255, 0.97);

    box-shadow:
        0 -8px 28px
        rgba(24, 26, 32, 0.055);

    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.bottom-navigation__inner {
    width: min(
        100%,
        var(--content-width)
    );

    min-height: var(--bottom-nav-height);

    display: grid;

    grid-template-columns:
        repeat(5, minmax(0, 1fr));

    align-items: center;

    margin-inline: auto;
}

.bottom-navigation__item {
    position: relative;

    min-width: 0;
    min-height: 68px;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    gap: 4px;

    padding:
        6px
        2px;

    border-radius: 14px;

    background: transparent;
    color: var(--alpha-muted);

    font-size: 10px;
    line-height: 1.15;
    font-weight: 650;

    text-align: center;

    transition:
        color var(--transition),
        background var(--transition);
}

.bottom-navigation__item:hover {
    color: var(--alpha-text);
}

.bottom-navigation__item.is-active,
.bottom-navigation__item[aria-current="page"] {
    background: transparent;

    color: var(--alpha-text);

    font-weight: 750;
}

.bottom-navigation__item::before {
    content: none;
}

.bottom-navigation__item.is-active::before,
.bottom-navigation__item[aria-current="page"]::before {
    content: "";

    position: absolute;

    top: 4px;
    left: 50%;

    width: 34px;
    height: 3px;

    border-radius: 999px;

    background: var(--alpha-yellow);

    transform: translateX(-50%);
}

.bottom-navigation__icon {
    width: 24px;
    height: 24px;

    display: grid;
    place-items: center;
}

.bottom-navigation__icon svg {
    width: 100%;
    height: 100%;
}

.bottom-navigation__item.is-active
.bottom-navigation__icon,
.bottom-navigation__item[aria-current="page"]
.bottom-navigation__icon {
    color: var(--alpha-text);
}


/* =========================================================
   18. NOSCRIPT
   ========================================================= */

.noscript-message {
    position: fixed;

    right: 14px;

    bottom:
        calc(
            var(--bottom-nav-height)
            + var(--safe-bottom)
            + 14px
        );

    left: 14px;

    z-index: 1900;

    padding:
        12px
        14px;

    border: 1px solid rgba(246, 70, 93, 0.28);
    border-radius: 10px;

    background: var(--alpha-danger-soft);
    color: #B52F43;

    font-size: 12px;
    font-weight: 600;

    text-align: center;
}


/* =========================================================
   19. SMALL MOBILE
   ========================================================= */

@media (max-width: 379px) {

    :root {
        --header-height: 58px;
        --bottom-nav-height: 72px;
    }

    .markets-container {
        width: min(
            calc(100% - 22px),
            var(--content-width)
        );
    }

    .markets-header__inner {
        grid-template-columns:
            36px
            minmax(0, 1fr)
            36px;
    }

    .header-back-button,
    .header-refresh-button {
        width: 36px;
        height: 36px;
    }

    .markets-page-title {
        font-size: 18px;
    }

    .markets-main {
        padding-top: 21px;
    }

    .markets-intro {
        gap: 9px;
    }

    .markets-intro__copy h2 {
        font-size: 16px;
    }

    .markets-intro__copy p {
        font-size: 10px;
    }

    .market-status {
        padding:
            0
            7px;

        font-size: 8px;
    }

    .market-list-header,
    .market-row {
        grid-template-columns:
            minmax(0, 1fr)
            minmax(74px, auto)
            minmax(54px, auto);

        gap: 7px;
    }

    .market-row__icon {
        width: 34px;
        height: 34px;

        font-size: 8px;
    }

    .market-row__symbol {
        font-size: 12px;
    }

    .market-row__name {
        font-size: 9px;
    }

    .market-row__price {
        max-width: 90px;

        font-size: 11px;
    }

    .market-row__volume {
        max-width: 90px;

        font-size: 7px;
    }

    .market-row__change {
        font-size: 10px;
    }

    .bottom-navigation__item {
        font-size: 9px;
    }

    .bottom-navigation__icon {
        width: 22px;
        height: 22px;
    }

    .market-skeleton-row {
        grid-template-columns:
            34px
            minmax(0, 1fr)
            64px
            48px;

        gap: 7px;
    }

    .market-skeleton--circle {
        width: 34px;
        height: 34px;
    }

    .market-skeleton--price {
        width: 60px;
    }

    .market-skeleton--change {
        width: 44px;
    }
}


/* =========================================================
   20. TABLET
   ========================================================= */

@media (min-width: 600px) {

    :root {
        --header-height: 64px;
    }

    .markets-container {
        width: min(
            calc(100% - 40px),
            var(--content-width)
        );
    }

    .markets-main {
        padding-top: 30px;
    }

    .markets-main
    > .markets-container {
        max-width: 720px;
    }

    .markets-intro__copy h2 {
        font-size: 19px;
    }

    .market-row {
        min-height: 72px;
    }

    .market-row__icon {
        width: 38px;
        height: 38px;
    }

    .market-row__symbol {
        font-size: 13px;
    }

    .market-row__price {
        font-size: 12px;
    }

    .bottom-navigation__item {
        font-size: 11px;
    }
}


/* =========================================================
   21. DESKTOP
   ========================================================= */

@media (min-width: 900px) {

    :root {
        --header-height: 68px;
    }

    .markets-main {
        padding-top: 36px;
    }

    .markets-main
    > .markets-container {
        max-width: 740px;
    }

    .market-row {
        min-height: 74px;
    }

    .bottom-navigation {
        right: 22px;
        bottom: 18px;
        left: 22px;

        max-width: 720px;

        margin-inline: auto;

        padding-bottom: 0;

        border: 1px solid var(--alpha-border);
        border-radius: 22px;

        background: rgba(255, 255, 255, 0.98);

        box-shadow:
            0 18px 50px
            rgba(24, 26, 32, 0.14);
    }

    .bottom-navigation__inner {
        min-height: 72px;
    }

    .bottom-navigation__item {
        min-height: 60px;

        margin: 5px;
    }
}


/* =========================================================
   22. REDUCED MOTION
   ========================================================= */

@media (prefers-reduced-motion: reduce) {

    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}