/* Telegram Web 1:1 clone — doodle wallpaper, TG header, loading/error
   modals (spinner + "Загрузка...", blue-circle-X error), gift content. */

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    padding: 0;
    background-color: #17212b;           /* Telegram Web dark base */
    background-image: url("/static/doodles.svg?v=5");
    background-size: 420px 420px;
    background-attachment: fixed;
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* --- header: blue TG logo + Telegram --- */
.header {
    position: sticky;
    top: 0;
    z-index: 5;
    background-color: #17212b;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.tg-logo {
    display: flex;
    align-items: center;
}

.header h1 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: 0.2px;
}

.container {
    position: relative;
    z-index: 1;
    padding: 14px 14px 24px;
    max-width: 520px;
    margin: 0 auto;
}

/* --- profile card --- */
.profile-card {
    background-color: #232e3c;
    border-radius: 16px;
    padding: 14px;
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}

.avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 600;
    margin-right: 12px;
    overflow: hidden;
    color: #fff;
    flex-shrink: 0;
    background: linear-gradient(135deg, #b06ab3, #4568dc);
}

.user-info h2 {
    margin: 0 0 3px 0;
    font-size: 17px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.premium-star { font-size: 14px; }

.username {
    color: #6ab3f3;
    margin: 0;
    font-size: 13px;
}

.stats {
    margin-left: auto;
    text-align: right;
    font-size: 13px;
    color: #8b98a8;
    white-space: nowrap;
}

.rating-row {
    color: #e8eef5;
    font-weight: 600;
    margin-bottom: 3px;
}

.rating-num { margin: 0 2px; }
.rating-star { font-size: 12px; }

/* --- balance card --- */
.balance-card {
    background-color: #232e3c;
    border-radius: 16px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 15px;
    font-weight: 500;
}

.balance-value { font-weight: 600; }

/* --- search --- */
.search-wrap {
    position: relative;
    margin-bottom: 14px;
}

.search-icon {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

#tg-search {
    width: 100%;
    padding: 12px 14px 12px 36px;
    border-radius: 12px;
    border: none;
    background: #232e3c;
    color: #fff;
    font-size: 14px;
    outline: none;
}

#tg-search::placeholder { color: #6b7889; }

/* --- content / profile loading --- */
#content { display: none; }

#profile-loading { padding: 20px 0; }

/* --- gifts head --- */
.gifts-head {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}

.gifts-head h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    display: flex;
    align-items: center;
}

.count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    margin-left: 8px;
    border-radius: 11px;
    background-color: #2f3d4f;
    color: #9db2c9;
    font-size: 12px;
    font-weight: 600;
}

.filters {
    margin-left: auto;
    display: flex;
    gap: 8px;
}

.filter-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    background-color: #232e3c;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 13px;
    color: #c6d2e0;
}

/* --- gifts grid --- */
.gifts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.gift-card {
    background-color: #232e3c;
    border-radius: 16px;
    overflow: hidden;
}

.gift-image {
    width: 100%;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 56px;
    background-color: #2b3849;
    overflow: hidden;
}

.gift-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gift-body { padding: 10px 12px 12px; }

.gift-name {
    font-weight: 600;
    margin: 0 0 2px 0;
    font-size: 14px;
}

.gift-num {
    color: #6b7889;
    font-size: 12px;
    margin: 0 0 8px 0;
}

.gift-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.gift-price {
    color: #fff;
    font-size: 13px;
    font-weight: 600;
}

.buy-btn {
    background: linear-gradient(180deg, #3ddc64, #25b84b);
    border: none;
    border-radius: 10px;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    padding: 7px 18px;
    cursor: pointer;
    min-width: 56px;
    min-height: 32px;
}

.buy-btn:active { filter: brightness(0.9); }

.gifts-empty {
    grid-column: 1 / -1;
    color: #6b7889;
    text-align: center;
    font-size: 14px;
    padding: 24px 0;
}

/* --- Telegram-style modal overlays --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.33);
}

.modal {
    background-color: #232e3c;
    border-radius: 12px;
    padding: 26px 38px 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.35);
    min-width: 190px;
}

.modal-title {
    color: #fff;
    font-size: 15px;
    font-weight: 500;
    text-align: center;
    line-height: 1.35;
}

#loading .modal-title { margin-top: 16px; }

.modal-sub {
    color: #8b98a8;
    font-size: 13px;
    margin-top: 7px;
    text-align: center;
}

.error-icon { margin-bottom: 16px; }

/* gray ring + blue segment, exactly like web.telegram.org */
.spinner {
    border: 3px solid rgba(255, 255, 255, 0.12);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border-top-color: #3f8ae0;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@media (max-width: 360px) {
    .gifts-grid { grid-template-columns: 1fr; }
}
