:root {
  /* Light theme colors */
  --color-primary: #007AFF;
  --color-primary-dark: #0056CC;
  --color-primary-light: rgba(0, 122, 255, 0.1);
  --color-success: #34C759;
  --color-error: #FF3B30;
  --color-warning: #FF9500;
  --color-accent: #5856D6;

  --color-bg: #F2F2F7;
  --color-surface: #FFFFFF;
  --color-card-bg: #FFFFFF;
  --color-text: #000000;
  --color-text-secondary: #8E8E93;
  --color-border: #C6C6C8;
  --color-border-light: #E5E5EA;

  --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
}

[data-color-scheme="dark"] {
  /* Dark theme colors with improved contrast */
  --color-bg: #0A0A0B;
  --color-surface: #1C1C1E;
  --color-card-bg: #2C2C2E;
  --color-text: #FFFFFF;
  --color-text-secondary: #B3B3B8;
  --color-border: #48484A;
  --color-border-light: #3A3A3C;

  /* Enhanced shadows for dark theme */
  --shadow: 0 2px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);
  
  /* Improved primary colors for dark theme */
  --color-primary: #5AC8FA;
  --color-primary-dark: #007AFF;
  --color-primary-light: rgba(90, 200, 250, 0.15);
  
  /* Better status colors for dark theme */
  --color-success: #32D74B;
  --color-error: #FF453A;
  --color-warning: #FF9F0A;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0 16px;
  height: 60px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header__content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}

.header__title {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
  color: var(--color-primary);
}

.theme-toggle {
  background: none;
  border: none;
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
}

.theme-toggle:hover {
  background: var(--color-border);
}

.theme-toggle__icon {
  color: var(--color-text-secondary);
  transition: opacity 0.2s ease;
}

.theme-toggle__icon--moon {
  display: none;
}

[data-color-scheme="dark"] .theme-toggle__icon--sun {
  display: none;
}

[data-color-scheme="dark"] .theme-toggle__icon--moon {
  display: block;
}

/* Main Content */
.main {
  flex: 1;
  padding: 16px;
  max-width: 400px;
  margin: 0 auto;
  width: 100%;
}

/* Screens */
.screen {
  display: none;
}

.screen.active {
  display: block;
}

/* Cards */
.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--color-border);
  transition: all 0.2s ease;
}

.card__body {
  padding: 20px;
}

/* Login */
.login__card {
  margin-top: 40px;
}

.login__title {
  font-size: 24px;
  font-weight: 600;
  margin: 0 0 8px 0;
  text-align: center;
}

.login__subtitle {
  color: var(--color-text-secondary);
  margin: 0 0 32px 0;
  text-align: center;
}

.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-weight: 500;
  margin-bottom: 8px;
  font-size: 14px;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color 0.2s ease;
}

.form-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.form-error {
  color: var(--color-error);
  font-size: 14px;
  margin-top: 4px;
  min-height: 20px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  position: relative;
}

.btn--primary {
  background: var(--color-primary);
  color: white;
}

.btn--primary:hover {
  background: var(--color-primary-dark);
}

.btn--ghost {
  background: transparent;
  color: var(--color-text-secondary);
}

.btn--ghost:hover {
  background: var(--color-border);
}

.btn--full {
  width: 100%;
}

.btn--sm {
  padding: 8px 12px;
  font-size: 14px;
}

.btn__loader {
  position: absolute;
}

.loader {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top: 2px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* User Info */
.user-info {
  margin-bottom: 20px;
}

.user-info .card__body {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-info__details {
  flex: 1;
}

.user-info__name {
  margin: 0 0 4px 0;
  font-size: 18px;
  font-weight: 600;
}

.user-info__chatid {
  margin: 0;
  color: var(--color-text-secondary);
  font-size: 14px;
}

/* Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stats__card .card__body {
  padding: 16px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.stat__icon {
  font-size: 24px;
  margin-bottom: 8px;
}

.stat__value {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 4px;
}

.stat__label {
  font-size: 12px;
  color: var(--color-text-secondary);
}

/* Progress */
.progress-card {
  margin-bottom: 20px;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.progress-info__title {
  margin: 0;
  font-size: 16px;
  font-weight: 500;
}

.progress-info__percentage {
  font-size: 14px;
  color: var(--color-text-secondary);
}

.progress-bar {
  height: 8px;
  background: var(--color-border);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-success));
  transition: width 0.3s ease;
}

/* Payments */
.payments__title {
  margin: 0 0 16px 0;
  font-size: 18px;
  font-weight: 600;
}

.tariffs {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tariff {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.tariff:hover {
  border-color: var(--color-primary);
}

.tariff--popular {
  border-color: var(--color-primary);
  background: rgba(0, 122, 255, 0.05);
}

.tariff__badge {
  position: absolute;
  top: -8px;
  right: 16px;
  background: var(--color-primary);
  color: white;
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 4px;
  font-weight: 500;
}

.tariff__content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tariff__minutes {
  font-weight: 500;
  font-size: 16px;
  color: var(--color-text);
}

.tariff__price {
  font-weight: 600;
  font-size: 18px;
  color: var(--color-primary);
}

/* News Section */
.news-section {
  margin-top: 20px;
}

.news-section__title {
  margin: 0 0 16px 0;
  font-size: 18px;
  font-weight: 600;
}

.news-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.news-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  gap: 12px;
}

.news-loader p {
  color: var(--color-text-secondary);
  margin: 0;
  font-size: 14px;
}

.news-item {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 16px;
  transition: all 0.2s ease;
}

.news-item:hover {
  border-color: var(--color-primary);
  box-shadow: 0 4px 12px rgba(0, 122, 255, 0.1);
}

.news-item--info {
  border-left: 4px solid var(--color-primary);
}

.news-item--normal {
  border-left: 4px solid var(--color-success);
}

.news-item--important {
  border-left: 4px solid var(--color-warning);
}

.news-item__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
  gap: 12px;
}

.news-item__title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  color: var(--color-text);
  flex: 1;
}

.news-item__badge {
  background: var(--color-primary);
  color: white;
  padding: 4px 8px;
  font-size: 11px;
  border-radius: 4px;
  font-weight: 500;
  text-transform: uppercase;
  white-space: nowrap;
}

.news-item__badge--info {
  background: var(--color-primary);
}

.news-item__badge--normal {
  background: var(--color-success);
}

.news-item__badge--important {
  background: var(--color-warning);
}

.news-item__content {
  color: var(--color-text);
  font-size: 14px;
  line-height: 1.5;
  margin: 0 0 8px 0;
}

.news-item__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--color-border);
}

.news-item__date {
  color: var(--color-text-secondary);
  font-size: 12px;
}

.news-item__author {
  color: var(--color-text-secondary);
  font-size: 12px;
}

.news-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--color-text-secondary);
}

.news-empty__icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.news-empty__text {
  margin: 0;
  font-size: 14px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
  border: 1px solid var(--color-border);
  z-index: 1000;
  opacity: 0;
  transition: all 0.3s ease;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast--error {
  border-left: 4px solid var(--color-error);
}

.toast--success {
  border-left: 4px solid var(--color-success);
}

.toast__content {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.toast__icon {
  color: var(--color-error);
}

.toast--success .toast__icon {
  color: var(--color-success);
}

.toast__close {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}

.toast__close:hover {
  background: var(--color-border);
}

/* Responsive */
@media (max-width: 480px) {
  .main {
    padding: 12px;
  }

  .stats {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .stat {
    flex-direction: row;
    text-align: left;
  }

  .stat__icon {
    margin-bottom: 0;
    margin-right: 12px;
  }
}
