:root {
  --bg-color: #0f172a;
  --card-bg: rgba(30, 41, 59, 0.7);
  --card-border: rgba(255, 255, 255, 0.1);
  --text-color: #f8fafc;
  --text-muted: #94a3b8;
  --accent-color: #3b82f6;
  --accent-hover: #2563eb;
  --success-color: #22c55e;
  --warning-color: #eab308;
  --danger-color: #ef4444;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  min-height: 100vh;
  padding-bottom: 24px;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.user-info h2 {
  font-size: 16px;
  font-weight: 700;
}

.sub-badge {
  font-size: 12px;
  color: var(--success-color);
  font-weight: 500;
}

.header-btn {
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-color);
  border-radius: 20px;
  padding: 6px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.2s ease;
  backdrop-filter: blur(8px);
}

.header-btn .btn-icon {
  width: 14px;
  height: 14px;
  transition: transform 0.4s ease;
}

.header-btn:hover {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.3);
  color: #3b82f6;
}

.header-btn:hover .btn-icon {
  transform: rotate(180deg);
}

.header-btn.logout-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: #ef4444;
}

.header-btn.logout-btn:hover .btn-icon {
  transform: translateX(-2px);
}

.header-btn:active {
  transform: scale(0.95);
}

/* Tabs */
.nav-tabs {
  display: flex;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--card-border);
  padding: 4px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  backdrop-filter: blur(10px);
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 10px 4px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn.active {
  background: var(--accent-color);
  color: #fff;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

/* Tab Content */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Hero Status Card */
.hero-card {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.9), rgba(15, 23, 42, 0.9));
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pulse-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: var(--danger-color);
  box-shadow: 0 0 10px var(--danger-color);
  transition: all 0.3s ease;
}

.pulse-dot.active {
  background-color: var(--success-color);
  box-shadow: 0 0 12px var(--success-color);
}

.status-label {
  font-weight: 700;
  font-size: 15px;
}

/* Switch Toggle */
.switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #475569;
  transition: .3s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .3s;
}

input:checked + .slider {
  background-color: var(--success-color);
}

input:checked + .slider:before {
  transform: translateX(24px);
}

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

.switch.disabled-expired {
  opacity: 0.5;
  cursor: not-allowed;
}

.switch.disabled-expired .slider {
  cursor: not-allowed;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 14px 10px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-icon {
  font-size: 20px;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-color);
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Card General */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
  backdrop-filter: blur(10px);
}

.card h3 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Timer Chips */
.chips-container {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  flex: 1;
  min-width: 60px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--card-border);
  color: var(--text-color);
  padding: 10px 0;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
}

.chip.active {
  background: var(--accent-color);
  border-color: var(--accent-color);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

/* Groups Section */
.groups-header {
  margin-bottom: 14px;
}

.search-box {
  position: relative;
  margin-bottom: 10px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
}

.search-box input {
  width: 100%;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 10px 12px 10px 36px;
  color: var(--text-color);
  font-size: 14px;
  outline: none;
}

.action-buttons {
  display: flex;
  gap: 8px;
}

.btn {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: none;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-color);
  border: 1px solid var(--card-border);
}

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

.btn-block {
  width: 100%;
}

/* Group Item */
.groups-list {
  max-height: 380px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.group-item {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: background 0.2s ease;
}

.group-item:hover {
  background: rgba(59, 130, 246, 0.1);
}

.group-title {
  font-size: 14px;
  font-weight: 600;
}

/* Post Editor & Preview */
.post-editor textarea {
  width: 100%;
  min-height: 120px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 12px;
  color: var(--text-color);
  font-size: 14px;
  outline: none;
  resize: vertical;
}

.telegram-preview-box {
  background: #182533;
  border-radius: var(--radius-md);
  padding: 12px;
  border-left: 3px solid #2b5278;
}

.preview-author {
  color: #64b5ef;
  font-weight: 700;
  font-size: 13px;
}

.preview-body {
  margin-top: 6px;
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
}

/* Credit Card View */
.credit-card-view {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  margin-bottom: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  position: relative;
}

.card-chip {
  font-size: 24px;
  margin-bottom: 16px;
}

.card-brand {
  position: absolute;
  top: 20px;
  right: 20px;
  font-weight: 800;
  font-size: 14px;
  color: #38bdf8;
}

.card-number {
  font-family: monospace;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 2px;
  margin-bottom: 20px;
  color: #f8fafc;
}

.card-footer {
  display: flex;
  justify-content: space-between;
}

.card-footer .label {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.card-footer .val {
  font-weight: 700;
  font-size: 13px;
}

/* Account Warning Banner */
.account-warning-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: rgba(234, 179, 8, 0.15);
  border: 1px solid rgba(234, 179, 8, 0.3);
  padding: 14px;
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  box-shadow: 0 4px 15px rgba(234, 179, 8, 0.05);
  animation: slideDown 0.3s ease;
}

.account-warning-banner .warning-icon {
  font-size: 20px;
  background: rgba(234, 179, 8, 0.2);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
  color: var(--warning-color);
}

.account-warning-banner .warning-content h4 {
  font-size: 14px;
  font-weight: 700;
  color: #fef08a;
  margin-bottom: 4px;
}

.account-warning-banner .warning-content p {
  font-size: 12px;
  color: #e2e8f0;
  line-height: 1.4;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Onboarding / Login View */
.onboarding-container {
  display: flex;
  flex-direction: column;
  padding: 32px 16px;
  min-height: calc(100vh - 100px);
  justify-content: center;
  animation: fadeIn 0.4s ease;
}

/* Keyboard open compact layout overrides */
.onboarding-container:has(input:focus) {
  min-height: auto;
  padding-top: 10px;
}
.onboarding-container:has(input:focus) .glow-logo {
  height: 48px;
  width: 48px;
  font-size: 28px;
  margin-bottom: 10px;
}
.onboarding-container:has(input:focus) .onboarding-header {
  margin-bottom: 12px;
}
.onboarding-container:has(input:focus) .onboarding-header p {
  display: none;
}

.onboarding-header {
  text-align: center;
  margin-bottom: 32px;
}

.onboarding-header h2 {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 12px;
  background: linear-gradient(135deg, #38bdf8, #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.onboarding-header p {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
}

.glow-logo {
  font-size: 56px;
  width: 90px;
  height: 90px;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px auto;
  box-shadow: 0 0 30px rgba(59, 130, 246, 0.2);
  animation: pulse-glow 2s infinite alternate;
}

@keyframes pulse-glow {
  0% {
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.2);
  }
  100% {
    box-shadow: 0 0 30px rgba(59, 130, 246, 0.4);
    border-color: rgba(59, 130, 246, 0.4);
  }
}

.auth-step {
  width: 100%;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  padding: 24px;
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.auth-status-message.success {
  display: block !important;
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: #86efac;
}

.auth-status-message.error {
  display: block !important;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.auth-status-message.info {
  display: block !important;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #93c5fd;
}

/* Subscription Status Card */
.sub-status-card {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.6), rgba(15, 23, 42, 0.8));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 20px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(12px);
}

.sub-status-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: 12px;
}

.sub-status-icon {
  font-size: 24px;
  background: rgba(59, 130, 246, 0.1);
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sub-status-title h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
}

.sub-status-indicator {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  display: inline-block;
}

.sub-status-indicator.active {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.sub-status-indicator.expired {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.sub-status-details {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sub-detail-item {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.sub-detail-item .detail-label {
  color: var(--text-muted);
}

.sub-detail-item .detail-val {
  font-weight: 600;
}

.sub-detail-item .detail-val.text-glow {
  color: #3b82f6;
  text-shadow: 0 0 10px rgba(59, 130, 246, 0.4);
}

/* Media Dropzone styling */
.media-dropzone {
  border: 2px dashed rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  background: rgba(15, 23, 42, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.media-dropzone:hover {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.08);
}

.media-dropzone.dragover {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.08);
}

.dropzone-text {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 4px;
}

/* Preview Media item */
.preview-media img, .preview-media video {
  width: 100%;
  height: auto;
  object-fit: cover;
  display: block;
}

/* Responsive Optimizations for Small Mobile Devices */
@media (max-width: 480px) {
  /* Compact Action Header Buttons (Turning labels off, keeping clean circular icons) */
  .header-btn {
    padding: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    justify-content: center;
    gap: 0;
  }
  .header-btn span {
    display: none; /* Hide 'Yangilash' / 'Chiqish' text on mobile viewports */
  }
  .header-btn .btn-icon {
    width: 15px;
    height: 15px;
    margin: 0;
  }
  .header-actions {
    gap: 6px;
  }

  /* User Info meta spacing adjustments */
  .user-profile {
    gap: 8px;
    max-width: 50%;
  }
  .user-info h2 {
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 110px;
  }
  .sub-badge {
    font-size: 11px;
    white-space: nowrap;
  }

  /* Clever Nav Tabs (Hiding inactive texts, expanding the active tab with sliding animations) */
  .nav-tabs {
    padding: 3px;
    gap: 4px;
  }
  .tab-btn {
    padding: 8px 4px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex: 1 1 0%;
  }
  .tab-btn .tab-text {
    display: none; /* Hide text of inactive tab buttons on mobile */
  }
  .tab-btn.active {
    flex: 2.2 1 0%; /* Expand active tab smoothly */
    background: var(--accent-color);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
  }
  .tab-btn.active .tab-text {
    display: inline-block;
    margin-left: 5px;
    white-space: nowrap;
    animation: slideFadeInTab 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  }
}

@keyframes slideFadeInTab {
  from {
    opacity: 0;
    transform: translateX(6px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
