/* KonorVPN Web App — Telegram-native theme */

:root {
    --wa-bg: var(--tg-theme-bg-color, #1c1c1e);
    --wa-text: var(--tg-theme-text-color, #ffffff);
    --wa-hint: var(--tg-theme-hint-color, #8e8e93);
    --wa-link: var(--tg-theme-link-color, #007aff);
    --wa-btn: var(--tg-theme-button-color, #007aff);
    --wa-btn-text: var(--tg-theme-button-text-color, #ffffff);
    --wa-secondary-bg: var(--tg-theme-secondary-bg-color, #2c2c2e);
    --wa-card-bg: var(--tg-theme-secondary-bg-color, #2c2c2e);
    --wa-radius: 12px;
    --wa-gap: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--wa-bg);
    color: var(--wa-text);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--wa-link);
    text-decoration: none;
}

/* App shell */
.wa-app {
    max-width: 480px;
    margin: 0 auto;
    padding: 0 16px 80px;
    min-height: 100vh;
}

/* Header */
.wa-header {
    padding: 16px 0 8px;
    text-align: center;
}

.wa-logo {
    font-size: 20px;
    font-weight: 700;
    color: var(--wa-text);
}

/* Loading */
.wa-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    color: var(--wa-hint);
    font-size: 15px;
}

.wa-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--wa-secondary-bg);
    border-top-color: var(--wa-btn);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

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

/* Cards */
.wa-card {
    background: var(--wa-card-bg);
    border-radius: var(--wa-radius);
    padding: 16px;
    margin-bottom: var(--wa-gap);
}

.wa-card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 10px;
}

/* Welcome card */
.wa-welcome {
    text-align: center;
    padding: 20px 16px;
}

.wa-greeting {
    font-size: 18px;
    font-weight: 600;
}

/* Status */
.wa-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 6px;
}

.wa-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.wa-status-active .wa-status-dot,
.wa-dot-active {
    background: #34c759;
    box-shadow: 0 0 6px rgba(52, 199, 89, 0.5);
}

.wa-status-inactive .wa-status-dot,
.wa-dot-inactive {
    background: #ff3b30;
}

.wa-meta {
    font-size: 14px;
    color: var(--wa-hint);
    margin-top: 4px;
}

.wa-hint {
    font-size: 14px;
    color: var(--wa-hint);
    margin-top: 6px;
}

.wa-text {
    font-size: 15px;
    margin-bottom: 16px;
}

/* Grid of link cards */
.wa-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--wa-gap);
    margin-bottom: var(--wa-gap);
}

.wa-card-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px 12px;
    text-decoration: none;
    color: var(--wa-text);
    transition: transform 0.15s, opacity 0.15s;
}

.wa-card-link:active {
    transform: scale(0.97);
    opacity: 0.8;
}

.wa-card-full {
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    padding: 16px;
}

.wa-card-icon {
    font-size: 28px;
}

.wa-card-full .wa-card-icon {
    font-size: 22px;
}

.wa-card-link-text {
    font-size: 14px;
    font-weight: 500;
    text-align: center;
}

/* Keys / access */
.wa-key-card {
    background: var(--wa-bg);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
}

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

.wa-key-label {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 10px;
}

.wa-key-section {
    margin-bottom: 10px;
}

.wa-key-section:last-child {
    margin-bottom: 0;
}

.wa-key-section-title {
    font-size: 12px;
    color: var(--wa-hint);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.wa-key-value {
    font-size: 13px;
    word-break: break-all;
    background: var(--wa-secondary-bg);
    padding: 8px 10px;
    border-radius: 6px;
    margin-bottom: 6px;
    user-select: all;
}

.wa-key-mono {
    font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
    font-size: 12px;
}

/* Buttons */
.wa-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: 8px;
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.15s;
    font-family: inherit;
}

.wa-btn:active {
    transform: scale(0.97);
    opacity: 0.8;
}

.wa-btn-copy {
    background: var(--wa-secondary-bg);
    color: var(--wa-text);
    width: 100%;
}

.wa-btn-primary {
    background: var(--wa-btn);
    color: var(--wa-btn-text);
}

.wa-btn-full {
    width: 100%;
    display: flex;
}

.wa-btn-success {
    background: #34c759 !important;
    color: #fff !important;
}

/* Tabs */
.wa-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: var(--wa-gap);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.wa-tabs::-webkit-scrollbar {
    display: none;
}

.wa-tab {
    flex: 1;
    padding: 10px 14px;
    border: none;
    background: var(--wa-card-bg);
    color: var(--wa-hint);
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--wa-radius);
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s, color 0.2s;
    font-family: inherit;
}

.wa-tab.active {
    background: var(--wa-btn);
    color: var(--wa-btn-text);
}

.wa-tab-content {
    display: none;
}

.wa-tab-content.active {
    display: block;
}

/* Steps */
.wa-steps {
    padding-left: 20px;
    font-size: 15px;
}

.wa-steps li {
    margin-bottom: 10px;
    line-height: 1.5;
}

.wa-steps li:last-child {
    margin-bottom: 0;
}

.wa-link {
    color: var(--wa-link);
    text-decoration: underline;
}

/* Devices */
.wa-devices-list,
.wa-locations-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wa-device-item,
.wa-location-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--wa-bg);
    border-radius: 8px;
}

.wa-device-icon,
.wa-location-icon {
    font-size: 24px;
}

.wa-device-name,
.wa-location-name {
    font-size: 15px;
    font-weight: 500;
}

.wa-device-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--wa-hint);
    margin-top: 2px;
}

.wa-device-status .wa-status-dot {
    width: 6px;
    height: 6px;
}

/* Location */
.wa-location-selected {
    border: 1px solid var(--wa-btn);
}

.wa-location-info {
    flex: 1;
}

.wa-location-badge {
    font-size: 13px;
    color: var(--wa-btn);
    font-weight: 500;
}

/* Support */
.wa-support-info {
    margin-top: 16px;
}

.wa-support-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    padding: 8px 0;
}

.wa-support-icon {
    font-size: 20px;
}

/* Bottom nav */
.wa-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    background: var(--wa-card-bg);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding: 6px 0;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
    z-index: 100;
}

.wa-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 4px;
    color: var(--wa-hint);
    text-decoration: none;
    font-size: 10px;
    transition: color 0.2s;
}

.wa-nav-item.active {
    color: var(--wa-btn);
}

.wa-nav-icon {
    font-size: 20px;
}

.wa-nav-label {
    font-weight: 500;
}
