/* ================= RESET & BASE ================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-body: #0f1117;
  --bg-sidebar: #161921;
  --bg-card: #1a1d27;
  --bg-card-hover: #1f2230;
  --bg-input: #12141c;
  --border: #2a2d3a;
  --border-focus: #4f8cff;
  --text: #e4e6ed;
  --text-dim: #8b8fa3;
  --text-muted: #5c6072;
  --accent: #4f8cff;
  --accent-hover: #3a75e8;
  --success: #2dd4a0;
  --danger: #f74a6a;
  --warning: #f5a623;
  --radius: 10px;
  --radius-sm: 6px;
  --sidebar-w: 240px;
  --topbar-h: 0px;
}

html { font-size: 15px; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-body);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

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

/* ================= LAYOUT ================= */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ================= SIDEBAR ================= */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.25s ease;
}

.sidebar-brand {
  padding: 1.5rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.02em;
}

.sidebar-brand .brand-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0;
  overflow-y: auto;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 1.25rem;
  color: var(--text-dim);
  font-size: 0.88rem;
  font-weight: 500;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
  color: var(--text);
  background: rgba(79, 140, 255, 0.06);
}

.sidebar-nav a.active {
  color: var(--accent);
  background: rgba(79, 140, 255, 0.1);
  border-left-color: var(--accent);
}

.sidebar-nav .nav-icon {
  font-size: 1.1rem;
  width: 22px;
  text-align: center;
}

.sidebar-nav .nav-section {
  padding: 1.2rem 1.25rem 0.4rem;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
}

.sidebar-user {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.sidebar-user .user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
}

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

.sidebar-user .user-name {
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user .user-plan {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ================= MAIN CONTENT ================= */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 2rem 2.5rem;
  max-width: 1100px;
}

.page-header {
  margin-bottom: 2rem;
}

.page-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-header p {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

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

.card-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.75rem;
}

/* ================= STAT GRID ================= */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
}

.stat-card .stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stat-card .stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  margin-top: 0.3rem;
  letter-spacing: -0.02em;
}

.stat-card .stat-value.text-success { color: var(--success); }
.stat-card .stat-value.text-accent { color: var(--accent); }
.stat-card .stat-value.text-warning { color: var(--warning); }

/* ================= TABLES ================= */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.87rem;
}

thead th {
  text-align: left;
  padding: 0.7rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:hover {
  background: var(--bg-card-hover);
}

/* ================= BADGES ================= */
.badge {
  display: inline-block;
  padding: 0.2em 0.6em;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-success { background: rgba(45, 212, 160, 0.15); color: var(--success); }
.badge-danger { background: rgba(247, 74, 106, 0.15); color: var(--danger); }
.badge-warning { background: rgba(245, 166, 35, 0.15); color: var(--warning); }
.badge-info { background: rgba(79, 140, 255, 0.15); color: var(--accent); }

/* ================= BUTTONS ================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

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

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

.btn-success {
  background: var(--success);
  color: #0f1117;
}

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

.btn-outline {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
}

/* ================= FORMS ================= */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 0.35rem;
}

.form-control {
  width: 100%;
  padding: 0.6rem 0.85rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.88rem;
  font-family: inherit;
  transition: border-color 0.15s;
}

.form-control:focus {
  outline: none;
  border-color: var(--border-focus);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b8fa3' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* ================= CODE BLOCKS ================= */
.code-block {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.82rem;
  line-height: 1.7;
  overflow-x: auto;
  position: relative;
}

.code-block .copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.25rem 0.6rem;
  font-size: 0.72rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-dim);
  cursor: pointer;
}

.code-block .copy-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.code-inline {
  background: var(--bg-input);
  padding: 0.15em 0.45em;
  border-radius: 4px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.85em;
  color: var(--accent);
}

/* ================= ALERTS ================= */
.alert {
  padding: 0.85rem 1.15rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 1rem;
  border-left: 3px solid;
}

.alert-success { background: rgba(45, 212, 160, 0.08); border-color: var(--success); color: var(--success); }
.alert-danger { background: rgba(247, 74, 106, 0.08); border-color: var(--danger); color: var(--danger); }
.alert-warning { background: rgba(245, 166, 35, 0.08); border-color: var(--warning); color: var(--warning); }
.alert-info { background: rgba(79, 140, 255, 0.08); border-color: var(--accent); color: var(--accent); }

/* ================= LOGIN PAGE ================= */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-body);
}

.login-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.login-box h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  color: var(--accent);
}

.login-box .login-sub {
  color: var(--text-dim);
  font-size: 0.88rem;
  margin-bottom: 2rem;
}

.login-box .login-features {
  text-align: left;
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
}

.login-box .login-features li {
  list-style: none;
  padding: 0.3rem 0;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.login-box .login-features li::before {
  content: '✓';
  color: var(--success);
  margin-right: 0.5rem;
  font-weight: 700;
}

.telegram-login-wrap {
  margin: 1.5rem 0;
}

/* ================= DOCS PAGE ================= */
.docs-section {
  margin-bottom: 2rem;
}

.docs-section h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.docs-section h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 1.25rem 0 0.5rem;
  color: var(--text);
}

.method-badge {
  display: inline-block;
  padding: 0.15em 0.5em;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-right: 0.5rem;
}

.method-post { background: rgba(79, 140, 255, 0.2); color: var(--accent); }
.method-get { background: rgba(45, 212, 160, 0.2); color: var(--success); }

.endpoint-path {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.88rem;
  color: var(--text);
}

/* ================= PACK TABLE ================= */
.pack-table td:first-child {
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
}

/* ================= SUBSCRIPTION CARDS ================= */
.plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.25rem;
  margin: 1.5rem 0;
}

.plan-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  text-align: center;
  transition: border-color 0.2s;
}

.plan-card.active {
  border-color: var(--accent);
}

.plan-card .plan-name {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.plan-card .plan-price {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.25rem;
}

.plan-card .plan-period {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.plan-card ul {
  list-style: none;
  text-align: left;
  margin-bottom: 1.5rem;
}

.plan-card ul li {
  padding: 0.35rem 0;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.plan-card ul li::before {
  content: '✓';
  color: var(--success);
  margin-right: 0.5rem;
  font-weight: 700;
}

/* ================= ORDER FORM ================= */
.order-form-card {
  max-width: 550px;
}

/* ================= MOBILE ================= */
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 200;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.65rem;
  color: var(--text);
  cursor: pointer;
  font-size: 1.2rem;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 90;
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.open {
    display: block;
  }

  .mobile-menu-btn {
    display: block;
  }

  .main-content {
    margin-left: 0;
    padding: 3.5rem 1.25rem 2rem;
  }

  .stat-grid {
    grid-template-columns: 1fr 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .plan-grid {
    grid-template-columns: 1fr;
  }
}

/* ================= COPY ANIMATION ================= */
.copied {
  color: var(--success) !important;
}

/* ================= API KEY DISPLAY ================= */
.api-key-display {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.85rem;
}

.api-key-display code {
  flex: 1;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  color: var(--accent);
  word-break: break-all;
}

/* ================= EMPTY STATE ================= */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}

.empty-state p {
  font-size: 0.9rem;
}

/* ================= LOGOUT ================= */
.sidebar-nav a.nav-logout {
  color: var(--danger);
}

.sidebar-nav a.nav-logout:hover {
  background: rgba(247, 74, 106, 0.08);
}
