/* ============================================
   SOPI TOOLS — Premium Mobile-First Design
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* === CSS Variables === */
:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.7);
  --bg-card-hover: rgba(31, 41, 55, 0.8);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  
  --accent-primary: #f97316;
  --accent-secondary: #fb923c;
  --accent-gradient: linear-gradient(135deg, #f97316, #ef4444);
  --accent-glow: rgba(249, 115, 22, 0.3);
  
  --text-primary: #f9fafb;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.3);
  --danger: #ef4444;
  --info: #3b82f6;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;
  
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100dvh;
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* === Background Gradient === */
body::before {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 30% 20%, rgba(249, 115, 22, 0.06) 0%, transparent 50%),
              radial-gradient(circle at 70% 80%, rgba(239, 68, 68, 0.04) 0%, transparent 50%),
              radial-gradient(circle at 50% 50%, rgba(59, 130, 246, 0.03) 0%, transparent 50%);
  z-index: 0;
  pointer-events: none;
}

/* === Layout === */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px;
  min-height: 100dvh;
}

/* === Header === */
.app-header {
  text-align: center;
  padding: 24px 0 32px;
}

.app-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  background: var(--accent-gradient);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  box-shadow: 0 4px 20px var(--accent-glow);
  animation: float 3s ease-in-out infinite;
}

.app-logo svg {
  width: 28px;
  height: 28px;
  fill: white;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.app-title {
  font-size: 1.75rem;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.app-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* === Cards === */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: 24px;
  box-shadow: var(--glass-shadow);
  transition: transform var(--transition-slow), box-shadow var(--transition-slow);
}

.card + .card {
  margin-top: 16px;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* === Inputs === */
.input-group {
  margin-bottom: 12px;
  animation: slideIn 0.3s ease forwards;
  opacity: 0;
}

.input-group.visible {
  opacity: 1;
}

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

.input-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.input-field {
  width: 100%;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

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

.input-field:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.input-row .input-field {
  flex: 1;
}

.input-label-field {
  width: 100%;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
  margin-bottom: 6px;
}

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

.input-label-field:focus {
  border-color: var(--accent-secondary);
  box-shadow: 0 0 0 3px rgba(251, 146, 60, 0.2);
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-base);
  outline: none;
  text-decoration: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 4px 16px var(--accent-glow);
  width: 100%;
  padding: 14px 24px;
  font-size: 1rem;
}

.btn-primary:hover {
  box-shadow: 0 6px 24px var(--accent-glow);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0) scale(0.98);
}

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

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-sm {
  padding: 8px 12px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.btn-remove {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-remove:hover {
  background: rgba(239, 68, 68, 0.2);
}

.btn-add {
  background: rgba(59, 130, 246, 0.1);
  color: var(--info);
  border: 1px dashed rgba(59, 130, 246, 0.3);
  width: 100%;
  padding: 10px;
  margin-top: 4px;
  font-size: 0.85rem;
}

.btn-add:hover {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.5);
}

.btn-copy {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.btn-copy:hover {
  background: rgba(16, 185, 129, 0.2);
}

.btn-copy.copied {
  background: var(--success);
  color: white;
}

.btn-link {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
  width: 100%;
  padding: 14px 20px;
  font-size: 0.95rem;
  border-radius: var(--radius-lg);
  justify-content: space-between;
  margin-bottom: 8px;
  transition: all var(--transition-base);
}

.btn-link:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-primary);
  box-shadow: 0 2px 12px var(--accent-glow);
}

.btn-link .link-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 80%;
  text-align: left;
}

.btn-link .link-arrow {
  color: var(--accent-primary);
  font-size: 1.1rem;
  flex-shrink: 0;
}

/* === Generator Section === */
.generator-section {
  margin-top: 8px;
}

.generator-result {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-top: 12px;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: border-color var(--transition-fast);
}

.generator-result.has-value {
  border-color: rgba(16, 185, 129, 0.3);
}

.generator-result-text {
  font-size: 0.95rem;
  color: var(--text-primary);
  word-break: break-word;
  flex: 1;
  line-height: 1.5;
}

.generator-result-text.placeholder {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.85rem;
}

.generator-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.generator-actions .btn {
  flex: 1;
}

/* === Address Result === */
.address-block {
  line-height: 1.7;
}

.address-label {
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* === Link Result === */
.generated-link-box {
  margin-top: 16px;
  padding: 16px;
  background: rgba(16, 185, 129, 0.05);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: var(--radius-lg);
  animation: fadeIn 0.5s ease;
}

.generated-link-url {
  font-size: 0.8rem;
  color: var(--text-secondary);
  word-break: break-all;
  margin-bottom: 12px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-sm);
  font-family: monospace;
}

/* === Divider === */
.divider {
  height: 1px;
  background: var(--glass-border);
  margin: 20px 0;
}

/* === Toast Notification === */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-secondary);
  color: var(--text-primary);
  padding: 12px 24px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  border: 1px solid var(--glass-border);
  z-index: 1000;
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.success {
  border-color: rgba(16, 185, 129, 0.4);
}

.toast.error {
  border-color: rgba(239, 68, 68, 0.4);
}

/* === Animations === */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.animate-fade-in {
  animation: fadeIn 0.4s ease forwards;
}

/* === Footer === */
.app-footer {
  text-align: center;
  padding: 32px 0 16px;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.app-footer a {
  color: var(--accent-primary);
  text-decoration: none;
}

/* === Scrollbar === */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

/* === Badge === */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-count {
  background: rgba(249, 115, 22, 0.15);
  color: var(--accent-primary);
}

/* === Loading Skeleton === */
.skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* === Install Banner === */
.install-banner {
  display: none;
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.1), rgba(239, 68, 68, 0.1));
  border: 1px solid rgba(249, 115, 22, 0.2);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
  align-items: center;
  gap: 12px;
  animation: fadeIn 0.5s ease;
}

.install-banner.show {
  display: flex;
}

.install-banner-text {
  flex: 1;
}

.install-banner-title {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.install-banner-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.install-banner .btn {
  flex-shrink: 0;
}

/* === Media Queries === */
@media (min-width: 480px) {
  .app-container {
    padding: 24px 24px;
  }
}

@media (min-width: 768px) {
  .app-container {
    max-width: 520px;
    padding: 32px 32px;
  }
  
  .card {
    padding: 28px;
  }
}
