/* Amethyst VPN — Telegram Mini App Styles */

:root {
    --bg: var(--tg-theme-bg-color, #ffffff);
    --text: var(--tg-theme-text-color, #111827);
    --hint: var(--tg-theme-hint-color, #6b7280);
    --link: var(--tg-theme-link-color, #c27aff);
    --btn: var(--tg-theme-button-color, #c27aff);
    --btn-text: var(--tg-theme-button-text-color, #ffffff);
    --secondary-bg: var(--tg-theme-secondary-bg-color, #f3f4f6);
    --section-bg: var(--tg-theme-section-bg-color, var(--secondary-bg));
    --accent: #c27aff;
    --accent-hover: #ad46ff;
    --accent-light: #f3e8ff;
    --danger: #ef4444;
    --success: #22c55e;
    --warning: #f59e0b;
    --radius: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #ffffff;
    color: var(--text);
    min-height: 100vh;
    padding: 16px;
    padding-top: 16px;
    padding-bottom: 100px;
    -webkit-font-smoothing: antialiased;
}

/* ============================================
   Layout
   ============================================ */

.container {
    max-width: 480px;
    margin: 0 auto;
}

.header {
    text-align: center;
    padding: 20px 0 16px;
}

.header h1 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 4px;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ============================================
   Cards
   ============================================ */

.card {
    background: var(--section-bg);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid rgba(194, 122, 255, 0.12);
}

.card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--hint);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.card-sub {
    background: linear-gradient(135deg, #f3e8ff, #ede4ff, #f8f0ff);
    border: 1px solid rgba(194, 122, 255, 0.2);
}

/* ============================================
   Status Badge
   ============================================ */

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
}

.status-badge.active {
    background: rgba(194, 122, 255, 0.15);
    color: var(--accent);
}

.status-badge.inactive {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.status-badge .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

/* ============================================
   Info rows
   ============================================ */

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(128, 128, 128, 0.1);
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    font-size: 14px;
    color: var(--hint);
}

.info-value {
    font-size: 14px;
    font-weight: 600;
}

/* ============================================
   Buttons
   ============================================ */

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.btn:active {
    transform: scale(0.98);
}

.btn:disabled {
    opacity: 0.5;
    pointer-events: none;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 14px rgba(194, 122, 255, 0.3);
}

.btn-primary:active {
    background: var(--accent-hover);
}

.btn-accent {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 14px rgba(194, 122, 255, 0.3);
}

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

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--accent);
    color: var(--accent);
}

.btn-outline:active {
    background: var(--accent-light);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
    width: auto;
    border-radius: 8px;
}

.btn-row {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.btn-row .btn {
    flex: 1;
}

/* ============================================
   Loading
   ============================================ */

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 0;
    color: var(--hint);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(194, 122, 255, 0.2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 12px;
}

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

.hidden {
    display: none !important;
}

/* ============================================
   QR Modal
   ============================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.modal {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 340px;
    width: 100%;
    text-align: center;
}

.modal h3 {
    margin-bottom: 16px;
    font-size: 18px;
}

.modal img {
    width: 100%;
    max-width: 280px;
    border-radius: 8px;
    margin-bottom: 16px;
}

/* ============================================
   Admin: Tables
   ============================================ */

.user-list {
    list-style: none;
}

.user-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid rgba(128, 128, 128, 0.1);
    cursor: pointer;
    transition: opacity 0.2s;
}

.user-item:last-child {
    border-bottom: none;
}

.user-item:active {
    opacity: 0.7;
}

.user-item .user-info {
    flex: 1;
    min-width: 0;
}

.user-item .user-name {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-item .user-meta {
    font-size: 13px;
    color: var(--hint);
    margin-top: 2px;
}

.user-item .user-badge {
    font-size: 13px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 12px;
    white-space: nowrap;
    margin-left: 8px;
}

.user-item .user-badge.days-ok {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.user-item .user-badge.days-warn {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.user-item .user-badge.days-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

/* ============================================
   Admin: Stats
   ============================================ */

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.stat-card {
    background: var(--section-bg);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
}

.stat-label {
    font-size: 12px;
    color: var(--hint);
    margin-top: 4px;
}

/* ============================================
   Admin: Tabs / Navigation
   ============================================ */

.tabs {
    display: flex;
    gap: 4px;
    background: var(--secondary-bg);
    border-radius: 10px;
    padding: 3px;
    margin-bottom: 16px;
}

.tab {
    flex: 1;
    padding: 10px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    background: transparent;
    color: var(--hint);
    -webkit-tap-highlight-color: transparent;
}

.tab.active {
    background: var(--bg);
    color: var(--text);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* ============================================
   Pagination
   ============================================ */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 12px 0;
}

.pagination .page-info {
    font-size: 14px;
    color: var(--hint);
}

.pagination .btn-sm {
    min-width: 36px;
}

/* ============================================
   Search
   ============================================ */

.search-input {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid rgba(128, 128, 128, 0.2);
    border-radius: 10px;
    font-size: 14px;
    background: var(--section-bg);
    color: var(--text);
    outline: none;
    margin-bottom: 12px;
    transition: border-color 0.2s;
}

.search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(194, 122, 255, 0.1);
}

.search-input::placeholder {
    color: var(--hint);
}

/* ============================================
   User card (admin detail)
   ============================================ */

.user-card-header {
    text-align: center;
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(128, 128, 128, 0.1);
}

.user-card-header .name {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}

.user-card-header .tid {
    font-size: 13px;
    color: var(--hint);
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    color: var(--link);
    cursor: pointer;
    padding: 8px 0;
    border: none;
    background: none;
    -webkit-tap-highlight-color: transparent;
}

/* ============================================
   Toast notifications
   ============================================ */

.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: var(--bg);
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    z-index: 200;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
}

/* ============================================
   Confirm dialog
   ============================================ */

.confirm-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.confirm-actions .btn {
    flex: 1;
}

/* ============================================
   Empty state
   ============================================ */

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--hint);
}

.empty-state .icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 15px;
}
