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

/* CSS Variables */
:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #ffffff;
  --text-primary: #ffffff;
  --text-secondary: #94a3b8;
  --text-dark: #1e293b;
  --text-muted: #64748b;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-light: #818cf8;
  --border: #334155;
  --border-card: #e2e8f0;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.2s ease;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  font-size: 16px;
  min-height: 100vh;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }

p {
  color: var(--text-secondary);
  line-height: 1.7;
}

a {
  color: var(--accent-light);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--accent);
}

/* Container */
.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 24px;
}

.container-wide {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Nav Bar */
nav {
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 24px;
}

.nav-brand {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.nav-brand span {
  color: var(--accent-light);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
  flex-wrap: wrap;
}

.nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background-color var(--transition);
  white-space: nowrap;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text-primary);
  background-color: rgba(99, 102, 241, 0.15);
}

/* Hero Section */
.hero {
  padding: 80px 0 60px;
  text-align: center;
}

.hero h1 {
  font-size: 3rem;
  background: linear-gradient(135deg, #ffffff 0%, var(--accent-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 20px;
}

.hero p {
  font-size: 1.125rem;
  color: var(--text-secondary);
  max-width: 560px;
  margin: 0 auto 40px;
}

/* Page Header (tool pages) */
.page-header {
  padding: 48px 0 32px;
  text-align: center;
}

.page-header h1 {
  font-size: 2.25rem;
  margin-bottom: 12px;
}

.page-header p {
  font-size: 1rem;
  color: var(--text-secondary);
}

/* Tool Cards Grid (homepage) */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  padding-bottom: 80px;
}

.tool-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}

.tool-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.tool-card-icon {
  font-size: 2rem;
  line-height: 1;
}

.tool-card h3 {
  font-size: 1.125rem;
  color: var(--text-primary);
}

.tool-card p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  flex: 1;
}

/* Form Card */
.form-card {
  background-color: var(--bg-card);
  border-radius: var(--radius);
  padding: 40px;
  box-shadow: var(--shadow-lg);
  margin-bottom: 32px;
}

.form-group {
  margin-bottom: 24px;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 8px;
}

label .required {
  color: #ef4444;
  margin-left: 2px;
}

input[type="text"],
input[type="email"],
input[type="url"],
select,
textarea {
  width: 100%;
  padding: 12px 16px;
  font-size: 0.9375rem;
  font-family: inherit;
  color: var(--text-dark);
  background-color: #f8fafc;
  border: 1.5px solid var(--border-card);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  appearance: none;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="url"]:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
  background-color: #ffffff;
}

input::placeholder,
textarea::placeholder {
  color: #b0bec5;
}

textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.6;
}

select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color var(--transition), transform var(--transition), box-shadow var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background-color: var(--accent);
  color: #ffffff;
  width: 100%;
  padding: 16px 32px;
  font-size: 1.0625rem;
}

.btn-primary:hover {
  background-color: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
}

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

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

.btn-outline {
  background-color: transparent;
  color: var(--accent-light);
  border: 1.5px solid var(--accent);
  padding: 10px 20px;
  font-size: 0.9rem;
}

.btn-outline:hover {
  background-color: rgba(99, 102, 241, 0.1);
  color: var(--text-primary);
}

.btn-cta {
  background-color: var(--accent);
  color: #ffffff;
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
}

.btn-cta:hover {
  background-color: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
  color: #ffffff;
}

/* Result Section */
.result-section {
  display: none;
  margin-bottom: 32px;
}

.result-section.visible {
  display: block;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.result-header h2 {
  font-size: 1.25rem;
  color: var(--text-primary);
}

.result-text {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 0.9375rem;
  color: var(--text-primary);
  line-height: 1.75;
  min-height: 200px;
  word-break: break-word;
}

/* Affiliate Section */
.affiliate-section {
  margin-bottom: 60px;
}

.affiliate-section h2 {
  font-size: 1.375rem;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.affiliate-section > p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.affiliate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.affiliate-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color var(--transition), transform var(--transition);
}

.affiliate-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.affiliate-card-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.affiliate-card-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.55;
  flex: 1;
}

/* Loading Spinner */
.spinner {
  display: none;
  width: 22px;
  height: 22px;
  border: 2.5px solid rgba(255, 255, 255, 0.4);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  flex-shrink: 0;
}

.spinner.active {
  display: inline-block;
}

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

/* Error message */
.error-message {
  display: none;
  background-color: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  color: #fca5a5;
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.error-message.visible {
  display: block;
}

/* Footer */
footer {
  border-top: 1px solid var(--border);
  padding: 32px 0;
  text-align: center;
}

footer p {
  font-size: 0.875rem;
  color: var(--text-muted);
}

footer a {
  color: var(--accent-light);
}

/* Copy feedback */
.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-family: inherit;
  font-weight: 600;
  background-color: transparent;
  color: var(--accent-light);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color var(--transition), color var(--transition);
}

.copy-btn:hover {
  background-color: rgba(99, 102, 241, 0.15);
  color: var(--text-primary);
}

.copy-btn.copied {
  background-color: rgba(34, 197, 94, 0.15);
  border-color: #22c55e;
  color: #86efac;
}

/* Section divider */
.section-divider {
  height: 1px;
  background-color: var(--border);
  margin: 40px 0;
}

/* Responsive — 768px breakpoint */
@media (max-width: 768px) {
  h1 { font-size: 1.875rem; }
  h2 { font-size: 1.5rem; }

  .hero h1 { font-size: 2rem; }

  .nav-inner {
    flex-direction: column;
    height: auto;
    padding: 12px 16px;
    gap: 10px;
  }

  .nav-links {
    width: 100%;
    justify-content: center;
    gap: 4px;
  }

  .nav-links a {
    font-size: 0.8rem;
    padding: 5px 8px;
  }

  .container,
  .container-wide {
    padding: 0 16px;
  }

  .tools-grid {
    grid-template-columns: 1fr;
    gap: 16px;
    padding-bottom: 48px;
  }

  .form-card {
    padding: 24px 20px;
  }

  .affiliate-grid {
    grid-template-columns: 1fr;
  }

  .result-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .hero {
    padding: 48px 0 36px;
  }

  .page-header {
    padding: 32px 0 24px;
  }
}
