/* Valo Companion — PWA shell. Palette inspirée Valorant. */

:root {
    --bg: #0f1923;
    --bg-elevated: #1f2731;
    --bg-card: #182028;
    --fg: #ece8e1;
    --fg-muted: #8b978f;
    --accent: #ff4655;
    --accent-soft: rgba(255, 70, 85, 0.15);
    --success: #00d68f;
    --danger: #ff5b5b;
    --border: rgba(236, 232, 225, 0.08);
    --radius: 12px;
    --space: 16px;
    --tab-height: 60px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--fg);
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-tap-highlight-color: transparent;
}

body {
    display: flex;
    flex-direction: column;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

body.has-tabbar main {
    padding-bottom: calc(var(--tab-height) + 24px);
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space) calc(var(--space) * 1.25);
    border-bottom: 1px solid var(--border);
}

.app-header h1 {
    font-size: 1.1rem;
    margin: 0;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.icon-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--fg);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:active { background: var(--accent-soft); }

main {
    flex: 1;
    padding: var(--space);
    display: flex;
    flex-direction: column;
}

.screen {
    display: flex;
    flex-direction: column;
    gap: var(--space);
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
}

.screen[hidden] { display: none; }

h2 {
    font-size: 1.4rem;
    margin: 0;
}

.hint {
    color: var(--fg-muted);
    font-size: 0.95rem;
    line-height: 1.4;
    margin: 0;
}

.hint code {
    background: var(--bg-elevated);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
}

form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

input[type="text"],
input[type="password"],
input[type="search"],
select {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    color: var(--fg);
    font-size: 1rem;
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
}

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

button {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius);
    padding: 14px 16px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
}

button:active { transform: scale(0.98); }
button:disabled { opacity: 0.5; cursor: wait; }

.ghost-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--fg-muted);
    font-weight: 400;
    margin-top: auto;
}

.error {
    color: var(--danger);
    font-size: 0.9rem;
    margin: 0;
}

/* --- Dashboard --- */

.account-block {
    text-align: center;
    color: var(--fg-muted);
    font-size: 1rem;
}

.game-name { color: var(--fg); font-weight: 600; }
.tag-line::before { content: "#"; color: var(--fg-muted); }

.rank-card {
    background: var(--bg-elevated);
    border-radius: var(--radius);
    padding: 28px 24px;
    text-align: center;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.rank-tier {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--accent);
    text-transform: uppercase;
}

.rank-rr { font-size: 3rem; font-weight: 800; color: var(--fg); line-height: 1; }
.rank-rr .unit { font-size: 1rem; color: var(--fg-muted); font-weight: 400; margin-left: 8px; }

.rank-meta {
    display: flex;
    justify-content: space-around;
    color: var(--fg-muted);
    font-size: 0.9rem;
}
.rank-meta strong { color: var(--fg); font-weight: 600; margin-right: 4px; }

.rank-delta { font-size: 0.95rem; color: var(--fg-muted); }
.rank-delta.positive { color: var(--success); }
.rank-delta.negative { color: var(--danger); }

.footer-hint { color: var(--fg-muted); font-size: 0.8rem; text-align: center; margin: 0; }

/* --- Wallet --- */

.wallet-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.wallet-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.wallet-card img {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    object-fit: contain;
}

.wallet-card-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    min-width: 0;
}

.wallet-amount {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--fg);
}

.wallet-code {
    color: var(--fg-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* --- Collection --- */

.collection-toolbar {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.filter-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.collection-count {
    color: var(--fg-muted);
    font-size: 0.85rem;
    margin: 0;
    text-align: right;
}

.skin-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.skin-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 64px;
}

.skin-card img {
    width: 90px;
    height: 36px;
    object-fit: contain;
    flex-shrink: 0;
}

.skin-card-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.skin-name {
    font-weight: 600;
    color: var(--fg);
    font-size: 0.95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.skin-meta {
    color: var(--fg-muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.skin-empty {
    text-align: center;
    color: var(--fg-muted);
    padding: 40px 16px;
    font-size: 0.9rem;
}

/* --- Stats card --- */

.stats-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stats-card-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    color: var(--fg-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stats-net {
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0;
}

.stats-net.positive { color: var(--success); }
.stats-net.negative { color: var(--danger); }

.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.stat { display: flex; flex-direction: column; align-items: center; }
.stat strong { font-size: 1.2rem; color: var(--fg); }
.stat span {
    font-size: 0.7rem;
    color: var(--fg-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 2px;
}

.rr-sparkline {
    width: 100%;
    height: 80px;
    overflow: hidden;
}

.rr-sparkline svg {
    width: 100%;
    height: 100%;
    display: block;
}

.rr-sparkline .axis-line { stroke: var(--border); stroke-dasharray: 2 4; }
.rr-sparkline .line { fill: none; stroke: var(--accent); stroke-width: 1.6; }
.rr-sparkline .area { fill: var(--accent); fill-opacity: 0.10; }
.rr-sparkline .point { fill: var(--accent); }
.rr-sparkline .point.win { fill: var(--success); }
.rr-sparkline .point.loss { fill: var(--danger); }
.rr-sparkline-empty {
    color: var(--fg-muted);
    font-size: 0.85rem;
    text-align: center;
    padding: 28px 0;
}

/* --- Shop --- */

.section-title {
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--fg);
    margin: 0;
    font-weight: 600;
}

.shop-block {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.shop-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.shop-timer {
    color: var(--fg-muted);
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}

.shop-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.shop-offer {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-top: 3px solid var(--border);
}

.shop-offer img {
    width: 100%;
    height: 56px;
    object-fit: contain;
}

.shop-offer-name {
    font-size: 0.85rem;
    color: var(--fg);
    font-weight: 600;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    min-height: 2.2em;
}

.shop-offer-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--fg-muted);
    font-size: 0.75rem;
}

.shop-offer-cost {
    color: var(--fg);
    font-weight: 700;
    font-size: 0.9rem;
}

.bundle-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bundle-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 0.85rem;
    color: var(--fg-muted);
}

.bundle-header strong { color: var(--fg); font-size: 1rem; }

/* --- Wishlist --- */

.inline-btn {
    width: auto;
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 500;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--fg-muted);
    border-radius: 6px;
}

.inline-btn:active { background: var(--accent-soft); }

.wishlist-search {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 320px;
    overflow: hidden;
}

.wishlist-results {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 240px;
}

.wishlist-result {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 6px;
    background: var(--bg-elevated);
    cursor: pointer;
}

.wishlist-result:active { background: var(--accent-soft); }
.wishlist-result img { width: 64px; height: 24px; object-fit: contain; }
.wishlist-result span { flex: 1; font-size: 0.85rem; }
.wishlist-result .add-icon { color: var(--accent); font-weight: 700; font-size: 1.1rem; }

.wishlist-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.wishlist-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--border);
    border-radius: var(--radius);
}

.wishlist-item img { width: 64px; height: 28px; object-fit: contain; flex-shrink: 0; }
.wishlist-item-text { flex: 1; min-width: 0; }
.wishlist-item-name { font-size: 0.85rem; font-weight: 600; color: var(--fg); }
.wishlist-item-meta { font-size: 0.7rem; color: var(--fg-muted); text-transform: uppercase; }
.wishlist-remove {
    background: transparent;
    border: none;
    color: var(--fg-muted);
    font-size: 1.3rem;
    width: 32px;
    height: 32px;
    padding: 0;
    cursor: pointer;
}

/* --- Push toggle --- */

.push-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    color: var(--fg-muted);
}

.push-btn { width: auto; padding: 6px 14px; font-size: 0.8rem; }
.push-row.enabled #push-status { color: var(--success); }

/* --- Animations --- */

.tab-screen:not([hidden]) {
    animation: fadeIn 0.18s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Petit hover-state pour les cards interactives (desktop ; sur mobile c'est ignoré). */
@media (hover: hover) {
    .skin-card:hover, .match-card:hover, .shop-offer:hover, .news-card:hover {
        border-color: rgba(255, 70, 85, 0.4);
        transition: border-color 0.15s ease-out;
    }
}

/* --- News --- */

.news-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.news-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.news-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--fg);
    text-decoration: none;
}

.news-card img {
    width: 64px;
    height: 40px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}

.news-card-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.news-title {
    font-size: 0.85rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.news-meta { color: var(--fg-muted); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; }

/* --- Matches --- */

.match-toolbar {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#match-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.match-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto auto;
    column-gap: 12px;
    row-gap: 2px;
    align-items: center;
}

.match-card.win { border-left-color: var(--success); }
.match-card.loss { border-left-color: var(--danger); }

.match-result {
    grid-column: 1;
    grid-row: 1 / 3;
    width: 44px;
    text-align: center;
    font-size: 1.1rem;
    font-weight: 700;
}
.match-result.win { color: var(--success); }
.match-result.loss { color: var(--danger); }

.match-main {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    flex-wrap: wrap;
    column-gap: 8px;
    font-size: 0.95rem;
    color: var(--fg);
    font-weight: 600;
}

.match-meta {
    grid-column: 2;
    grid-row: 2;
    color: var(--fg-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.match-right {
    grid-column: 3;
    grid-row: 1 / 3;
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.match-kda {
    font-weight: 700;
    color: var(--fg);
    font-size: 0.95rem;
}

.match-kda small { color: var(--fg-muted); font-weight: 400; }

.match-rr { font-size: 0.8rem; color: var(--fg-muted); }
.match-rr.positive { color: var(--success); }
.match-rr.negative { color: var(--danger); }

/* --- Spinner --- */

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 40px auto;
}

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

/* --- Tab bar --- */

.tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--tab-height) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--bg-elevated);
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 5;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--fg-muted);
    width: 100%;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 8px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border-radius: 0;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.tab-btn.active { color: var(--accent); }
.tab-btn:active { transform: none; }

.tab-icon { font-size: 1.3rem; line-height: 1; }

/* --- Update banner --- */

.update-banner {
    position: fixed;
    bottom: calc(var(--tab-height) + 16px + env(safe-area-inset-bottom));
    left: 16px;
    right: 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 12px 16px;
    color: var(--fg);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    z-index: 10;
}

.update-banner button {
    background: var(--accent);
    width: auto;
    padding: 6px 12px;
    font-size: 0.85rem;
    border-radius: 6px;
}

body:not(.has-tabbar) .update-banner {
    bottom: calc(16px + env(safe-area-inset-bottom));
}
