/* ===== CSS Variables ===== */
:root {
  --primary: #6C63FF;
  --primary-dark: #5a52d5;
  --secondary: #FF6584;
  --bg: #ffffff;
  --bg-secondary: #f8f9fa;
  --surface: #ffffff;
  --surface-hover: #f0eeff;
  --border: #e2e8f0;
  --text: #1a202c;
  --text-muted: #718096;
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: all 0.25s ease;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

[data-theme="dark"] {
  --bg: #0f1117;
  --bg-secondary: #1a1d27;
  --surface: #1e2130;
  --surface-hover: #2a2d3e;
  --border: #2d3048;
  --text: #e2e8f0;
  --text-muted: #a0aec0;
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.4), 0 2px 4px -1px rgba(0,0,0,0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.5), 0 4px 6px -2px rgba(0,0,0,0.3);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background 0.3s ease, color 0.3s ease;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; }

/* ===== Navbar ===== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 0 1.5rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--primary);
  text-decoration: none;
}

.nav-brand .logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: white;
}

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

.btn-back {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.9rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.875rem;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn-back:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  text-decoration: none;
}

.theme-toggle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: var(--transition);
  color: var(--text);
}

.theme-toggle:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ===== Hero Section ===== */
.hero {
  background: linear-gradient(135deg, #6C63FF 0%, #9B59B6 50%, #FF6584 100%);
  color: white;
  padding: 5rem 1.5rem 3.5rem;
  text-align: center;
  position: relative;
  overflow: clip;
}

.hero::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, transparent 60%);
  animation: pulse 6s ease-in-out infinite;
}

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

.hero h1 {
  font-size: clamp(1.8rem, 4vw, 3rem);
  font-weight: 800;
  margin-bottom: 1rem;
  position: relative;
}

.hero p {
  font-size: clamp(1rem, 2vw, 1.2rem);
  opacity: 0.9;
  max-width: 600px;
  margin: 0 auto 1.5rem;
  position: relative;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  flex-wrap: wrap;
  position: relative;
}

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

.stat-item strong {
  display: block;
  font-size: 1.5rem;
  font-weight: 800;
}

.stat-item span {
  font-size: 0.85rem;
  opacity: 0.85;
}

/* ===== Search ===== */
.search-section {
  padding: 2rem 1.5rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.search-wrapper {
  max-width: 600px;
  margin: 0 auto;
  position: relative;
}

.search-input {
  width: 100%;
  padding: 0.85rem 1rem 0.85rem 3rem;
  border: 2px solid var(--border);
  border-radius: 50px;
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  font-family: var(--font);
  transition: var(--transition);
  outline: none;
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108,99,255,0.15);
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.1rem;
  color: var(--text-muted);
  pointer-events: none;
}

/* ===== Category Filter ===== */
.category-section {
  padding: 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.category-pills {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.category-pill {
  padding: 0.4rem 1rem;
  border-radius: 50px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font);
}

.category-pill:hover,
.category-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* ===== Tool Grid ===== */
.tools-section {
  padding: 1rem 1.5rem 3rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  flex: 1;
}

.section-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: var(--text);
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
}

.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-decoration: none;
  color: var(--text);
  transition: var(--transition);
  display: block;
  position: relative;
  overflow: hidden;
}

.tool-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transform: scaleX(0);
  transition: var(--transition);
}

.tool-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
  text-decoration: none;
  color: var(--text);
}

.tool-card:hover::before {
  transform: scaleX(1);
}

.tool-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  margin-bottom: 1rem;
}

.tool-icon.purple { background: rgba(108,99,255,0.12); }
.tool-icon.pink { background: rgba(255,101,132,0.12); }
.tool-icon.green { background: rgba(72,199,142,0.12); }
.tool-icon.blue { background: rgba(79,193,232,0.12); }
.tool-icon.orange { background: rgba(255,169,64,0.12); }
.tool-icon.teal { background: rgba(32,201,151,0.12); }

.tool-card h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.tool-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.tool-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 50px;
  font-size: 0.7rem;
  font-weight: 600;
  margin-top: 0.75rem;
  background: rgba(108,99,255,0.1);
  color: var(--primary);
}

/* ===== Tool Page Layout ===== */
.tool-page-hero {
  background: linear-gradient(135deg, #6C63FF 0%, #9B59B6 100%);
  color: white;
  padding: 2.5rem 1.5rem;
  text-align: center;
}

.tool-page-hero h1 {
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.tool-page-hero p {
  opacity: 0.9;
  font-size: 1rem;
  max-width: 500px;
  margin: 0 auto;
}

.tool-container {
  max-width: 900px;
  margin: 2rem auto;
  padding: 0 1.5rem 3rem;
}

/* ===== Drop Zone ===== */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: var(--bg-secondary);
  position: relative;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--primary);
  background: rgba(108,99,255,0.05);
}

.drop-zone.drag-over {
  transform: scale(1.01);
}

.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.drop-icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
  display: block;
}

.drop-zone h3 {
  font-size: 1.1rem;
  margin-bottom: 0.4rem;
  color: var(--text);
}

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

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: 0 4px 14px rgba(108,99,255,0.35);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(108,99,255,0.45);
  color: white;
  text-decoration: none;
}

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

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

.btn-success {
  background: linear-gradient(135deg, #48c78e, #06d6a0);
  color: white;
  box-shadow: 0 4px 14px rgba(72,199,142,0.35);
}

.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(72,199,142,0.45);
  color: white;
  text-decoration: none;
}

.btn-danger {
  background: linear-gradient(135deg, #ff6b6b, #ee5a24);
  color: white;
}

.btn-danger:hover {
  transform: translateY(-2px);
  color: white;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-group {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

/* ===== Card/Panel ===== */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-top: 1.5rem;
}

.panel-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

/* ===== Form Controls ===== */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--text);
}

.form-control {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  font-family: var(--font);
  transition: var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108,99,255,0.15);
}

textarea.form-control {
  resize: vertical;
  min-height: 150px;
}

.form-control-range {
  width: 100%;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ===== Checkbox / Toggle ===== */
.checkbox-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.checkbox-group input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

.checkbox-group label {
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--text);
}

/* ===== Progress ===== */
.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 50px;
  overflow: hidden;
  margin: 1rem 0;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 50px;
  transition: width 0.4s ease;
  width: 0%;
}

/* ===== File List ===== */
.file-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
}

.file-item .file-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-item .file-size {
  color: var(--text-muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.file-item .remove-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.1rem;
  line-height: 1;
  transition: var(--transition);
}

.file-item .remove-btn:hover {
  color: #ff6b6b;
}

/* ===== Alert ===== */
.alert {
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-top: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.alert-success {
  background: rgba(72,199,142,0.12);
  border: 1px solid rgba(72,199,142,0.4);
  color: #1a7a4a;
}

[data-theme="dark"] .alert-success {
  color: #48c78e;
}

.alert-error {
  background: rgba(255,107,107,0.12);
  border: 1px solid rgba(255,107,107,0.4);
  color: #c0392b;
}

[data-theme="dark"] .alert-error {
  color: #ff6b6b;
}

.alert-info {
  background: rgba(108,99,255,0.1);
  border: 1px solid rgba(108,99,255,0.3);
  color: var(--primary);
}

/* ===== Stats Grid ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 1rem;
}

.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  text-align: center;
}

.stat-card .stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
}

.stat-card .stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* ===== Code / Pre ===== */
pre, code {
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
}

.code-block {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text);
  max-height: 400px;
  overflow-y: auto;
}

/* ===== Color Swatch ===== */
.color-swatch {
  width: 100%;
  height: 200px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 600;
  transition: var(--transition);
}

/* ===== Tab System ===== */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.5rem;
}

.tab-btn {
  padding: 0.65rem 1.25rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: var(--transition);
  font-family: var(--font);
}

.tab-btn:hover { color: var(--primary); }

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== Copy button ===== */
.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.75rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text);
  font-family: var(--font);
}

.copy-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.copy-btn.copied {
  background: #48c78e;
  color: white;
  border-color: #48c78e;
}

/* ===== Password ===== */
.password-display {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: var(--bg-secondary);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Consolas', monospace;
  font-size: 1.1rem;
  word-break: break-all;
  min-height: 60px;
}

.password-text { flex: 1; color: var(--primary); font-weight: 600; }

.strength-bar {
  height: 6px;
  border-radius: 50px;
  background: var(--border);
  overflow: hidden;
  margin-top: 0.5rem;
}

.strength-fill {
  height: 100%;
  border-radius: 50px;
  transition: width 0.4s ease, background 0.4s ease;
}

/* ===== QR Code ===== */
.qr-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  background: white;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  min-height: 260px;
}

#qrcode canvas, #qrcode img { display: block; }

/* ===== Image Preview ===== */
.image-preview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}

.image-preview-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.image-preview-item img {
  width: 100%;
  height: 200px;
  object-fit: contain;
  background: var(--bg-secondary);
  display: block;
}

.image-preview-info {
  padding: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--surface);
}

/* ===== Footer ===== */
footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

footer a {
  color: var(--primary);
}

/* ===== Utility ===== */
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-success { color: #48c78e; }
.text-danger { color: #ff6b6b; }
.w-100 { width: 100%; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .hero { padding: 2.5rem 1rem 2rem; }
  .tools-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .image-preview-grid { grid-template-columns: 1fr; }
  .btn-group { flex-direction: column; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .navbar { padding: 0 1rem; }
  .tools-section, .tool-container { padding-left: 1rem; padding-right: 1rem; }
  .hero-stats { gap: 1rem; }
}
