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

:root {
  --primary: #2563eb;
  --primary-dark: #1e40af;
  --primary-light: #3b82f6;
  --secondary: #f97316;
  --secondary-dark: #ea580c;
  --secondary-light: #fb923c;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --light: #f8fafc;
  --dark: #1e293b;
  --gray: #64748b;
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.15);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Inter', sans-serif;
  background: linear-gradient(135deg, #1e40af 0%, #7c3aed 50%, #f97316 100%);
  min-height: 100vh;
  overflow: hidden;
  color: var(--dark);
}

.app-container {
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 12px;
}

/* Header */
.header {
  background: rgba(255, 255, 255, 0.98);
  padding: 12px 25px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  backdrop-filter: blur(10px);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  width: 40px;
  height: 40px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand h1 {
  font-size: 1.5rem;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1;
}

.tagline {
  font-size: 0.7rem;
  color: var(--gray);
  font-weight: 500;
  letter-spacing: 0.5px;
}

.version-badge {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  box-shadow: var(--shadow);
  letter-spacing: 0.5px;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 8px;
  background: rgba(255, 255, 255, 0.95);
  padding: 8px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--gray);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

.tab-btn:hover {
  background: rgba(37, 99, 235, 0.1);
  color: var(--primary);
}

.tab-btn.active {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  box-shadow: var(--shadow);
}

.tab-btn.coming-soon {
  opacity: 0.6;
  cursor: not-allowed;
}

.tab-btn.contact-tab {
  margin-left: auto;
  background: linear-gradient(135deg, var(--success), #34d399);
  color: white;
}

.tab-btn.contact-tab:hover {
  transform: scale(1.05);
}

/* Main Content */
.main-content {
  flex: 1;
  background: rgba(255, 255, 255, 0.98);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.tab-content {
  display: none;
  padding: 15px;
  height: 100%;
  overflow-y: auto;
}

.tab-content.active {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Grid Layout */
.content-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 15px;
  height: 100%;
  overflow: hidden;
}

.output-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.controls-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}

/* Input Groups */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-height: 0;
}

.input-group.compact {
  flex: 0 0 auto;
  min-height: auto;
}

.input-group label {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--dark);
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.input-row input {
  flex: 1;
}

input[type="text"],
input[type="email"],
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
  transition: all 0.3s ease;
  background: white;
}

input[type="text"]:focus,
input[type="email"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

textarea {
  resize: none;
  flex: 1;
  min-height: 100px;
}

.output-area {
  flex: 1;
  min-height: 0;
}

input[type="text"]:read-only {
  background: var(--light);
  cursor: default;
}

/* Buttons */
.btn {
  padding: 9px 16px;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: var(--shadow);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-success {
  background: linear-gradient(135deg, var(--success), #34d399);
  color: white;
  box-shadow: var(--shadow);
}

.btn-success:hover:not(:disabled) {
  transform: translateY(-2px);
}

.btn-secondary {
  background: #e2e8f0;
  color: var(--dark);
  border: 2px solid #cbd5e1;
}

.btn-secondary:hover:not(:disabled) {
  background: #cbd5e1;
}

.btn-warning {
  background: linear-gradient(135deg, var(--warning), #fbbf24);
  color: white;
}

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 2px solid #e2e8f0;
  background: white;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 1.1rem;
}

.btn-icon:hover {
  border-color: var(--primary);
  color: var(--primary);
  transform: scale(1.1);
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

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

.badge-success {
  background: var(--success);
  color: white;
}

.badge-warning {
  background: var(--warning);
  color: white;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
  z-index: 1000;
  animation: fadeIn 0.3s ease;
}

.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-content {
  background: white;
  border-radius: 12px;
  padding: 25px;
  max-width: 600px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 2px solid #e2e8f0;
}

.modal-header h3 {
  font-size: 1.3rem;
  color: var(--dark);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--gray);
  transition: all 0.3s ease;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}

.modal-close:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 15px;
  border-top: 2px solid #e2e8f0;
}

/* Toast */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  font-weight: 600;
  font-size: 0.9rem;
  z-index: 2000;
  animation: slideInRight 0.3s ease;
  max-width: 400px;
  display: none;
}

.toast.show {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.success {
  background: #d1fae5;
  color: #065f46;
  border-left: 4px solid var(--success);
}

.toast.error {
  background: #fee2e2;
  color: #991b1b;
  border-left: 4px solid var(--danger);
}

/* Info Box */
.info-box {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(249, 115, 22, 0.08));
  border-left: 4px solid var(--primary);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  line-height: 1.5;
}

.info-box h4 {
  margin-bottom: 6px;
  font-size: 0.85rem;
  color: var(--primary);
}

.scan-progress {
  background: linear-gradient(135deg, #dbeafe, #bfdbfe);
  border-left: 4px solid #2563eb;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  color: #1e3a8a;
  display: none;
  font-weight: 600;
}

.scan-progress.show {
  display: block;
}

/* Replace Form */
.replace-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px;
  background: var(--light);
  border-radius: 8px;
}

/* Contact Section */
.contact-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.contact-card {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.05), rgba(249, 115, 22, 0.05));
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  transition: all 0.3s ease;
}

.contact-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}

.contact-icon {
  font-size: 2.5rem;
  margin-bottom: 10px;
}

.contact-card h3 {
  font-size: 1.1rem;
  margin-bottom: 8px;
  color: var(--dark);
}

.contact-card p {
  font-size: 0.85rem;
  color: var(--gray);
  margin-bottom: 15px;
}

.donation-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 15px;
}

/* Coming Soon */
.coming-soon-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 40px;
}

.coming-soon-icon {
  font-size: 5rem;
  margin-bottom: 20px;
  animation: bounce 2s infinite;
}

.coming-soon-container h2 {
  font-size: 2rem;
  color: var(--dark);
  margin-bottom: 10px;
}

.coming-soon-container p {
  font-size: 1.1rem;
  color: var(--gray);
}

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

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

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

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

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary-dark);
}

/* Copy Button Success Animation */
.btn-copied {
  background: linear-gradient(135deg, var(--success), #34d399) !important;
  transform: scale(1.05);
  animation: pulseGreen 0.5s ease;
}

@keyframes pulseGreen {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* Token Counter Badges */
.token-counter {
  display: flex;
  gap: 10px;
  margin-top: 5px;
  flex-wrap: wrap;
}

.token-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 15px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  box-shadow: var(--shadow);
}

.token-badge.input-tokens {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: white;
}

.token-badge.output-tokens {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
}

.token-badge.reduction {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
}

/* API Tester Specific Styles */
.api-tester-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  height: 100%;
  overflow: hidden;
}

.api-request-section,
.api-response-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
}

.api-request-section #apiHeaders {
  height: 85px;
  min-height: 85px;
  max-height: 85px;
}

.api-request-section #apiBody {
  height: 105px;
  min-height: 105px;
  max-height: 105px;
}

.method-url-row {
  display: flex;
  gap: 8px;
}

.method-select {
  min-width: 120px;
  padding: 10px 12px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  background: white;
  cursor: pointer;
  transition: all 0.3s ease;
}

.method-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.status-badge.success {
  background: #d1fae5;
  color: #065f46;
  border: 2px solid #10b981;
}

.status-badge.error {
  background: #fee2e2;
  color: #991b1b;
  border: 2px solid #ef4444;
}

.status-badge.warning {
  background: #fef3c7;
  color: #92400e;
  border: 2px solid #f59e0b;
}

/* Web Scraper Styles */
.scraper-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 15px;
  height: 100%;
  overflow-y: auto;
}

.mode-selector {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.mode-btn {
  flex: 1;
  padding: 10px;
  border: 2px solid #e2e8f0;
  background: white;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 600;
  font-size: 0.85rem;
}

.mode-btn.active {
  border-color: var(--primary);
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.1), rgba(249, 115, 22, 0.1));
  color: var(--primary);
}

.selector-output {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
  margin-top: 15px;
}

.selector-card {
  background: var(--light);
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  padding: 15px;
}

.selector-card h4 {
  font-size: 0.9rem;
  color: var(--primary);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.selector-code {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 10px;
  font-family: 'Courier New', monospace;
  font-size: 0.8rem;
  word-break: break-all;
  max-height: 120px;
  overflow-y: auto;
  margin-bottom: 10px;
}

.match-preview {
  background: #e7f3ff;
  border-left: 3px solid var(--primary);
  padding: 8px 10px;
  border-radius: 4px;
  font-size: 0.75rem;
  margin-top: 10px;
}

/* Responsive */
@media (max-width: 1200px) {
  .content-grid {
    grid-template-columns: 1.5fr 1fr;
  }

  .api-tester-grid {
    grid-template-columns: 1fr;
  }

  .selector-output {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1024px) {
  .content-grid {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }

  .contact-section {
    grid-template-columns: 1fr;
  }

  .output-section,
  .controls-section {
    min-height: 300px;
  }
}

@media (max-width: 768px) {
  .app-container {
    padding: 8px;
    gap: 8px;
  }

  .header {
    padding: 10px 15px;
  }

  .brand h1 {
    font-size: 1.2rem;
  }

  .tagline {
    font-size: 0.65rem;
  }

  .version-badge {
    font-size: 0.65rem;
    padding: 3px 8px;
  }

  .tab-btn {
    font-size: 0.8rem;
    padding: 6px 12px;
  }

  .btn-group {
    flex-direction: column;
  }

  .btn {
    width: 100%;
    justify-content: center;
  }

  .modal-content {
    padding: 20px;
  }

  .replace-form {
    grid-template-columns: 1fr;
  }

  .method-url-row {
    flex-direction: column;
  }

  .method-select {
    width: 100%;
  }
}
