/* ========================================
   GitHub Profile README Generator - Styles
   Dark theme, modern glassmorphism UI
   ======================================== */

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

:root {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-card: #1c2128;
  --bg-input: #0d1117;
  --border: #30363d;
  --border-hover: #58a6ff;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --accent: #58a6ff;
  --accent-hover: #79c0ff;
  --accent-glow: rgba(88, 166, 255, 0.15);
  --green: #3fb950;
  --orange: #d29922;
  --red: #f85149;
  --purple: #bc8cff;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --transition: 0.2s ease;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

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

a:hover {
  text-decoration: underline;
}

/* ---------- Header ---------- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(13, 17, 23, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

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

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text-primary);
}

.header-link {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: var(--transition);
}

.header-link:hover {
  color: var(--text-primary);
  border-color: var(--text-secondary);
  text-decoration: none;
}

.header-star-btn svg {
  color: var(--orange);
}

.header-star-btn:hover {
  border-color: var(--orange);
  color: var(--orange);
}

/* ---------- Hero ---------- */
.hero {
  text-align: center;
  padding: 80px 24px 48px;
  max-width: 720px;
  margin: 0 auto;
}

.hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text-primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 12px;
}

.subtitle {
  font-size: 1.15rem;
  color: var(--text-secondary);
  margin-bottom: 40px;
}

/* ---------- Search Box ---------- */
.search-box {
  max-width: 560px;
  margin: 0 auto;
}

.input-wrapper {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 4px 4px 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

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

.input-wrapper.input-error {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(248, 81, 73, 0.15);
}

.input-wrapper.input-error:focus-within {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(248, 81, 73, 0.15);
}

.input-icon {
  color: var(--text-muted);
  flex-shrink: 0;
}

#username-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 1rem;
  padding: 12px 10px;
}

#username-input::placeholder {
  color: var(--text-muted);
}

#generate-btn {
  flex-shrink: 0;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 22px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
}

#generate-btn:hover {
  background: var(--accent-hover);
}

#generate-btn:active {
  transform: scale(0.97);
}

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

.spinner {
  animation: spin 1s linear infinite;
}

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

.error-msg {
  margin-top: 14px;
  color: var(--red);
  font-size: 0.9rem;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(248, 81, 73, 0.1);
  border: 1px solid rgba(248, 81, 73, 0.3);
  border-radius: 8px;
  padding: 12px 16px;
  animation: shakeIn 0.4s ease;
}

.error-msg:not([hidden]) {
  display: flex;
}

@keyframes shakeIn {
  0%   { transform: translateX(-8px); opacity: 0; }
  25%  { transform: translateX(6px); }
  50%  { transform: translateX(-4px); }
  75%  { transform: translateX(2px); }
  100% { transform: translateX(0); opacity: 1; }
}

/* ---------- Results Section ---------- */
.results {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 24px 60px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  animation: fadeIn 0.4s ease;
}

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

/* ---------- Profile Card ---------- */
.profile-card {
  display: flex;
  align-items: center;
  gap: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow);
}

.avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 3px solid var(--border);
  flex-shrink: 0;
}

.profile-info {
  flex: 1;
  min-width: 0;
}

.profile-info h2 {
  font-size: 1.4rem;
  margin-bottom: 4px;
}

.profile-bio {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 16px;
}

.profile-stats {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---------- Section Cards ---------- */
.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
}

.section-card h3 {
  font-size: 1.1rem;
  margin-bottom: 16px;
  color: var(--text-primary);
}

/* ---------- Languages Chart ---------- */
.languages-chart {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lang-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lang-name {
  width: 110px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-align: right;
  flex-shrink: 0;
}

.lang-bar-bg {
  flex: 1;
  height: 10px;
  background: var(--bg-primary);
  border-radius: 5px;
  overflow: hidden;
}

.lang-bar {
  height: 100%;
  border-radius: 5px;
  transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.lang-pct {
  width: 48px;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: right;
}

/* ---------- Top Repos ---------- */
.top-repos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.repo-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: border-color var(--transition), transform var(--transition);
}

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

.repo-name {
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 6px;
  font-size: 0.95rem;
}

.repo-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.repo-meta {
  display: flex;
  gap: 14px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.repo-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ---------- README Section ---------- */
.readme-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.readme-header h3 {
  margin-bottom: 0;
}

.readme-actions {
  display: flex;
  gap: 8px;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-primary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

.action-btn:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.action-btn-primary {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.action-btn-primary:hover {
  background: #2ea043;
  border-color: #2ea043;
  color: #fff;
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.tab {
  padding: 10px 18px;
  font-size: 0.9rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

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

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

.tab-content {
  display: none;
}

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

/* ---------- README Preview ---------- */
.readme-preview {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  overflow-x: auto;
  line-height: 1.7;
}

.readme-preview h1,
.readme-preview h2,
.readme-preview h3 {
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  margin-top: 24px;
  margin-bottom: 12px;
}

.readme-preview h1:first-child {
  margin-top: 0;
}

.readme-preview p {
  margin-bottom: 12px;
}

.readme-preview img {
  max-width: 100%;
  border-radius: 6px;
}

.readme-preview code {
  background: var(--bg-secondary);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

.readme-preview pre {
  background: var(--bg-secondary);
  padding: 14px;
  border-radius: var(--radius);
  overflow-x: auto;
  margin-bottom: 12px;
}

.readme-preview ul,
.readme-preview ol {
  padding-left: 24px;
  margin-bottom: 12px;
}

.readme-preview a {
  color: var(--accent);
}

.readme-preview table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
}

.readme-preview th,
.readme-preview td {
  padding: 8px 12px;
  border: 1px solid var(--border);
  text-align: left;
}

.readme-preview th {
  background: var(--bg-secondary);
}

.readme-preview blockquote {
  border-left: 3px solid var(--accent);
  margin: 12px 0;
  padding: 4px 16px;
  color: var(--text-secondary);
}

/* ---------- Customize Section ---------- */
.customize-section h3 {
  margin-bottom: 20px;
}

.style-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}

.drag-hint {
  font-weight: 400;
  text-transform: none;
  color: var(--text-muted);
  font-size: 0.78rem;
  letter-spacing: 0;
}

/* ---- Style Selector ---- */
.style-selector {
  margin-bottom: 24px;
}

.style-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.style-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 10px;
  background: var(--bg-primary);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
  color: var(--text-primary);
}

.style-btn:hover {
  border-color: var(--text-muted);
  transform: translateY(-2px);
}

.style-btn.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.style-preview {
  width: 48px;
  height: 32px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.style-preview-classic {
  background: linear-gradient(135deg, #58a6ff 0%, #3fb950 50%, #d29922 100%);
}

.style-preview-minimal {
  background: linear-gradient(135deg, #e6edf3 0%, #8b949e 100%);
}

.style-preview-hacker {
  background: linear-gradient(135deg, #0d1117 0%, #3fb950 100%);
}

.style-preview-elegant {
  background: linear-gradient(135deg, #bc8cff 0%, #58a6ff 50%, #f778ba 100%);
}

.style-preview-portfolio {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.style-preview-futuristic {
  background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
}

.style-preview-resume {
  background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
}

.style-preview-gradient {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 50%, #ffd200 100%);
}

.style-preview-opensource {
  background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}

.style-preview-compact {
  background: linear-gradient(135deg, #434343 0%, #000000 100%);
}

.style-preview-animated {
  background: linear-gradient(135deg, #fc466b 0%, #3f5efb 100%);
}

.style-preview-startup {
  background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 50%, #fdfcfb 100%);
}

.style-preview-devops {
  background: linear-gradient(135deg, #0052d4 0%, #4364f7 50%, #6fb1fc 100%);
}

.style-preview-mobile {
  background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.style-preview-aiml {
  background: linear-gradient(135deg, #a18cd1 0%, #fbc2eb 100%);
}

.style-preview-pastel {
  background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 50%, #ff9a9e 100%);
}

.style-preview-monochrome {
  background: linear-gradient(135deg, #bdc3c7 0%, #2c3e50 100%);
}

.style-preview-timeline {
  background: linear-gradient(135deg, #e44d26 0%, #f7df1e 50%, #3178c6 100%);
}

.style-preview-badges {
  background: linear-gradient(135deg, #ff6b6b 0%, #feca57 33%, #48dbfb 66%, #ff9ff3 100%);
}

.style-preview-premium {
  background: linear-gradient(135deg, #bf953f 0%, #fcf6ba 25%, #b38728 50%, #fbf5b7 75%, #aa771c 100%);
}

.style-name {
  font-size: 0.85rem;
  font-weight: 600;
}

.style-desc {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: center;
}

/* ---- Section Reorder (Drag & Drop) ---- */
.section-reorder {
  margin-top: 4px;
}

.section-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.section-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.88rem;
  color: var(--text-primary);
  cursor: grab;
  user-select: none;
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
}

.section-item:hover {
  border-color: var(--text-muted);
}

.section-item:active {
  cursor: grabbing;
}

.section-item.dragging {
  opacity: 0.4;
  border-color: var(--accent);
  transform: scale(0.97);
}

.section-item.drag-over {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.drag-handle {
  color: var(--text-muted);
  font-size: 1rem;
  flex-shrink: 0;
}

/* ---------- Raw Markdown ---------- */
.readme-raw {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  font-size: 0.88rem;
  color: var(--text-secondary);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 600px;
  overflow-y: auto;
}

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  padding: 32px 24px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.8;
}

.visitor-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.generation-counter {
  display: inline-block;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 10px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .hero h1 {
    font-size: 1.7rem;
  }

  .subtitle {
    font-size: 1rem;
  }

  .input-wrapper {
    flex-direction: column;
    padding: 8px;
    gap: 8px;
  }

  .input-icon {
    display: none;
  }

  #username-input {
    width: 100%;
    text-align: center;
  }

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

  .profile-card {
    flex-direction: column;
    text-align: center;
  }

  .profile-stats {
    justify-content: center;
  }

  .readme-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .style-options {
    grid-template-columns: repeat(2, 1fr);
  }
}

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

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ---------- Toast notification ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--green);
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  z-index: 1000;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  pointer-events: none;
}

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

/* ---------- Stat Image Placeholder ---------- */
.stat-img-placeholder {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 200px;
  min-height: 120px;
  padding: 1.25rem 1.5rem;
  margin: 0.5rem;
  background: var(--bg-secondary);
  border: 1px dashed var(--border);
  border-radius: 10px;
  text-align: center;
  vertical-align: middle;
}

.stat-img-icon {
  font-size: 1.6rem;
}

.stat-img-label {
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 600;
}

.stat-img-note {
  color: var(--text-muted);
  font-size: 0.75rem;
}
