/* ============================================
   OG Image Preview — Clean Utility UI
   Dark mode, minimal, responsive
   ============================================ */

:root {
  --bg-primary: #0c0c0f;
  --bg-secondary: #111116;
  --bg-tertiary: #19191f;
  --bg-card: rgba(22, 22, 28, 0.9);
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.16);
  --text-primary: #eeeef0;
  --text-secondary: #8b8b98;
  --text-muted: #55555e;
  --accent: #818cf8;
  --accent-dim: rgba(129, 140, 248, 0.12);
  --accent-glow: rgba(129, 140, 248, 0.25);
  --green: #22c55e;
  --green-dim: rgba(34, 197, 94, 0.12);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.12);
  --yellow: #f59e0b;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --transition: 0.2s ease;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

/* App Container */
.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
.header { margin-bottom: 28px; }

.header-inner { display: flex; flex-direction: column; gap: 4px; }

.logo {
  display: flex; align-items: center; gap: 12px;
  color: var(--accent);
}

.logo h1 { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.02em; color: var(--text-primary); }

.subtitle { font-size: 0.85rem; color: var(--text-secondary); }

/* URL Section */
.url-section { margin-bottom: 24px; }

.url-bar {
  display: flex; gap: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 6px;
}

.url-input {
  flex: 1;
  font-family: var(--font);
  font-size: 0.9rem;
  padding: 10px 14px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  outline: none;
}

.url-input::placeholder { color: var(--text-muted); }

.fetch-btn {
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 10px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  display: flex; align-items: center; gap: 6px;
  white-space: nowrap;
}

.fetch-btn:hover { background: #6366f1; box-shadow: 0 0 16px var(--accent-glow); }

.url-hint {
  margin-top: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
  min-height: 1.2em;
}

.url-hint.error { color: var(--red); }
.url-hint.success { color: var(--green); }

/* Main Grid */
.main-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 24px;
  flex: 1;
}

/* Panel */
.panel {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.panel-title {
  font-size: 0.8rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

/* Editor Panel */
.editor-panel {
  display: flex; flex-direction: column; gap: 14px;
  height: fit-content;
}

.field-group {
  display: flex; flex-direction: column; gap: 4px;
  position: relative;
}

.field-label {
  font-size: 0.72rem; font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field-input {
  font-family: var(--font);
  font-size: 0.85rem;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  transition: border-color var(--transition);
  resize: vertical;
}

.field-input:focus { outline: none; border-color: var(--accent); }

.field-select {
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%238b8b98' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.char-count {
  position: absolute; top: 0; right: 0;
  font-size: 0.65rem;
  color: var(--text-muted);
}

/* Image Validation */
.image-validation {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.75rem;
  padding: 4px 0;
}

.image-validation.valid { color: var(--green); }
.image-validation.warning { color: var(--yellow); }
.image-validation.invalid { color: var(--red); }

/* Editor Actions */
.editor-actions {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-top: 4px;
}

.btn {
  font-family: var(--font);
  font-size: 0.8rem; font-weight: 600;
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  transition: all var(--transition);
}

.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #6366f1; box-shadow: 0 0 16px var(--accent-glow); }

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

/* Preview Panel */
.preview-panel {
  display: flex; flex-direction: column; gap: 16px;
}

/* Tabs */
.preview-tabs {
  display: flex; gap: 4px;
  background: var(--bg-primary);
  padding: 4px;
  border-radius: var(--radius-sm);
}

.tab {
  flex: 1;
  font-family: var(--font);
  font-size: 0.78rem; font-weight: 500;
  padding: 8px 12px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition);
}

.tab:hover { color: var(--text-secondary); }
.tab.active { background: var(--bg-tertiary); color: var(--text-primary); }

.preview-card.hidden { display: none; }

/* Facebook Card */
.fb-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-secondary);
}

.fb-image-wrap {
  width: 100%;
  aspect-ratio: 1.91 / 1;
  background: var(--bg-tertiary);
  overflow: hidden;
  position: relative;
}

.fb-image {
  width: 100%; height: 100%;
  object-fit: cover;
  display: none;
}

.fb-image-placeholder, .tw-image-placeholder, .li-image-placeholder {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.fb-content { padding: 12px 16px; }

.fb-domain {
  font-size: 0.7rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.fb-title {
  font-size: 0.95rem; font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}

.fb-desc {
  font-size: 0.78rem; color: var(--text-secondary);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Twitter Card */
.tw-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  background: var(--bg-secondary);
}

.tw-image-wrap {
  width: 100%;
  aspect-ratio: 2 / 1;
  background: var(--bg-tertiary);
  overflow: hidden;
  position: relative;
}

.tw-image {
  width: 100%; height: 100%;
  object-fit: cover;
  display: none;
}

.tw-content { padding: 12px 16px; }

.tw-title {
  font-size: 0.9rem; font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}

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

.tw-domain { font-size: 0.72rem; color: var(--text-muted); }

.tw-card.summary-card {
  display: grid;
  grid-template-columns: 120px 1fr;
}

.tw-card.summary-card .tw-image-wrap {
  aspect-ratio: 1;
  border-radius: 16px 0 0 16px;
}

/* LinkedIn Card */
.li-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-secondary);
}

.li-image-wrap {
  width: 100%;
  aspect-ratio: 1.91 / 1;
  background: var(--bg-tertiary);
  overflow: hidden;
  position: relative;
}

.li-image {
  width: 100%; height: 100%;
  object-fit: cover;
  display: none;
}

.li-content { padding: 12px 16px; }

.li-title {
  font-size: 0.88rem; font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.li-domain { font-size: 0.72rem; color: var(--text-muted); }

/* Image Info */
.image-info {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.info-title {
  font-size: 0.72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.info-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 16px;
  font-size: 0.78rem;
}

.info-label { color: var(--text-muted); }
.info-value { color: var(--text-primary); font-weight: 500; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.modal-overlay.hidden { display: none; }

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  max-width: 640px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}

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

.modal-header h3 { font-size: 1rem; font-weight: 600; }

.modal-close {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.9rem;
  transition: all var(--transition);
}

.modal-close:hover { color: var(--text-primary); border-color: var(--border-hover); }

.modal-code {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  overflow-x: auto;
  font-size: 0.78rem;
  line-height: 1.7;
  color: var(--accent);
  margin-bottom: 12px;
}

.modal-copy { width: 100%; }

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

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

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 100px; }

/* Responsive */
@media (max-width: 860px) {
  .main-grid { grid-template-columns: 1fr; }
}

@media (max-width: 500px) {
  .app { padding: 16px 12px; }
  .url-bar { flex-direction: column; }
  .fetch-btn { width: 100%; justify-content: center; }
  .tw-card.summary-card { grid-template-columns: 1fr; }
  .tw-card.summary-card .tw-image-wrap { aspect-ratio: 2/1; border-radius: 16px 16px 0 0; }
}
