/* VPNStar-inspired dark theme */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: #16161f;
  --bg-input: #1a1a24;
  --border: #2a2a3a;
  --text-primary: #f0f0f5;
  --text-secondary: #a0a0b0;
  --text-muted: #6b6b7b;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.3);
  --success: #22c55e;
  --error: #ef4444;
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  margin: 0;
  padding: 1rem;
  line-height: 1.5;
}

/* Centered layout */
.page {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  padding: 0 0.5rem;
}

h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 0.5rem 0;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 1rem 0;
}

h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 0 0 0.5rem 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Card */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

.card.user-info {
  background: var(--bg-secondary);
}

/* Links */
a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--accent-hover);
}

a.back {
  color: var(--text-secondary);
  font-size: 0.9rem;
  display: inline-block;
  margin-bottom: 1rem;
}

a.back:hover {
  color: var(--text-primary);
}

/* Form inputs */
input[type="email"],
input[type="password"],
input[type="text"] {
  width: 100%;
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input::placeholder {
  color: var(--text-muted);
}

input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Buttons */
button,
.btn {
  display: inline-block;
  padding: 0.6rem 1.25rem;
  margin-right: 0.5rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  text-decoration: none;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 500;
  transition: background 0.2s, transform 0.1s;
}

button:disabled,
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn,
button:not(.primary):not(.modal-close):not(.tariff-item) {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn:hover:not(:disabled),
button:hover:not(:disabled):not(.modal-close) {
  background: var(--border);
}

.btn.primary,
button.primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.btn.primary:hover:not(:disabled),
button.primary:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: 0 0 20px var(--accent-glow);
}

/* Telegram widget area */
.tg-wrap {
  margin: 1.25rem 0;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.tg-wrap p {
  margin: 0 0 0.75rem 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Form blocks */
.form-block {
  margin-bottom: 1.5rem;
}

.form-block:last-child {
  margin-bottom: 0;
}

/* Error message */
.error {
  color: var(--error);
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

/* Profile */
.profile-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, #8b5cf6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
}

.avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.profile-title {
  flex: 1;
  min-width: 0;
}

.profile-title h2 {
  margin: 0 0 0.25rem 0;
  font-size: 1.2rem;
}

.profile-title .username {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.profile-meta {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.profile-section {
  margin-bottom: 1.5rem;
}

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

.profile-section h3 {
  margin: 0 0 0.75rem 0;
}

.profile-row {
  display: flex;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

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

.profile-row .label {
  min-width: 9rem;
  color: var(--text-secondary);
}

.profile-row .value {
  flex: 1;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
}

.badge.active {
  background: rgba(34, 197, 94, 0.2);
  color: var(--success);
}

.badge.expired {
  background: rgba(239, 68, 68, 0.2);
  color: var(--error);
}

.badge.none {
  background: var(--bg-input);
  color: var(--text-muted);
}

/* Key preview */
.key-preview {
  font-size: 0.85rem;
  word-break: break-all;
  color: var(--text-secondary);
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 360px;
  width: 100%;
  padding: 1.5rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.modal h2 {
  margin: 0 0 1rem 0;
  font-size: 1.2rem;
}

.tariff-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.tariff-item {
  display: block;
  width: 100%;
  padding: 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: all 0.2s;
  background: var(--bg-input);
  text-align: left;
  font-family: inherit;
}

.tariff-item:hover,
.tariff-item.selected {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.1);
}

.tariff-item .name {
  font-weight: 600;
  margin-bottom: 0.25rem;
  display: block;
}

.tariff-item .price {
  font-size: 1.2rem;
  color: var(--accent);
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0.25rem;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-primary);
}

.payment-link-wrap {
  margin-top: 1rem;
  display: none;
}

.payment-link-wrap.visible {
  display: block;
}

.payment-link-wrap .btn {
  margin-top: 0.5rem;
}

.duration-selector {
  margin-top: 1rem;
  display: none;
}

.duration-selector.visible {
  display: block;
}

.duration-selector h4 {
  margin: 0 0 0.5rem 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.duration-options {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.duration-options button {
  padding: 0.5rem 1rem;
}

.duration-btn.selected {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.2);
  color: var(--accent);
}

.payment-status-msg {
  margin-top: 0.75rem;
  font-size: 0.95rem;
  min-height: 1.5em;
  color: var(--text-secondary);
}

.payment-status-msg.success {
  color: var(--success);
  font-weight: 500;
}

/* User info list */
.user-info p {
  margin: 0.35rem 0;
}

.user-info strong {
  display: inline-block;
  min-width: 8rem;
  color: var(--text-secondary);
}

/* ========== Responsive ========== */
@media (max-width: 480px) {
  body {
    padding: 0.75rem;
  }
  .page {
    padding: 0;
  }
  h1 {
    font-size: 1.5rem;
  }
  .card {
    padding: 1rem;
  }
  .profile-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .profile-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }
  .profile-row .label {
    min-width: auto;
  }
  .modal {
    max-width: calc(100vw - 2rem);
    margin: 1rem;
  }
}

@media (min-width: 768px) {
  body {
    padding: 2rem 1rem;
  }
  .page {
    max-width: 480px;
  }
}
