/**
 * Remote Inject - Base Styles
 * Shared styles across all pages
 * Import after theme.css
 */

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

/* ============ Base Body ============ */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--color-bg-primary);
  color: var(--color-text-primary);
  line-height: 1.6;
}

/* ============ Utility Classes ============ */
.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.text-left {
  text-align: left;
}

/* ============ Loading Spinner ============ */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--color-accent);
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 1s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}

.loading-ring {
  width: 56px;
  height: 56px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* ============ Pulse Animation ============ */
.pulse-ring {
  position: absolute;
  top: 0;
  left: 0;
  width: 56px;
  height: 56px;
  border: 2px solid var(--color-warning);
  border-radius: 50%;
  animation: pulse 1.5s ease-out infinite;
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.3); opacity: 0; }
}

/* ============ Status Badges ============ */
.status {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
}

.status.checking {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.status.success {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.status.error {
  background: var(--color-error-bg);
  color: var(--color-error);
}

/* ============ Buttons ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

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

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

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

.btn-secondary {
  background: var(--color-bg-tertiary);
  color: var(--color-text-primary);
}

.btn-secondary:hover:not(:disabled) {
  filter: brightness(0.95);
}

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

.btn-ghost:hover:not(:disabled) {
  border-color: var(--color-text-secondary);
  color: var(--color-text-primary);
}

.btn-danger {
  background: var(--color-error);
  color: white;
}

.btn-danger:hover:not(:disabled) {
  filter: brightness(0.9);
}

.btn-disconnect {
  background: var(--color-error-bg);
  color: var(--color-error);
}

.btn-disconnect:hover:not(:disabled) {
  filter: brightness(0.95);
}

/* ============ Form Controls ============ */
.form-input {
  width: 100%;
  padding: 12px 16px;
  font-size: 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-secondary);
  color: var(--color-text-primary);
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus {
  border-color: var(--color-accent);
}

.form-input::placeholder {
  color: var(--color-text-muted);
}

/* ============ Top Controls (Theme/Lang) ============ */
.top-controls {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  gap: 8px;
}

.ctrl-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
  color: var(--color-text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
}

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

select.ctrl-btn.lang {
  width: auto;
  padding: 0 12px;
  padding-right: 24px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  appearance: none;
  -webkit-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='%23888' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

select.ctrl-btn.lang option {
  background: var(--color-bg-secondary);
  color: var(--color-text-primary);
}

/* ============ DApp Info Card ============ */
.dapp-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 16px;
}

.dapp-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--color-bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  overflow: hidden;
  color: var(--color-text-secondary);
  flex-shrink: 0;
}

.dapp-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dapp-text {
  text-align: left;
  min-width: 0;
}

.dapp-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dapp-url {
  font-size: 13px;
  color: var(--color-accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============ Wallet Info ============ */
.wallet-info {
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-md);
  padding: 12px;
}

.wallet-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.wallet-row + .wallet-row {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--color-border);
}

.wallet-label {
  color: var(--color-text-muted);
}

.wallet-value {
  color: var(--color-text-primary);
  font-weight: 500;
  font-family: monospace;
  font-size: 12px;
}

/* ============ Guide Box ============ */
.guide {
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: left;
}

.guide h3 {
  font-size: 14px;
  color: var(--color-text-primary);
  margin-bottom: 12px;
}

.guide ol {
  padding-left: 18px;
  color: var(--color-text-secondary);
  font-size: 13px;
  line-height: 1.7;
}

.guide li {
  margin-bottom: 4px;
}

/* ============ Brand Footer ============ */
.brand-footer {
  position: fixed;
  bottom: 12px;
  left: 0;
  right: 0;
  text-align: center;
}

.brand-footer a {
  color: var(--color-text-muted);
  font-size: 11px;
  text-decoration: none;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.brand-footer a:hover {
  opacity: 0.8;
}

/* ============ Error Container ============ */
.error-container {
  padding: 40px 20px;
  text-align: center;
}

.error-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.error-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-error);
  margin-bottom: 8px;
}

.error-desc {
  font-size: 14px;
  color: var(--color-text-secondary);
}

/* ============ Code Block ============ */
.code-block {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: var(--color-bg-tertiary);
  border-bottom: 1px solid var(--color-border);
}

.code-header span {
  font-size: 12px;
  color: var(--color-text-muted);
  font-weight: 500;
}

.code-copy {
  padding: 4px 10px;
  font-size: 11px;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.code-copy:hover {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: white;
}

pre {
  padding: 20px;
  overflow-x: auto;
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
}

/* Code syntax highlighting */
code .c { color: var(--color-text-muted); }
code .k { color: #a855f7; }
code .s { color: #22c55e; }
code .f { color: #3b82f6; }

/* ============ Info Grid ============ */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.info-item {
  background: var(--color-bg-tertiary);
  padding: 16px;
  border-radius: var(--radius-md);
}

.info-label {
  font-size: 12px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.info-value {
  font-family: monospace;
  font-size: 14px;
  color: var(--color-text-primary);
  word-break: break-all;
}

/* ============ Card ============ */
.card {
  background: var(--color-bg-secondary);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
}

.card h2 {
  font-size: 18px;
  color: var(--color-text-primary);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--color-border);
}

/* ============ Container (centered card) ============ */
.container-card {
  background: var(--color-bg-secondary);
  border-radius: var(--radius-xl);
  padding: 24px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-elevated);
}

/* ============ Responsive ============ */
@media (max-width: 640px) {
  .top-controls {
    top: 12px;
    right: 12px;
  }

  .ctrl-btn {
    width: 36px;
    height: 36px;
  }

  select.ctrl-btn.lang {
    padding: 0 8px;
    padding-right: 20px;
    font-size: 11px;
  }
}
