/* ═══════════════════════════════════════════
   PROFILE PAGE — Redesign
═══════════════════════════════════════════ */

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

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

body {
    font-family: var(--font-family);
    background: #f1f5f9;
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

/* ── Page wrapper ── */
.profile-page {
    max-width: 1080px;
    margin: 0 auto;
    padding: 28px 24px 48px;
    animation: fadeUp 0.35s ease;
}

/* ── Alert ── */
.profile-alert-wrap {
    margin-bottom: 16px;
}

.profile-alert-wrap .alert,
.alert {
    padding: 13px 18px;
    border-radius: 10px;
    margin-bottom: 10px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: fadeUp 0.25s ease;
}

.alert-success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.alert-error   { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.alert-info    { background: #e0f2fe; color: #0369a1; border: 1px solid #7dd3fc; }

/* ── Loading / Error ── */
.profile-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 80px 20px;
    color: var(--text-muted);
    font-size: 14px;
}

.profile-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

.profile-error {
    background: #fee2e2;
    color: #b91c1c;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid #fca5a5;
    margin-bottom: 16px;
}

/* ── Page Header ── */







/* ── Stats Grid ── */
.profile-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 24px;
}

.profile-stat-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: box-shadow 0.15s, transform 0.15s;
    box-shadow: var(--shadow-sm);
}

.profile-stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.profile-stat-icon {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.profile-stat-value {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    line-height: 1.1;
    margin-top: 2px;
    word-break: break-all;
}

.profile-stat-label {
    font-size: 11.5px;
    color: var(--text-muted);
    font-weight: 500;
}

/* ── 2-col content layout ── */
.profile-content-grid {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 20px;
    align-items: start;
}

/* ── Card ── */
.profile-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 22px 24px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}

.profile-card:last-child { margin-bottom: 0; }

.profile-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.profile-card-header h2 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    flex: 1;
}

.profile-card-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ── Form fields ── */
.profile-field-group {
    margin-bottom: 14px;
}

.profile-field-group:last-child { margin-bottom: 0; }

.profile-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.profile-input {
    width: 100%;
    padding: 10px 13px;
    border: 1px solid #d1d5db;
    border-radius: 9px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary);
    background: #f9fafb;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
    box-sizing: border-box;
}

.profile-input:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

/* ── Buttons ── */
.profile-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 18px;
    font-size: 13.5px;
    font-weight: 600;
    border: none;
    border-radius: 9px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
}

.profile-btn:hover:not(:disabled) { transform: translateY(-1px); }
.profile-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.profile-btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(99,102,241,0.25);
}
.profile-btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    box-shadow: 0 4px 14px rgba(99,102,241,0.35);
}

.profile-btn-green {
    background: #16a34a;
    color: #fff;
    box-shadow: 0 2px 8px rgba(22,163,74,0.25);
}
.profile-btn-green:hover:not(:disabled) { background: #15803d; }

.profile-btn-tg {
    background: #0088cc;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0,136,204,0.25);
}
.profile-btn-tg:hover:not(:disabled) { background: #006699; }

.profile-btn-danger {
    background: #dc2626;
    color: #fff;
    box-shadow: 0 2px 8px rgba(220,38,38,0.2);
}
.profile-btn-danger:hover:not(:disabled) { background: #b91c1c; }

.profile-btn-outline {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.profile-btn-outline:hover:not(:disabled) {
    background: #f8fafc;
    color: var(--text-primary);
    transform: none;
}

/* Small buttons (header inline) */
.profile-btn-sm {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    border: none;
    border-radius: 7px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s;
}

.profile-btn-sm-primary { background: #eef2ff; color: var(--primary); }
.profile-btn-sm-primary:hover { background: #e0e7ff; }
.profile-btn-sm-green { background: #f0fdf4; color: #16a34a; }
.profile-btn-sm-green:hover { background: #dcfce7; }

/* ── Telegram Bot Banner ── */
.tg-bot-banner {
    background: linear-gradient(135deg, #0088cc 0%, #005f8e 100%);
    border-radius: 12px;
    padding: 18px 20px;
    margin-bottom: 18px;
    color: #fff;
}

.tg-bot-banner-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.tg-bot-info {
    display: flex;
    align-items: center;
    gap: 13px;
    flex: 1;
    min-width: 180px;
}

.tg-bot-avatar {
    width: 44px;
    height: 44px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.tg-bot-name { font-weight: 700; font-size: 15px; }
.tg-bot-username { font-size: 12.5px; opacity: 0.85; }
.tg-bot-desc { font-size: 11.5px; opacity: 0.7; margin-top: 2px; }

.tg-open-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    color: #0088cc;
    font-weight: 700;
    font-size: 13px;
    padding: 9px 16px;
    border-radius: 8px;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s;
    flex-shrink: 0;
}

.tg-open-btn:hover { background: #f0f9ff; }

.tg-commands {
    background: rgba(255,255,255,0.12);
    border-radius: 8px;
    padding: 11px 14px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 7px;
}

.tg-commands-label {
    font-size: 11.5px;
    font-weight: 600;
    opacity: 0.8;
    width: 100%;
    margin-bottom: 2px;
}

.tg-commands code {
    background: rgba(255,255,255,0.2);
    color: #fff;
    border-radius: 5px;
    padding: 3px 9px;
    font-size: 12px;
    font-family: 'Courier New', monospace;
}

/* ── Telegram Status ── */
.tg-status-box {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 13px 16px;
    margin-bottom: 16px;
}

.tg-status-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13.5px;
}

.tg-id-display {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* ── Telegram Guide ── */
.tg-guide-box {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 9px;
    padding: 14px 16px;
    font-size: 13.5px;
    color: #1e40af;
    line-height: 1.7;
}

.tg-guide-box strong { display: block; margin-bottom: 6px; }

.tg-guide-box ol {
    margin: 0;
    padding-left: 18px;
}

.tg-guide-box code {
    background: rgba(255,255,255,0.8);
    padding: 1px 5px;
    border-radius: 4px;
    font-family: monospace;
}

/* ── Telegram Linked ── */
.tg-linked-box {
    background: #f0fdf4;
    border: 1px solid #86efac;
    border-radius: 10px;
    padding: 16px;
}

.tg-linked-header {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 15px;
    font-weight: 700;
    color: #15803d;
    margin-bottom: 8px;
}

.tg-linked-box p {
    font-size: 13.5px;
    color: #166534;
    margin-bottom: 14px;
}

.tg-linked-commands {
    background: #fff;
    border-radius: 8px;
    padding: 13px;
    margin-bottom: 14px;
    border: 1px solid #dcfce7;
    font-size: 13px;
    color: var(--text-primary);
}

.tg-linked-commands strong { display: block; margin-bottom: 8px; color: #166534; }

.tg-cmd-list { display: flex; flex-direction: column; gap: 5px; }

.tg-cmd-list code {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
}

.tg-linked-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── Email list (purchased emails) ── */
.email-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
}

.email-item {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    border-radius: 10px;
    padding: 14px 16px;
    transition: border-color 0.15s, box-shadow 0.15s;
    animation: fadeUp 0.3s ease forwards;
    opacity: 0;
}

.email-item:hover {
    box-shadow: var(--shadow-sm);
    border-color: var(--primary);
}

.email-item .email {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    word-break: break-all;
}

.email-item .platforms {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.platform-badge {
    background: var(--primary);
    color: #fff;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 11.5px;
    font-weight: 600;
    text-transform: capitalize;
}

.email-item .date {
    font-size: 12px;
    color: var(--text-muted);
}

.email-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.login-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: background 0.15s, transform 0.15s;
    font-family: inherit;
}

.login-btn:hover:not(:disabled) { background: var(--primary-dark); transform: translateY(-1px); }
.login-btn:disabled { background: #94a3b8; cursor: not-allowed; }

@keyframes spin2 { to { transform: rotate(360deg); } }
.login-btn.loading { position: relative; color: transparent; }
.login-btn.loading::after {
    content: '';
    position: absolute;
    width: 14px; height: 14px;
    top: 50%; left: 50%;
    margin: -7px 0 0 -7px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin2 0.7s linear infinite;
}

/* ── History list ── */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.history-item {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-left-width: 3px;
    border-radius: 10px;
    padding: 13px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    transition: box-shadow 0.15s;
}

.history-item:hover { box-shadow: var(--shadow-sm); }
.history-item.positive { border-left-color: #16a34a; }
.history-item.negative { border-left-color: #dc2626; }

.history-item .info { flex: 1; min-width: 160px; }

.history-item .type {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 13.5px;
    margin-bottom: 3px;
    text-transform: capitalize;
}

.history-item .description {
    font-size: 12.5px;
    color: var(--text-muted);
}

.history-item .amount {
    font-size: 15px;
    font-weight: 700;
}

.history-item .amount.positive { color: #16a34a; }
.history-item .amount.negative { color: #dc2626; }

.history-item .date {
    font-size: 11.5px;
    color: var(--text-muted);
    width: 100%;
    text-align: right;
    margin-top: 4px;
}

/* ── Pagination ── */
.profile-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
}

.profile-pagination .pagination-btn,
.pagination button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, transform 0.15s;
}

.profile-pagination .pagination-btn:hover:not(:disabled),
.pagination button:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.profile-pagination .pagination-btn:disabled,
.pagination button:disabled {
    background: #94a3b8;
    cursor: not-allowed;
    transform: none;
}

.pagination-info {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

/* ── Empty ── */
.profile-empty {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-muted);
    font-size: 13.5px;
    font-style: italic;
}

/* ── Code ── */
code {
    font-family: 'Courier New', monospace;
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12.5px;
    color: var(--text-primary);
}

/* ── Footer ── */
.profile-footer {
    background: #fff;
    border-top: 1px solid var(--border);
    padding: 20px 24px;
    text-align: center;
}

.profile-footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    margin-bottom: 10px;
}

.profile-footer-links a {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12.5px;
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.15s;
}

.profile-footer-links a:hover { color: var(--text-primary); }

.profile-footer-copy {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0;
}

/* ── Utility ── */
.hidden { display: none !important; }

/* ── Responsive ── */
@media (max-width: 900px) {
    .profile-stats-grid { grid-template-columns: repeat(2, 1fr); }
    .profile-content-grid { grid-template-columns: 1fr; }
    .profile-left { order: 2; }
    .profile-right { order: 1; }
}

@media (max-width: 600px) {
    .profile-page { padding: 16px 16px 40px; }
    .profile-stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .profile-card { padding: 16px; }
    .history-item { flex-direction: column; align-items: flex-start; }
    .history-item .date { text-align: left; }
    .email-actions { flex-direction: column; }
    .email-actions .login-btn { width: 100%; justify-content: center; }
}

.username-banner {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: #fffbeb;
    border: 1.5px solid #fde68a;
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 14px;
    font-size: 13px;
    color: #92400e;
    line-height: 1.5;
}
