/* Prompta.co — Tailwind-style CSS (standalone, no build needed for M1) */

/* ===== CSS Variables (theme) ===== */
:root {
  --bg: #ffffff;
  --fg: #171717;
  --muted: #737373;
  --border: #e5e5e5;
  --card: #f5f5f5;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --surface: #fafafa;
  --success: #22c55e;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
}

[data-theme="dark"] {
  --bg: #0a0a0a;
  --fg: #e5e5e5;
  --muted: #a3a3a3;
  --border: #262626;
  --card: #171717;
  --accent: #818cf8;
  --accent-hover: #6366f1;
  --surface: #1a1a1a;
  --success: #4ade80;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.5);
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
img { max-width: 100%; height: auto; }

/* ===== Layout ===== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* ===== Header ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 56px;
}
.logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--fg);
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.logo:hover { color: var(--accent); }
.search-form {
  flex: 1;
  max-width: 400px;
  display: flex;
  position: relative;
}
.search-input {
  width: 100%;
  padding: 0.375rem 2.5rem 0.375rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--fg);
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.15s;
}
.search-input:focus { border-color: var(--accent); }
.search-btn {
  position: absolute;
  right: 0.25rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 0.25rem;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  cursor: pointer;
  background: var(--bg);
  color: var(--fg);
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); color: white; }
.btn-secondary {
  background: transparent;
  color: var(--fg);
  border-color: var(--border);
}
.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--fg);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-icon:hover { background: var(--card); color: var(--fg); }
.btn-label { display: none; }
@media (min-width: 640px) { .btn-label { display: inline; } }

/* ===== Icon ===== */
.icon {
  display: inline-block;
  vertical-align: middle;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-sun, .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: inline-block; }
[data-theme="dark"] .icon-sun { display: inline-block; }
[data-theme="dark"] .icon-moon { display: none; }

/* ===== Dropdown ===== */
.dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 160px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 0.25rem;
  z-index: 100;
  max-height: 300px;
  overflow-y: auto;
}
.dropdown-item {
  display: block;
  padding: 0.375rem 0.75rem;
  border-radius: 4px;
  font-size: 0.875rem;
  color: var(--fg);
  text-decoration: none;
}
.dropdown-item:hover { background: var(--surface); }
.dropdown-item.active { background: var(--accent); color: white; }
[x-cloak] { display: none !important; }

/* ===== Lang Switch ===== */
.lang-switch { position: relative; }

/* ===== Sections ===== */
.section { padding: 1.5rem 0; }
.section-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--fg);
}

/* ===== Category Grid ===== */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}
.category-card {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s;
}
.category-card:hover { border-color: var(--accent); background: var(--surface); }

/* ===== Prompts Grid ===== */
.prompts-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* ===== Prompt Card ===== */
.prompt-card {
  padding: 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s;
}
.prompt-card:hover { border-color: var(--accent); }
.prompt-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.375rem;
}
.prompt-title { font-size: 0.9375rem; font-weight: 600; }
.prompt-title a { color: var(--fg); }
.prompt-title a:hover { color: var(--accent); }
.prompt-desc {
  font-size: 0.8125rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.prompt-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-bottom: 0.5rem;
}
.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 9999px;
  font-size: 0.75rem;
  color: var(--muted);
  background: var(--surface);
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip-tag { font-size: 0.6875rem; }
.chip-model { font-family: monospace; font-size: 0.6875rem; }
.difficulty { font-size: 0.75rem; color: #eab308; white-space: nowrap; }
.prompt-actions {
  display: flex;
  gap: 0.5rem;
}
.prompt-actions .btn-icon {
  width: auto;
  padding: 0.25rem 0.5rem;
  gap: 0.25rem;
  font-size: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
}
.prompt-actions .btn-icon:hover { border-color: var(--accent); color: var(--accent); }
.prompt-actions .count { font-size: 0.6875rem; color: var(--muted); }

/* ===== List Page ===== */
.list-page {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 1.5rem;
  padding: 1.5rem 0;
}
@media (max-width: 768px) {
  .list-page { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}
.sidebar-title {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 0.125rem; }
.sidebar-link {
  padding: 0.375rem 0.5rem;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  color: var(--fg);
}
.sidebar-link:hover { background: var(--card); }
.sidebar-link.active { background: var(--accent); color: white; }
.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.page-title { font-size: 1.25rem; font-weight: 700; }
.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  height: 1.5rem;
  padding: 0 0.375rem;
  border-radius: 9999px;
  background: var(--card);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
}
.sort-options { display: flex; gap: 0.5rem; }
.sort-link {
  font-size: 0.8125rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius);
  color: var(--muted);
}
.sort-link.active { background: var(--accent); color: white; }

/* ===== Detail Page ===== */
.prompt-detail { max-width: 800px; padding: 1.5rem 0; }
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8125rem;
  color: var(--muted);
  margin-bottom: 1rem;
}
.breadcrumb-sep { color: var(--border); }
.detail-header { margin-bottom: 1.5rem; }
.detail-header h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.5rem; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 0.375rem; }
.prompt-body {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}
.prompt-text {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.875rem;
  line-height: 1.7;
}
.detail-actions {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.detail-actions .btn { padding: 0.625rem 1.25rem; font-size: 0.9375rem; }
.copy-count, .use-count { font-size: 0.75rem; opacity: 0.7; margin-left: 0.25rem; }
.copied { background: var(--success) !important; color: white !important; border-color: var(--success) !important; }
.source-info {
  font-size: 0.8125rem;
  color: var(--muted);
  padding: 0.75rem 0;
  border-top: 1px solid var(--border);
  margin-bottom: 2rem;
}
.related-section { margin-top: 2rem; }
.related-section h2 { font-size: 1.125rem; font-weight: 600; margin-bottom: 1rem; }

/* ===== Search Page ===== */
.search-page { padding: 1.5rem 0; max-width: 800px; }
.search-form-large {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0;
}
.search-input-large {
  flex: 1;
  padding: 0.625rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--fg);
  font-size: 1rem;
}
.search-input-large:focus { border-color: var(--accent); outline: none; }
.search-count { font-size: 0.875rem; color: var(--muted); margin-bottom: 1rem; }
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 3rem 0;
  color: var(--muted);
  text-align: center;
}

/* ===== Chat Page ===== */
.chat-page { padding: 1.5rem 0; }
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
}
.chat-mode-switch { display: flex; gap: 0.5rem; }
.chat-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 3rem 0;
  color: var(--muted);
  text-align: center;
}
.chat-local-info {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: left;
  max-width: 400px;
}

/* ===== Footer ===== */
.footer {
  margin-top: 3rem;
  padding: 1.5rem 0;
  border-top: 1px solid var(--border);
}
.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8125rem;
  color: var(--muted);
}
.footer-links { display: flex; gap: 1rem; }
.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--fg); }

/* ===== Load More ===== */
.load-more {
  display: flex;
  justify-content: center;
  padding: 1.5rem 0;
}

/* ===== Auth Modal ===== */
.auth-modal {
  border: none;
  border-radius: var(--radius-lg);
  padding: 0;
  max-width: 400px;
  width: 90vw;
  box-shadow: var(--shadow-lg);
}
.auth-modal::backdrop { background: rgba(0,0,0,0.5); }
.auth-modal-content { padding: 2rem; position: relative; }
.auth-modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--muted);
}
.auth-options { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 1rem; }

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .header-inner { gap: 0.5rem; }
  .search-form { max-width: none; }
  .category-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .list-header { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .footer-inner { flex-direction: column; gap: 0.5rem; text-align: center; }
}

/* ===== RTL ===== */
[dir="rtl"] .search-form { direction: rtl; }
[dir="rtl"] .search-input { text-align: right; }
[dir="rtl"] .search-btn { right: auto; left: 0.25rem; }
.dropdown.show { display: block; }
