/* -------------------------------------------------------------
   ScamShield SMS Reporter - Mobile-First Stylesheet
   Modern Web Standards & Responsive Design
   ------------------------------------------------------------- */

:root {
  /* Color Palette - Dark Theme Default */
  --bg-primary: #0b0f19;
  --bg-surface: #111827;
  --bg-surface-elevated: #1f2937;
  --bg-input: #0f172a;
  
  --border-subtle: #1f2937;
  --border-strong: #374151;
  --border-focus: #3b82f6;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-active: #1e40af;
  --primary-text: #ffffff;

  --accent-red: #ef4444;
  --accent-red-surface: rgba(239, 68, 68, 0.12);
  --accent-red-border: rgba(239, 68, 68, 0.3);

  --accent-green: #10b981;
  --accent-green-surface: rgba(16, 185, 129, 0.12);
  --accent-green-border: rgba(16, 185, 129, 0.3);

  --accent-amber: #f59e0b;
  --accent-amber-surface: rgba(245, 158, 11, 0.12);
  --accent-amber-border: rgba(245, 158, 11, 0.3);

  /* Typography */
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  /* Spacing & Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 9999px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.5);

  --transition-quick: 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg-primary: #f8fafc;
    --bg-surface: #ffffff;
    --bg-surface-elevated: #f1f5f9;
    --bg-input: #f8fafc;

    --border-subtle: #e2e8f0;
    --border-strong: #cbd5e1;
    --border-focus: #2563eb;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-active: #1e40af;
    --primary-text: #ffffff;

    --accent-red-surface: rgba(239, 68, 68, 0.08);
    --accent-green-surface: rgba(16, 185, 129, 0.08);
    --accent-amber-surface: rgba(245, 158, 11, 0.08);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
  }
}

/* Base Reset & Mobile-first Container */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  min-height: -webkit-fill-available;
  display: flex;
  justify-content: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.app-container {
  width: 100%;
  max-width: 540px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-lg);
  position: relative;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(8px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(239, 68, 68, 0.35);
}

.logo-icon svg {
  width: 22px;
  height: 22px;
}

.brand-text h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.brand-text .subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  padding: 0.25rem 0.625rem;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--accent-green);
  box-shadow: 0 0 6px var(--accent-green);
}

.status-pill.offline .status-dot {
  background-color: var(--accent-red);
  box-shadow: 0 0 6px var(--accent-red);
}

/* Main Content */
.main-content {
  flex: 1;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Cards */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-quick);
}

.intro-card {
  background: var(--bg-surface-elevated);
  border-color: var(--border-subtle);
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Input Section */
.field-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.field-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

.field-label-sm {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
  display: block;
}

.field-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-text {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: background-color var(--transition-quick), color var(--transition-quick);
}

.btn-text:hover {
  background-color: var(--bg-surface-elevated);
}

.btn-clear {
  color: var(--accent-red);
}

.btn-icon {
  width: 14px;
  height: 14px;
}

.textarea-wrapper {
  position: relative;
}

textarea#sms-input {
  width: 100%;
  padding: 0.875rem;
  font-size: 0.95rem;
  line-height: 1.5;
  font-family: inherit;
  color: var(--text-primary);
  background-color: var(--bg-input);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  resize: vertical;
  min-height: 120px;
  outline: none;
  transition: border-color var(--transition-quick), box-shadow var(--transition-quick);
}

textarea#sms-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

textarea#sms-input::placeholder {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.input-counter {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: right;
  margin-top: 0.375rem;
}

/* Extracted Preview Card */
.preview-card {
  background: var(--bg-surface-elevated);
  border-left: 4px solid var(--border-strong);
  transition: border-color var(--transition-quick), background-color var(--transition-quick);
}

.preview-card.has-link {
  border-left-color: var(--accent-red);
  background: var(--accent-red-surface);
}

.preview-card.is-reputable {
  border-left-color: var(--accent-green);
  background: var(--accent-green-surface);
}

.preview-card.is-reputable .preview-icon {
  color: var(--accent-green) !important;
}

.preview-card.is-reputable .url-value {
  color: var(--accent-green) !important;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.preview-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.preview-icon {
  width: 18px;
  height: 18px;
  color: var(--text-secondary);
}

.preview-card.has-link .preview-icon {
  color: var(--accent-red);
}

.preview-title h2 {
  font-size: 0.95rem;
  font-weight: 700;
}

.badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-pill);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.badge.badge-active {
  background: var(--accent-red);
  color: white;
  border-color: transparent;
}

.empty-preview {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 0.5rem 0;
}

.url-display-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}

.url-label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.url-value {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent-red);
  word-break: break-all;
  user-select: all;
  font-weight: 600;
}

.url-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.meta-item {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
}

.meta-label {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.meta-value {
  display: block;
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.safe-note {
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.375rem;
  line-height: 1.3;
}

.safe-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--text-muted);
}

.multiple-urls-container {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border-subtle);
}

.url-dropdown {
  width: 100%;
  padding: 0.5rem;
  font-size: 0.85rem;
  font-family: var(--font-mono);
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  outline: none;
}

/* Action Section */
.action-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: auto;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  padding: 0.875rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all var(--transition-quick);
  min-height: 52px;
  user-select: none;
}

.btn-primary {
  background-color: var(--accent-red);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.4);
}

.btn-primary:hover:not(:disabled) {
  background-color: #dc2626;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(239, 68, 68, 0.45);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

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

.btn-secondary:hover {
  background: var(--primary-hover);
}

.btn-sm {
  min-height: 36px;
  padding: 0.4rem 0.875rem;
  font-size: 0.85rem;
}

.btn-action-icon {
  width: 20px;
  height: 20px;
}

.btn-spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255, 255, 255, 0.3);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.action-caption {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

/* Notification Banner */
.notification-banner {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-elevated);
  box-shadow: var(--shadow-md);
  position: relative;
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.notification-banner.success {
  background: var(--accent-green-surface);
  border-color: var(--accent-green-border);
  color: var(--text-primary);
}

.notification-banner.error {
  background: var(--accent-red-surface);
  border-color: var(--accent-red-border);
  color: var(--text-primary);
}

.notification-banner.warning {
  background: var(--accent-amber-surface);
  border-color: var(--accent-amber-border);
  color: var(--text-primary);
}

.notification-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.notification-banner.success .notification-icon {
  color: var(--accent-green);
}

.notification-banner.error .notification-icon {
  color: var(--accent-red);
}

.notification-banner.warning .notification-icon {
  color: var(--accent-amber);
}

.notification-body {
  flex: 1;
}

.notification-title {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.notification-message {
  font-size: 0.825rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.notification-details {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  background: var(--bg-surface);
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  word-break: break-word;
}

.btn-close-notification {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem;
}

/* Install Card */
.install-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.5rem;
}

.install-title {
  font-size: 0.9rem;
  font-weight: 700;
}

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

.install-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* Footer */
.app-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-subtle);
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Mode Bar & Settings */
.mode-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  padding: 0.35rem 0.75rem;
  margin-top: 0.5rem;
}

.mode-toggle-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}

.mode-toggle-input {
  display: none;
}

.mode-toggle-slider {
  position: relative;
  width: 32px;
  height: 18px;
  background-color: var(--border-strong);
  border-radius: var(--radius-pill);
  transition: background-color var(--transition-quick);
}

.mode-toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background-color: white;
  border-radius: 50%;
  transition: transform var(--transition-quick);
}

.mode-toggle-input:checked + .mode-toggle-slider {
  background-color: var(--primary);
}

.mode-toggle-input:checked + .mode-toggle-slider::after {
  transform: translateX(14px);
}

.mode-label-text {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.endpoint-indicator {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-pill);
  color: var(--text-muted);
}

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