/* @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap'); */
@import url('https://fonts.googleapis.com/css2?family=Nunito+Sans:ital,opsz,wght@0,6..12,200..1000;1,6..12,200..1000&display=swap');
:root {
  --tg_theme_accent_text_color: #168acd;
  --tg_theme_bg_color: #ffffff;
  --tg_theme_button_color: #007AFF;
  --tg_theme_button_text_color: #ffffff;
  --tg_theme_bottom_bar_bg_color: #ffffff;
  --tg_theme_destructive_text_color: #FF3B30;
  --tg_theme_header_bg_color: #ffffff;
  --tg_theme_hint_color: #999999;
  --tg_theme_link_color: #168acd;
  --tg_theme_secondary_bg_color: #f1f1f1;
  --tg_theme_section_bg_color: #ffffff;
  --tg_theme_section_header_text_color: #168acd;
  --tg_theme_subtitle_text_color: #999999;
  --tg_theme_text_color: #000000;
}

/* ====================
   Глобальные стили (в стиле Apple)
   ==================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Шрифт — как у Apple: SF Pro или системный */
body,
button,
input,
select,
textarea {
  /* font-family: -apple-system, BlinkMacSystemFont, 'Inter', Helvetica, Arial, sans-serif; */
  font-family: -apple-system, BlinkMacSystemFont, 'Nunito Sans', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  /* -webkit-appearance: none; */ /* Отключение айфоновских стилей */
}

body {
  /* background-color: var(--tg_theme_bg_color); */
  background-color: #161616;
  color: var(--tg_theme_text_color);
  display: flex;
  justify-content: center;
  flex-direction: column;
  min-height: 100vh;
  padding: 16px;
  font-size: 17px;
  line-height: 1.5;
  font-weight: 400;
  letter-spacing: -0.01em;
}

/* ====================
   Шапка (в стиле Apple)
   ==================== */

.header {
  background-color: var(--tg_theme_header_bg_color);
  color: var(--tg_theme_text_color);
  padding: 20px 24px;
  font-size: 20px;
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.015em;
  border-radius: 12px 12px 0 0;
  border-bottom: 1px solid #e9ecef;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.1);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60px;
  
  position: sticky;
  top: 0;
  z-index: 1000;
}

.back-btn {
  position: absolute;
  left: 24px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 17px;
  font-weight: 500;
  color: var(--tg_theme_link_color);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  letter-spacing: -0.008em;
  transition: all 0.2s ease;
}

.back-btn:hover {
  color: var(--tg_theme_accent_text_color);
  /* transform: translateY(-50%) scale(1.02); */
}

.back-btn:active {
  transform: translateY(-50%) scale(1);
}

.header span {
  text-align: center;
}

/* ====================
   Контейнеры
   ==================== */

.container {
  width: 100%;
  max-width: 480px;
  background: var(--tg_theme_bg_color);
  border-radius: 16px;
  /* overflow: hidden; */
  margin: 0 auto;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.content {
  padding: 28px 24px;
  text-align: center;
}

.title {
  font-size: 28px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin-bottom: 12px;
  color: var(--tg_theme_text_color);
}

.subtitle {
  font-size: 16px;
  color: var(--tg_theme_subtitle_text_color);
  margin-bottom: 32px;
  line-height: 1.5;
  font-weight: 400;
}

.footer {
  padding: 20px;
  text-align: center;
  color: var(--tg_theme_hint_color);
  font-size: 14px;
  font-weight: 400;
}

/* ====================
   Кнопки (в стиле Apple)
   ==================== */

.btn,
.submit-btn,
.buy-btn {
  display: block;
  width: 100%;
  padding: 16px;
  margin-bottom: 12px;
  background-color: var(--tg_theme_button_color);
  color: var(--tg_theme_button_text_color);
  text-align: center;
  border: none;
  border-radius: 12px;
  font-size: 17px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  letter-spacing: -0.008em;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.1);
}

.btn:hover,
.submit-btn:hover,
.buy-btn:hover {
  transform: scale(1.01);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.btn:active {
  transform: scale(0.99);
}

.btn.secondary {
  background-color: #f1f1f1;
  color: #2c2c2c;
}

.btn.balance {
  background-color: #34C759;
  color: white;
}

.btn.cancel {
  background-color: var(--tg_theme_destructive_text_color);
  color: white;
}

.btn-profile {
  background: none;
  border: none;
  font-size: 18px;
  color: #168acd;
  float: right;
  margin: 12px 12px 0 0;
  cursor: pointer;
}

/* ====================
   Фильтр (в стиле Apple)
   ==================== */

.filter {
  background: white;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #e0e0e0;
}

.filter select {
  padding: 10px 14px;
  border: 1px solid #ccc;
  border-radius: 10px;
  font-size: 15px;
  background-color: #fafafa;
  font-family: inherit;
}

.filter select:focus {
  border-color: #0077cc;
  outline: none;
}

/* ====================
   Список ордеров
   ==================== */

.orders-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px;
}

.order-card {
  background: white;
  border-radius: 14px;
  padding: 18px;
  margin: 12px 0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  border: 1px solid #e9ecef;
}

.order-info {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  font-weight: 500;
  font-size: 17px;
}

.stars {
  text-align: left;
  font-weight: 600;
  color: var(--tg_theme_accent_text_color);
}

.price {
  font-size: 17px;
  font-weight: 600;
  color: var(--tg_theme_text_color);
}

.details {
  text-align: left;
  font-size: 15px;
  line-height: 1.4;
  color: var(--tg_theme_text_color);
  margin-bottom: 20px;
}

.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--tg_theme_hint_color);
  font-size: 16px;
  line-height: 1.5;
}

/* ====================
   Форма (в стиле Apple)
   ==================== */

.form-container {
  background: white;
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  margin-top: 12px;
}

.input-group {
  margin-bottom: 20px;
}

label {
  /* display: block; */
  display: flex;
  margin-bottom: 8px;
  font-size: 15px;
  color: #555;
  font-weight: 500;
  letter-spacing: -0.005em;
}

select {
  /* width: 100%; */
  padding: 14px 16px;
  border: 1px solid #ccc;
  border-radius: 10px;
  font-size: 17px;
  background-color: #fcfcfc;
  font-family: inherit;
  transition: border 0.2s ease;
  color: #000;
}

input[type="number"],
input[type="text"] {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid #ccc;
  border-radius: 10px;
  font-size: 17px;
  background-color: #fcfcfc;
  font-family: inherit;
  transition: border 0.2s ease;
}

input:focus {
  border-color: #0077cc;
  outline: none;
  background-color: white;
  box-shadow: 0 0 0 2px rgba(0, 119, 204, 0.2);
}

select:focus {
  border-color: #0077cc;
  outline: none;
  background-color: white;
  box-shadow: 0 0 0 2px rgba(0, 119, 204, 0.2);
}

.hint {
  font-size: 13px;
  color: var(--tg_theme_hint_color);
  margin-top: 6px;
  line-height: 1.4;
}

.submit-btn {
  margin-top: 12px;
  font-weight: 500;
}

/* ====================
   Профиль
   ==================== */

.profile-info {
  margin-bottom: 28px;
  background: var(--tg_theme_section_bg_color);
  border-radius: 12px;
  padding: 24px;
  border: 1px solid #e9ecef;
}

.profile-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid #e9ecef;
  font-size: 16px;
}

.profile-item:last-child {
  border-bottom: none;
}

.profile-item label {
  display: contents;
  font-weight: 500;
  color: var(--tg_theme_text_color);
}

.profile-item span {
  color: var(--tg_theme_hint_color);
}

.my-lots {
  margin-top: 20px;
}

.lot-item {
  /* background: white;
  border-radius: 14px;
  padding: 18px;
  margin: 12px 0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08); */
  
    background: white;
    border-radius: 14px;
    padding: 18px;
    margin-bottom: 12px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    border: 1px solid #e9ecef;
}

.lot-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-weight: 500;
  font-size: 17px;
}

.lot-status {
  /* padding: 5px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em; */
  
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.lot-status.active {
  background-color: #D1F2EB;
  color: #1AB17B;
}

.lot-status.cancelled {
  background-color: #ffebee;
  color: #c62828;
}

.lot-status.completed {
  background-color: #e3f2fd;
  color: #0d47a1;
}

/* ====================
   Ошибки / Успех
   ==================== */

.error {
  color: #c62828;
  font-size: 14px;
  margin-top: 10px;
  text-align: center;
  font-weight: 400;
}

.success {
  color: #2e7d32;
  font-size: 14px;
  margin-top: 10px;
  text-align: center;
  font-weight: 400;
}

/* ====================
   Пагинация
   ==================== */

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
  padding: 0 16px;
}

.page-info {
  font-size: 14px;
  color: var(--tg_theme_hint_color);
}

/* ====================
   Загрузка
   ==================== */

.loading {
  text-align: center;
  padding: 24px;
  color: var(--tg_theme_hint_color);
  font-size: 15px;
}

/* ====================
   Страница покупки
   ==================== */

.lot-details {
  margin-bottom: 28px;
}

.lot-info {
  /* background: var(--tg_theme_secondary_bg_color); */
  border-radius: 12px;
  /* padding: 18px;
  margin-top: 16px; */
}

.info-row {
  display: flex;
  justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px solid #e9ecef;
  font-size: 16px;
}

.info-row:last-child {
  border-bottom: none;
}

.info-row .label {
  font-weight: 500;
  color: var(--tg_theme_text_color);
}

.info-row .value {
  font-weight: 600;
  color: var(--tg_theme_accent_text_color);
}

.purchase-form {
  background: var(--tg_theme_section_bg_color);
  border-radius: 12px;
  padding: 24px;
  border: 1px solid #e9ecef;
}

.total-price {
  font-size: 22px;
  font-weight: 600;
  color: var(--tg_theme_accent_text_color);
  text-align: center;
  padding: 14px;
  background: var(--tg_theme_secondary_bg_color);
  border-radius: 12px;
  margin-top: 12px;
  letter-spacing: -0.01em;
}

/* ====================
   Профиль - заказы
   ==================== */

.orders-section {
  margin-top: 28px;
}

.order-item {
  background: white;
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  border: 1px solid #e9ecef;
}

.order-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.order-id {
  font-size: 13px;
  color: var(--tg_theme_hint_color);
}

.order-status {
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.order-status.pending {
  background: #fff8e1;
  color: #f57f17;
}

.order-status.confirmed {
  background-color: #D1F2EB;
  color: #1AB17B;
}

.order-status.cancelled {
  background: #ffebee;
  color: #c62828;
}

.order-status.completed {
  background: #e3f2fd;
  color: #0d47a1;
}

.order-details {
  text-align: left;
  font-size: 15px;
  line-height: 1.4;
  color: var(--tg_theme_text_color);
  margin-bottom: 20px;
}

.order-type {
  font-weight: 500;
  margin-bottom: 8px;
}

.order-type.buy {
  color: #c62828;
}

.order-type.sell {
  color: #1AB17B;
}

.btn.confirm {
  background-color: #34C759;
  color: white;
}

/* ====================
   Главная страница
   ==================== */

.welcome-section {
  margin-bottom: 32px;
}

.description {
  font-size: 17px;
  color: var(--tg_theme_subtitle_text_color);
  line-height: 1.6;
  margin-bottom: 28px;
  font-weight: 400;
}

.main-buttons {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 28px;
}

.main-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px;
  background-color: var(--tg_theme_button_color);
  color: var(--tg_theme_button_text_color);
  border: none;
  border-radius: 14px;
  font-size: 17px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  letter-spacing: -0.008em;
}

.main-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.main-btn:active {
  transform: translateY(0);
}

.seller-btn {
  background: linear-gradient(135deg, #4CAF50, #45a049);
}

.buyer-btn {
  background: linear-gradient(135deg, #2196F3, #1976D2);
}

.info-btn {
  background: linear-gradient(135deg, #FF9800, #F57C00);
}

.btn-icon {
  font-size: 22px;
}

.btn-text {
  font-size: 17px;
  font-weight: 500;
}

.support-btn {
  background: var(--tg_theme_secondary_bg_color);
  color: var(--tg_theme_text_color);
  border: 1px solid #e0e0e0;
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
}

.support-btn:hover {
  background: #e8e8e8;
  border-color: #ccc;
}

/* ====================
   Переключатель языка
   ==================== */

.language-switcher {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.lang-btn {
  width: 100px;
  height: 40px;
  border: none;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.95);
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10px);
  margin: 0 6px;
  letter-spacing: -0.005em;
}

.lang-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
}

.lang-btn.active {
  background-color: var(--tg_theme_button_color);
  color: white;
}

.lang-btn.active:hover {
  background: #0056b3;
}

/* ====================
   Рейтинг звездочками
   ==================== */

.rating-container {
  background: var(--tg_theme_section_bg_color);
  border-radius: 12px;
  padding: 20px;
  margin-top: 16px;
  border: 1px solid #e9ecef;
}

.rating-title {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 12px;
  color: var(--tg_theme_text_color);
  text-align: center;
}

.star-rating {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
}

.star {
  font-size: 32px;
  color: #ddd;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.star:hover,
.star.active {
  color: #ffc107;
  transform: scale(1.1);
}

.star:active {
  transform: scale(1);
}

.rating-comment {
  width: 100%;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  resize: vertical;
  min-height: 80px;
  margin-bottom: 16px;
  font-family: inherit;
}

.rating-comment:focus {
  border-color: var(--tg_theme_button_color);
  outline: none;
  box-shadow: 0 0 0 2px rgba(0, 119, 204, 0.2);
}

.rating-actions {
  display: flex;
  gap: 12px;
}

.btn.rate-submit {
  background-color: #ffc107;
  color: #000;
  font-weight: 600;
}

.btn.rate-cancel {
  background-color: #6c757d;
  color: white;
}

.rating-display {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.rating-stars {
  color: #ffc107;
  font-size: 14px;
  margin-right: 4px;
}

.rating-text {
  font-size: 14px;
  color: var(--tg_theme_hint_color);
}

.rating-value {
  font-weight: 600;
  color: var(--tg_theme_text_color);
  margin-right: 4px;
}

.rating-count {
  color: var(--tg_theme_hint_color);
  font-size: 13px;
}

.no-rating {
  color: var(--tg_theme_hint_color);
  font-style: italic;
}

/* ====================
   Адаптивность
   ==================== */

@media (max-width: 480px) {
  body {
    padding: 12px;
  }

  .container {
    border-radius: 14px;
    margin-top: 10px;
  }

  .content {
    padding: 20px 16px;
  }

  .title {
    font-size: 24px;
  }

  .subtitle {
    font-size: 15px;
  }

  .main-btn {
    padding: 18px 16px;
    font-size: 16px;
  }

  .btn-icon {
    font-size: 20px;
  }

  .lang-btn {
    width: 90px;
    height: 40px;
    font-size: 14px;
  }
}

/* Загрузочный экран */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--tg-theme-bg-color, #ffffff);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s ease;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--tg-theme-hint-color, #cccccc);
    border-top: 3px solid var(--tg-theme-button-color, #007AFF);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

.loading-text {
    color: var(--tg-theme-text-color, #000000);
    font-size: 16px;
    font-weight: 400;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Скрываем загрузочный экран с плавным исчезновением */
.loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}