/* =========================================================
   GregPlay — Реферальная программа (referral)
   Использует лейаут кабинета (cabinet.css), добавляет свои блоки.
   ========================================================= */

/* Контент виден только после авторизации (или в demo-режиме ?preview).
   Неавторизованных requireAuth() редиректит на /login — контент не мелькает. */
.referral-page:not(.ref-ready) .cab-content { visibility: hidden; }

/* ============ HERO ============ */
.ref-hero {
    position: relative;
    border-radius: 22px;
    overflow: hidden;
    padding: 34px 36px;
    min-height: 168px;
    display: flex;
    align-items: center;
    border: 1px solid rgba(160, 107, 255, 0.24);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.36);
    animation: cab-rise 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.ref-hero-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    background:
        linear-gradient(90deg, rgba(11, 6, 24, 0.94) 0%, rgba(13, 7, 28, 0.72) 40%, rgba(20, 11, 40, 0.28) 68%, rgba(30, 14, 60, 0.15) 100%),
        radial-gradient(60% 120% at 88% 50%, rgba(160, 107, 255, 0.42), transparent 60%),
        url(/img/referral-hero.png?v=1),
        linear-gradient(115deg, #1b0f3a 0%, #2a1656 46%, #3a1d63 72%, #1d1140 100%);
    background-size: cover, cover, cover, cover;
    background-position: center, center, center right, center;
    background-repeat: no-repeat;
}
.ref-hero-copy { position: relative; z-index: 1; }
.ref-hero-title { font-family: "Sora", sans-serif; font-size: clamp(26px, 3.4vw, 40px); color: #fff; line-height: 1.04; }
.ref-hero-sub { margin-top: 12px; color: #cdc3e6; line-height: 1.6; font-size: 15px; }

/* ============ STATS ============ */
.ref-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px;
    animation: cab-rise 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.ref-stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 22px;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.09);
    background: linear-gradient(180deg, rgba(21, 15, 31, 0.92), rgba(13, 10, 19, 0.94));
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.24);
    transition: transform 0.2s ease, border-color 0.2s ease;
}
.ref-stat-card:hover { transform: translateY(-3px); border-color: rgba(160, 107, 255, 0.4); }
.ref-stat-ico {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    flex-shrink: 0;
    border-radius: 15px;
    color: #c4a5ff;
    background: rgba(160, 107, 255, 0.16);
    border: 1px solid rgba(160, 107, 255, 0.3);
}
.ref-stat-ico svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ref-stat-ico.ico-active { color: #7fd3a8; background: rgba(75, 198, 173, 0.14); border-color: rgba(75, 198, 173, 0.3); }
.ref-stat-ico.ico-bonus { color: #ffcf6b; background: rgba(255, 207, 107, 0.14); border-color: rgba(255, 207, 107, 0.3); }
.ref-stat-ico.ico-money { color: #8bb6ff; background: rgba(110, 150, 255, 0.14); border-color: rgba(110, 150, 255, 0.3); }
.ref-stat-body { display: flex; flex-direction: column; min-width: 0; }
.ref-stat-label { color: #a99fc0; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.ref-stat-value { color: #fff; font-family: "Sora", sans-serif; font-size: 26px; font-weight: 800; line-height: 1.05; }

/* ============ ROWS ============ */
.ref-row { display: grid; gap: 24px; align-items: start; }
.ref-row-mid { grid-template-columns: 1.55fr 1fr; }
.ref-row-bottom { grid-template-columns: 1.55fr 1fr; }

.ref-card-title { font-family: "Sora", sans-serif; font-size: 22px; color: #f4f0fc; }
.ref-card-sub { color: #a99fc0; font-size: 13.5px; margin-top: 6px; margin-bottom: 18px; }

/* ============ LINK CARD ============ */
.ref-link { position: relative; display: flex; align-items: center; margin-bottom: 18px; }
.ref-link input {
    flex: 1;
    min-height: 52px;
    border-radius: 13px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    color: #d7c4ff;
    font: 500 14px "JetBrains Mono", monospace;
    padding: 14px 56px 14px 16px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ref-link input:focus { outline: none; border-color: rgba(160, 107, 255, 0.5); }
.ref-copy {
    position: absolute;
    right: 8px;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    color: #c4a5ff;
    cursor: pointer;
    background: rgba(160, 107, 255, 0.16);
    border: 1px solid rgba(160, 107, 255, 0.3);
    transition: background 0.2s ease, transform 0.2s ease;
}
.ref-copy:hover { background: rgba(160, 107, 255, 0.3); transform: scale(1.06); }
.ref-copy.copied { color: #20e898; border-color: rgba(32, 232, 152, 0.5); background: rgba(32, 232, 152, 0.16); }
.ref-copy svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.ref-mini-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 18px; }
.ref-mini {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px;
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
}
.ref-mini-label { display: block; color: #a99fc0; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; }
.ref-mini-value { color: #f4f0fc; font-family: "Sora", sans-serif; font-size: 24px; font-weight: 800; }
.ref-mini-ico { display: grid; place-items: center; width: 42px; height: 42px; flex-shrink: 0; border-radius: 12px; }
.ref-mini-ico svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ref-mini-ico.ico-bonus { color: #ffcf6b; background: rgba(255, 207, 107, 0.14); border: 1px solid rgba(255, 207, 107, 0.28); }
.ref-mini-ico.ico-bonus svg { fill: currentColor; stroke: none; }
.ref-mini-ico.ico-money { color: #7fe3c4; background: rgba(75, 198, 173, 0.14); border: 1px solid rgba(75, 198, 173, 0.28); }

.ref-withdraw { width: 100%; min-height: 50px; border-radius: 13px; font-size: 15px; }
.ref-withdraw-note { margin: 12px 0 0; text-align: center; color: #8d83a3; font-size: 12.5px; }
.ref-withdraw-note b { color: #b69bff; font-weight: 700; }

/* ============ HOW IT WORKS ============ */
.ref-how-card { align-self: stretch; }
.ref-steps { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 20px; }
.ref-step { display: flex; align-items: center; gap: 16px; }
.ref-step-num {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border-radius: 50%;
    font-family: "Sora", sans-serif;
    font-weight: 800;
    font-size: 15px;
    color: #cdbdf2;
    background: rgba(160, 107, 255, 0.16);
    border: 1px solid rgba(160, 107, 255, 0.34);
}
.ref-step-text { color: #d6cfe6; font-size: 14.5px; line-height: 1.45; }

/* ============ REFERRALS TABLE ============ */
.ref-table-card .table-wrap { overflow-x: auto; margin-top: 16px; }
.ref-table { width: 100%; border-collapse: collapse; min-width: 560px; }
.ref-table th, .ref-table td { padding: 14px 12px; text-align: left; border-bottom: 1px solid rgba(255, 255, 255, 0.07); font-size: 14px; }
.ref-table th { color: #9a90aa; font-size: 11px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.ref-table tbody tr { transition: background 0.18s ease; }
.ref-table tbody tr:hover { background: rgba(160, 107, 255, 0.06); }
.ref-player { display: inline-flex; align-items: center; gap: 11px; color: #f0ecf8; font-weight: 600; }
.ref-avatar { width: 32px; height: 32px; border-radius: 8px; image-rendering: pixelated; border: 1px solid rgba(255, 255, 255, 0.1); flex-shrink: 0; }
.ref-status { display: inline-flex; align-items: center; min-height: 26px; padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.ref-status-active { color: #b9ffd6; border: 1px solid rgba(32, 232, 152, 0.4); background: rgba(32, 232, 152, 0.12); }
.ref-status-idle { color: #d8d1e8; border: 1px solid rgba(255, 255, 255, 0.16); background: rgba(255, 255, 255, 0.05); }
.ref-muted { color: #a99fc0; white-space: nowrap; }
.ref-activity { color: #d6cfe6; white-space: nowrap; }
.ref-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #20e898; box-shadow: 0 0 8px rgba(32, 232, 152, 0.7); margin-right: 8px; vertical-align: middle; }
.ref-earned { color: #f4f0fc; font-weight: 700; white-space: nowrap; }
.ref-earned svg { width: 15px; height: 15px; fill: #ffcf6b; vertical-align: middle; margin-left: 5px; }
.ref-empty { padding: 26px 12px; text-align: center; color: #a99fc0; }

/* ============ LEVELS ============ */
.ref-levels { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.ref-level {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 15px 16px;
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: border-color 0.18s ease, background 0.18s ease;
}
.ref-level:hover { border-color: rgba(160, 107, 255, 0.3); background: rgba(160, 107, 255, 0.07); }
.ref-level-ico { position: relative; display: grid; place-items: center; width: 44px; height: 44px; flex-shrink: 0; color: #a06bff; }
.ref-level-ico svg { width: 44px; height: 44px; fill: rgba(160, 107, 255, 0.18); stroke: rgba(160, 107, 255, 0.5); stroke-width: 1.2; }
.ref-level-ico b { position: absolute; font-family: "Sora", sans-serif; font-weight: 800; font-size: 16px; color: #d7c4ff; }
.ref-level-body { flex: 1; min-width: 0; }
.ref-level-body strong { display: block; color: #f2eefb; font-size: 15px; font-weight: 700; }
.ref-level-body span { color: #9a90aa; font-size: 12.5px; }
.ref-level-badge {
    flex-shrink: 0;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 700;
    color: #cdbdf2;
    background: rgba(160, 107, 255, 0.16);
    border: 1px solid rgba(160, 107, 255, 0.34);
}

/* ============ RESPONSIVE ============ */
@media (max-width: 1280px) {
    .ref-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1080px) {
    .ref-row-mid, .ref-row-bottom { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
    .ref-hero { padding: 24px; }
    .ref-stats { grid-template-columns: 1fr; }
    .ref-mini-grid { grid-template-columns: 1fr; }
    .ref-table { min-width: 480px; }
}
