/*
 * Application styles — consolidated from all views.
 */

/* ── Animations ─────────────────────────────────────────────────────────── */
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

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

/* ── Base body ──────────────────────────────────────────────────────────── */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f9f6f1;
  color: #1a1a1a;
}

/* ── Auth layout ────────────────────────────────────────────────────────── */
.auth-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

/* ── Card ───────────────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.07);
}

/* ── Logo ───────────────────────────────────────────────────────────────── */
.logo {
  display: block;
  width: 300px;
  height: auto;
  border-radius: 12px;
  margin: 0 auto 1.5rem;
}

/* ── Typography ─────────────────────────────────────────────────────────── */
h1 { font-size: 1.5rem; font-weight: 800; }

.subtitle { color: #888; font-size: 0.95rem; margin-bottom: 1.75rem; }

.footer-link { text-align: center; margin-top: 1.25rem; font-size: 0.9rem; color: #888; }
.footer-link a { color: #4f7942; font-weight: 600; text-decoration: none; }

.back { display: block; text-align: center; margin-top: 1.25rem; font-size: 0.9rem; color: #4f7942; font-weight: 600; text-decoration: none; }

.hint { font-size: 0.8rem; color: #aaa; margin-top: -0.6rem; margin-bottom: 1rem; }

.forgot { display: block; text-align: right; font-size: 0.85rem; color: #4f7942; text-decoration: none; margin-top: -0.5rem; margin-bottom: 1rem; font-weight: 600; }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 700;
  background: #4f7942;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: #3d6032; }

.btn-outline {
  background: transparent;
  color: #4f7942;
  border: 1.5px solid #4f7942;
}
.btn-outline:hover { background: #f0f7ee; }

.btn-ai { background: #6c47cc; }
.btn-ai:hover { background: #5638a8; }

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 6px;
  text-decoration: none;
  border: none;
  cursor: pointer;
}

.btn-danger { background: #fff0f0; color: #c0392b; }
.btn-danger:hover { background: #fde8e8; }

.btn-block {
  display: block;
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  font-weight: 700;
  justify-content: center;
}

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.7rem;
  font-size: 0.95rem;
  font-weight: 600;
  background: #fff;
  color: #333;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
}
.btn-google:hover { background: #f5f5f5; border-color: #ccc; }

/* ── Form elements ──────────────────────────────────────────────────────── */
label { display: block; font-size: 0.875rem; font-weight: 600; margin-bottom: 0.35rem; }

input[type="email"],
input[type="password"],
input[type="text"],
input[type="tel"],
input[type="number"] {
  display: block;
  width: 100%;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  padding: 0.65rem 0.9rem;
  background: #fafafa;
  color: #1a1a1a;
  outline: none;
  margin-bottom: 1rem;
  font-size: 1rem;
}
input:focus { border-color: #4f7942; background: #fff; }

/* ── Slug wrap ──────────────────────────────────────────────────────────── */
.slug-wrap {
  display: flex;
  align-items: center;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  background: #fafafa;
  margin-bottom: 0.4rem;
  overflow: hidden;
}
.slug-wrap:focus-within { border-color: #4f7942; background: #fff; }
.slug-prefix {
  padding: 0.65rem 0.6rem 0.65rem 0.9rem;
  font-size: 1rem;
  color: #aaa;
  white-space: nowrap;
  user-select: none;
}
.slug-wrap input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0.65rem 0.9rem 0.65rem 0;
  font-size: 1rem;
  color: #1a1a1a;
  outline: none;
  margin: 0;
}

/* ── Divider ────────────────────────────────────────────────────────────── */
.divider { display: flex; align-items: center; gap: 0.75rem; margin: 1.25rem 0; color: #ccc; font-size: 0.85rem; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: #e5e5e5; }

/* ── Notices / Alerts ───────────────────────────────────────────────────── */
.notice { background: #e8f5e9; color: #2e7d32; border-radius: 8px; padding: 0.75rem 1rem; margin-bottom: 1.5rem; font-size: 0.9rem; }
.notice-bar { background: #e8f5e9; color: #2e7d32; border-radius: 6px; padding: 0.5rem 0.75rem; font-size: 0.82rem; }
.alert { color: #c0392b; font-size: 0.9rem; margin-bottom: 1rem; text-align: center; }
.alert-bar { background: #fff3f3; color: #c0392b; border-radius: 6px; padding: 0.5rem 0.75rem; font-size: 0.82rem; }
.errors { background: #fff3f3; border: 1px solid #f5c2c2; border-radius: 8px; padding: 0.75rem 1rem; margin-bottom: 1rem; font-size: 0.9rem; color: #c0392b; }

/* ── Nav header ─────────────────────────────────────────────────────────── */
.nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 800px;
  margin: 0 auto;
  padding-top: 2rem;
}
.wordmark {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 800;
  text-decoration: none;
  color: inherit;
  font-size: 1.1rem;
}
.wordmark img { width: 32px; height: 32px; border-radius: 7px; }
.header-actions { display: flex; align-items: center; gap: 0.75rem; }
.menu-wrap { position: relative; }
.hamburger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
}
.hamburger:hover { background: rgba(0,0,0,0.05); }
.hamburger span { display: block; height: 2px; background: #1a1a1a; border-radius: 2px; }
.dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  min-width: 150px;
  overflow: hidden;
  z-index: 100;
}
.dropdown.open { display: block; }
.dropdown form { margin: 0; }
.dropdown button {
  display: block;
  width: 100%;
  padding: 0.7rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #c0392b;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
}
.dropdown button:hover { background: #fff5f5; }
.dropdown-link { display: block; padding: 0.7rem 1rem; font-size: 0.9rem; font-weight: 600; color: #1a1a1a; text-decoration: none; }
.dropdown-link:hover { background: #f5f5f5; }

/* ── Editor header ──────────────────────────────────────────────────────── */
.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: #fff;
  border-bottom: 1px solid #e8e4de;
  flex-shrink: 0;
  gap: 1rem;
}
.page-info { flex: 1; min-width: 0; }
.page-title { font-weight: 700; font-size: 0.95rem; color: #444; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-slug-label { font-size: 0.8rem; color: #999; font-family: monospace; }

/* ── Pages list ─────────────────────────────────────────────────────────── */
.page-list { padding: 2rem; }
.page-list main { max-width: 800px; margin: 0 auto; }
.page-list h1 { font-size: 1.75rem; font-weight: 800; margin-bottom: 1.5rem; }
.sites-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.site-card {
  background: #fff;
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s, transform 0.1s;
  cursor: pointer;
}
.site-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.1); transform: translateY(-1px); }
.site-name { font-weight: 700; font-size: 1.05rem; }
.site-slug { font-size: 0.85rem; color: #888; font-family: monospace; }
.site-card-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.empty { text-align: center; padding: 4rem 2rem; color: #888; }
.empty p { margin-bottom: 1.5rem; font-size: 1.05rem; }

/* ── Editor layout ──────────────────────────────────────────────────────── */
.editor-layout { display: flex; flex: 1; overflow: hidden; }
.editor-panel { width: 380px; flex-shrink: 0; display: flex; flex-direction: column; border-right: 1px solid #e8e4de; background: #fff; overflow: hidden; padding: 1.25rem; gap: 0.75rem; position: relative; }
.editor-panel.editor-loading::after { content: "Rejigging your page\2026"; position: absolute; inset: 0; background: rgba(255,255,255,0.85); display: flex; align-items: center; justify-content: center; font-size: 0.95rem; font-weight: 600; color: #6c47cc; animation: pulse 1.2s ease-in-out infinite; }
.ai-form { display: flex; flex-direction: column; gap: 0.75rem; flex: 1; }
.ai-form label { font-size: 0.95rem; font-weight: 700; color: #1a1a1a; display: flex; flex-direction: column; gap: 0.2rem; }
.ai-hint { font-size: 0.8rem; color: #aaa; font-weight: 400; }
.ai-form textarea {
  flex: 1;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.95rem;
  line-height: 1.6;
  border: 1.5px solid #e0dbd3;
  border-radius: 8px;
  padding: 0.75rem;
  resize: none;
  background: #fafaf8;
  color: #1a1a1a;
  outline: none;
}
.ai-form textarea:focus { border-color: #6c47cc; background: #fff; }

.preview-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: #e8e4de; }
.preview-bar { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.75rem; background: #f0ece6; border-bottom: 1px solid #ddd9d2; flex-shrink: 0; }
#preview-wrapper { display: flex; flex: 1; overflow: hidden; }
#preview-wrapper.preview-mobile { overflow: auto; background: #d0ccc6; justify-content: center; align-items: flex-start; }
.preview-panel iframe { flex: 1; width: 100%; border: none; }
#preview-wrapper.preview-mobile iframe { flex: none; border-radius: 10px; box-shadow: 0 4px 24px rgba(0,0,0,0.25); margin: 1rem auto; }
.preview-mode-btn { background: none; border: none; cursor: pointer; padding: 0.2rem; color: #aaa; border-radius: 4px; display: flex; align-items: center; }
.preview-mode-btn:hover { color: #555; }
.preview-mode-btn.active { color: #4f7942; }
.preview-mode-btn svg { width: 16px; height: 16px; }

/* ── Lighthouse bar ─────────────────────────────────────────────────────── */
#lighthouse-bar { background: #f9f6f1; border-bottom: 1px solid #e8e4de; padding: 0.6rem 1.25rem; flex-shrink: 0; }
.lh-loading { font-size: 0.85rem; color: #888; animation: pulse 1.2s ease-in-out infinite; }
.lh-scores { display: flex; gap: 1.5rem; align-items: center; }
.lh-score { display: flex; flex-direction: column; align-items: center; gap: 0.25rem; }
.lh-circle { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.8rem; font-weight: 700; border: 3px solid; }
.lh-green  { color: #0cce6b; border-color: #0cce6b; }
.lh-orange { color: #ffa400; border-color: #ffa400; }
.lh-red    { color: #ff4e42; border-color: #ff4e42; }
.lh-grey   { color: #aaa;    border-color: #ddd; }
.lh-label  { font-size: 0.7rem; color: #888; text-align: center; max-width: 56px; line-height: 1.2; }
.lh-error  { font-size: 0.85rem; color: #e57373; }

/* ── Images index page ──────────────────────────────────────────────────── */
.images-page { max-width: 960px; margin: 0 auto; padding: 2rem 1rem; }
.images-page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 1.5rem; }
.images-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
.image-card { background: #fff; border-radius: 10px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.06); display: flex; flex-direction: column; }
.image-card-thumb { aspect-ratio: 4/3; overflow: hidden; background: #f0ece6; }
.image-card-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.image-card-info { padding: 0.6rem 0.75rem 0; flex: 1; }
.image-card-name { font-size: 0.8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.image-card-meta { font-size: 0.75rem; color: #aaa; margin-top: 0.1rem; }
.image-card-actions { display: flex; flex-direction: column; }
.image-card-toggle { background: none; border: none; width: 100%; padding: 0.25rem; cursor: pointer; font-size: 1rem; color: #aaa; transition: transform 0.2s; }
.image-card-toggle:hover { color: #666; }
.image-card-toggle[aria-expanded="true"] { transform: rotate(180deg); }
.image-card-actions-drawer { display: none; padding: 0.5rem 0.75rem; }
.image-card-actions-drawer.open { display: block; }
.image-description { width: 100%; margin-top: 0.4rem; font-size: 0.8rem; font-family: inherit; line-height: 1.4; border: 1px solid #e0dbd3; border-radius: 6px; padding: 0.35rem 0.5rem; resize: none; background: #fafaf8; color: #444; outline: none; }
.image-description:focus { border-color: #6c47cc; background: #fff; }
.image-description.analyzing { border-color: #b8a9e0; animation: pulse 1.5s ease-in-out infinite; }

/* ── Media panel ────────────────────────────────────────────────────────── */
.media-panel { border-top: 1px solid #e8e4de; padding-top: 0.75rem; flex-shrink: 0; }
.media-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.5rem; }
.media-title { font-size: 0.8rem; font-weight: 700; color: #888; text-transform: uppercase; letter-spacing: 0.05em; }
.media-upload-btn { display: inline-block; }
#media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.media-item { position: relative; aspect-ratio: 1; border-radius: 6px; overflow: hidden; background: #f0ece6; }
.media-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-item-actions { position: absolute; inset: 0; background: rgba(0,0,0,0.45); display: flex; align-items: center; justify-content: center; gap: 6px; opacity: 0; transition: opacity 0.15s; }
.media-item:hover .media-item-actions { opacity: 1; }
.media-copy-btn, .media-delete-btn { background: rgba(255,255,255,0.9); border: none; border-radius: 4px; width: 26px; height: 26px; cursor: pointer; font-size: 0.85rem; display: flex; align-items: center; justify-content: center; }
.media-copy-btn:hover { background: #fff; }
.media-delete-btn:hover { background: #ffd0d0; }
.media-status-msg { font-size: 0.8rem; padding: 0.25rem 0; }

/* ── Version history ────────────────────────────────────────────────────── */
.versions-page { max-width: 760px; margin: 0 auto; padding: 2rem 1rem; }
.versions-page h2 { font-size: 1.25rem; font-weight: 700; margin-bottom: 1.25rem; }
.version-list { border: 1px solid #e8e4de; border-radius: 10px; overflow: hidden; background: #fff; }
.version-item { display: flex; align-items: center; gap: 1rem; padding: 0.875rem 1rem; border-bottom: 1px solid #e8e4de; }
.version-item:last-child { border-bottom: none; }
.version-item:hover { background: #fafaf8; }
.version-sha { font-family: monospace; font-size: 0.75rem; color: #888; background: #f3f0eb; padding: 0.15rem 0.4rem; border-radius: 4px; flex-shrink: 0; }
.version-message { flex: 1; font-size: 0.9rem; font-weight: 500; }
.version-time { font-size: 0.8rem; color: #aaa; flex-shrink: 0; }
.version-empty { text-align: center; padding: 3rem 1rem; color: #aaa; }

/* ── Dark mode ──────────────────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  body { background: #0f0f0f; color: #e8e8e8; }
  .card { background: #1a1a1a; box-shadow: 0 4px 24px rgba(0,0,0,0.3); }
  .wordmark { color: #e8e8e8; }
  .hamburger span { background: #e8e8e8; }
  .hamburger:hover { background: rgba(255,255,255,0.08); }
  .dropdown { background: #1a1a1a; box-shadow: 0 4px 20px rgba(0,0,0,0.4); }
  .dropdown button { color: #e57373; }
  .dropdown button:hover { background: #2a1a1a; }
  .dropdown-link { color: #e8e8e8; }
  .dropdown-link:hover { background: #222; }
  .editor-header { background: #111; border-bottom-color: #222; }
  #lighthouse-bar { background: #0f0f0f; border-bottom-color: #222; }
  .page-title { color: #ccc; }
  input[type="email"],
  input[type="password"],
  input[type="text"],
  input[type="tel"],
  input[type="number"] { background: #111; border-color: #333; color: #e8e8e8; }
  input:focus { border-color: #6dbf67; background: #1a1a1a; }
  .slug-wrap { background: #111; border-color: #333; }
  .slug-wrap:focus-within { border-color: #6dbf67; background: #1a1a1a; }
  .slug-wrap input { color: #e8e8e8; }
  .btn-danger { background: #2a1a1a; color: #e57373; }
  .btn-danger:hover { background: #3a1f1f; }
  .btn-google { background: #222; color: #e8e8e8; border-color: #333; }
  .btn-google:hover { background: #2a2a2a; }
  .btn-outline { color: #6dbf67; border-color: #6dbf67; }
  .divider { color: #444; }
  .divider::before, .divider::after { background: #333; }
  .notice { background: #1a2e1a; color: #6dbf67; }
  .notice-bar { background: #1a2e1a; color: #6dbf67; }
  .alert-bar { background: #2a1a1a; color: #e57373; }
  .site-card { background: #1a1a1a; box-shadow: 0 2px 8px rgba(0,0,0,0.3); color: #e8e8e8; }
  .site-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.5); }
  .site-slug { color: #666; }
  .editor-panel { background: #111; border-right-color: #222; }
  .editor-panel.editor-loading::after { background: rgba(0,0,0,0.75); color: #a78bdb; }
  .ai-form label { color: #e8e8e8; }
  .ai-form textarea { background: #0d0d0d; border-color: #2a2a2a; color: #e8e8e8; }
  .ai-form textarea:focus { border-color: #7c5cd6; background: #111; }
  .preview-bar { background: #1a1a1a; border-bottom-color: #222; }
  .preview-panel { background: #1a1a1a; }
  .preview-mode-btn:hover { color: #aaa; }
  .preview-mode-btn.active { color: #6dbf67; }
  #preview-wrapper.preview-mobile { background: #111; }
  .subtitle { color: #666; }
  .footer-link { color: #666; }
  .footer-link a { color: #6dbf67; }
  .hint { color: #555; }
  .image-card { background: #1a1a1a; box-shadow: 0 2px 8px rgba(0,0,0,0.3); }
  .image-card-thumb { background: #111; }
  .image-card-name { color: #e8e8e8; }
  .image-description { background: #111; border-color: #2a2a2a; color: #aaa; }
  .image-description:focus { border-color: #7c5cd6; background: #1a1a1a; }
  .media-panel { border-top-color: #222; }
  .media-item { background: #1a1a1a; }
  .version-list { border-color: #222; }
  .version-item { border-bottom-color: #222; }
  .version-item:hover { background: #1a1a1a; }
  .version-sha { color: #888; background: #1a1a1a; }
  .version-message { color: #e8e8e8; }
  .version-time { color: #555; }
}
