/* CSS Variables */
:root {
  --primary: #667eea;
  --primary-dark: #5a67d8;
  --secondary: #764ba2;
  --success: #48bb78;
  --danger: #f56565;
  --warning: #ed8936;
  --gray-100: #f7fafc;
  --gray-200: #edf2f7;
  --gray-300: #e2e8f0;
  --gray-400: #cbd5e0;
  --gray-500: #a0aec0;
  --gray-600: #718096;
  --gray-700: #4a5568;
  --gray-800: #2d3748;
  --gray-900: #1a202c;
  --white: #ffffff;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Body */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  min-height: 100vh;
  color: var(--gray-800);
  line-height: 1.6;
}

/* App Container */
.app-container {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--white);
}

.logo {
  font-size: 1.5rem;
  font-weight: bold;
}

.env-badge {
  background: rgba(255, 255, 255, 0.2);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.env-badge.android {
  background: var(--success);
}

.env-badge.pwa {
  background: var(--primary-dark);
}

.env-badge.browser {
  background: var(--warning);
}

/* Main Content */
.main-content {
  flex: 1;
  padding: 0 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Cards */
.card {
  background: var(--white);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow-lg);
}

/* Status Card */
.status-card {
  text-align: center;
}

.status-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.status-card h2 {
  color: var(--gray-800);
  margin-bottom: 8px;
}

.status-text {
  color: var(--gray-600);
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--gray-100);
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
}

.status-indicator .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gray-400);
  animation: pulse 2s infinite;
}

.status-indicator.active .dot {
  background: var(--success);
}

.status-indicator.inactive .dot {
  background: var(--gray-400);
}

.status-indicator.error .dot {
  background: var(--danger);
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

/* Toggle Card */
.toggle-card h3 {
  color: var(--gray-800);
  margin-bottom: 8px;
}

.toggle-description {
  color: var(--gray-600);
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.toggle-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 16px;
}

.toggle-label {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--gray-600);
  min-width: 80px;
}

.toggle-label.active {
  color: var(--success);
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 64px;
  height: 34px;
}

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

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--gray-300);
  transition: 0.3s;
  border-radius: 34px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 26px;
  width: 26px;
  left: 4px;
  bottom: 4px;
  background-color: var(--white);
  transition: 0.3s;
  border-radius: 50%;
  box-shadow: var(--shadow);
}

.toggle-switch input:checked+.toggle-slider {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
}

.toggle-switch input:checked+.toggle-slider:before {
  transform: translateX(30px);
}

.toggle-switch input:disabled+.toggle-slider {
  opacity: 0.5;
  cursor: not-allowed;
}

.toggle-status {
  text-align: center;
  color: var(--gray-500);
  font-size: 0.85rem;
}

.toggle-status.subscribed {
  color: var(--success);
}

/* Info Card */
.info-card h3 {
  color: var(--gray-800);
  margin-bottom: 16px;
}

.info-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-200);
}

.info-item:last-child {
  border-bottom: none;
}

.info-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.info-text strong {
  display: block;
  color: var(--gray-800);
  margin-bottom: 2px;
}

.info-text p {
  color: var(--gray-600);
  font-size: 0.85rem;
}

/* Install Card */
.install-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: var(--white);
}

.install-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.install-icon {
  font-size: 32px;
}

.install-text strong {
  display: block;
}

.install-text p {
  font-size: 0.85rem;
  opacity: 0.9;
}

.install-button {
  background: var(--white);
  color: var(--primary);
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s;
}

.install-button:hover {
  transform: scale(1.05);
}

/* Debug Card */
.debug-card {
  background: var(--gray-900);
  color: var(--gray-300);
}

.debug-card h3 {
  color: var(--white);
  margin-bottom: 12px;
}

.debug-card pre {
  background: var(--gray-800);
  padding: 12px;
  border-radius: 8px;
  font-size: 0.75rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  margin-bottom: 12px;
}

.debug-toggle {
  background: var(--primary);
  color: var(--white);
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  width: 100%;
}

/* Footer */
.footer {
  padding: 20px;
  text-align: center;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.85rem;
}

.debug-toggle-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  color: var(--white);
  font-size: 0.75rem;
  cursor: pointer;
  margin-top: 8px;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  color: var(--white);
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Toast Container */
.toast-container {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--gray-900);
  color: var(--white);
  padding: 12px 24px;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
  white-space: nowrap;
}

.toast.success {
  background: var(--success);
}

.toast.error {
  background: var(--danger);
}

.toast.info {
  background: var(--primary);
}

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

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Token Card Styles */
.token-card {
  background: var(--white);
  border-left: 4px solid var(--primary);
}

.token-description {
  color: var(--gray-600);
  font-size: 14px;
  margin-bottom: 16px;
}

.token-section {
  margin-top: 16px;
}

.token-header {
  margin-bottom: 12px;
}

.token-type-badge {
  display: inline-block;
  background: var(--primary);
  color: var(--white);
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.token-type-badge.android {
  background: #3ddc84;
}

.token-type-badge.webpush {
  background: var(--primary);
}

.token-display {
  background: var(--gray-100);
  border: 2px solid var(--gray-300);
  border-radius: 8px;
  padding: 12px;
  margin: 12px 0;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  word-break: break-all;
  max-height: 120px;
  overflow-y: auto;
  transition: all 0.2s ease;
}

.token-display:hover {
  border-color: var(--primary);
}

.token-display.has-token {
  background: var(--success);
  color: var(--white);
  border-color: var(--success);
}

.token-placeholder {
  color: var(--gray-500);
  font-style: italic;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

.token-actions {
  display: flex;
  gap: 8px;
  margin: 12px 0;
}

.token-button {
  flex: 1;
  background: var(--primary);
  color: var(--white);
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.token-button:hover:not(:disabled) {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.token-button:active:not(:disabled) {
  transform: translateY(0);
}

.token-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.token-button.secondary {
  background: var(--gray-300);
  color: var(--gray-700);
}

.token-button.secondary:hover:not(:disabled) {
  background: var(--gray-400);
}

.token-info {
  margin-top: 8px;
  color: var(--gray-600);
  font-size: 13px;
}

.token-info.success {
  color: var(--success);
  font-weight: 600;
}

.token-info.error {
  color: var(--danger);
  font-weight: 600;
}

/* Update Banner */
.update-banner {
  position: fixed;
  top: -200px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: var(--white);
  padding: 16px 20px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 10000;
  max-width: 90%;
  width: 400px;
  transition: top 0.3s ease;
}

.update-banner.show {
  top: 20px;
}

/* Forced Update Overlay */
.update-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20000;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.update-overlay.show {
  opacity: 1;
}

.update-modal {
  background: var(--white);
  border-radius: 16px;
  padding: 40px 32px;
  max-width: 90%;
  width: 400px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease;
}

.update-icon-large {
  font-size: 64px;
  display: block;
  margin-bottom: 20px;
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.1);
  }
}

.update-modal h2 {
  color: var(--gray-900);
  margin-bottom: 12px;
  font-size: 24px;
}

.update-modal p {
  color: var(--gray-600);
  margin-bottom: 12px;
  line-height: 1.6;
}

.update-version {
  background: var(--gray-100);
  padding: 12px;
  border-radius: 8px;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  color: var(--primary);
  font-weight: 600;
  margin: 16px 0;
}

.update-countdown {
  background: var(--warning);
  color: var(--white);
  padding: 12px;
  border-radius: 8px;
  margin: 16px 0;
  font-weight: 600;
}

.update-countdown #countdown {
  font-size: 20px;
  font-weight: bold;
}

.update-button-large {
  width: 100%;
  padding: 16px;
  background: var(--primary);
  color: var(--white);
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 8px;
}

.update-button-large:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(102, 126, 234, 0.3);
}

.update-content {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.update-icon {
  font-size: 28px;
  animation: rotate 2s linear infinite;
}

@keyframes rotate {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.update-text strong {
  display: block;
  font-size: 16px;
  margin-bottom: 4px;
}

.update-text p {
  margin: 0;
  font-size: 13px;
  opacity: 0.9;
}

.update-button,
.update-dismiss {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  margin-right: 8px;
  transition: all 0.2s ease;
}

.update-button {
  background: var(--white);
  color: var(--primary);
}

.update-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.update-dismiss {
  background: transparent;
  color: var(--white);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.update-dismiss:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Responsive */
@media (max-width: 360px) {
  .card {
    padding: 16px;
  }

  .toggle-container {
    flex-direction: column;
    gap: 12px;
  }

  .token-display {
    font-size: 10px;
  }

  .token-actions {
    flex-direction: column;
  }
}

/* Safe area for notched devices */
@supports (padding: env(safe-area-inset-top)) {
  .header {
    padding-top: calc(20px + env(safe-area-inset-top));
  }

  .footer {
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }
}