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

:root {
  --red:        #C0392B;
  --red-light:  #FDECEA;
  --red-dark:   #96281B;
  --blue:       #2980B9;
  --green:      #27AE60;
  --amber:      #E67E22;
  --grey:       #95A5A6;
  --text:       #2C3E50;
  --muted:      #7F8C8D;
  --subtle:     #BDC3C7;
  --border:     #E5E7EB;
  --surface:    #F8F9FA;
  --bg:         #F0F2F5;
  --white:      #FFFFFF;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.08);
  --shadow-md:  0 4px 12px rgba(0,0,0,.10);
  --radius:     10px;
  --radius-sm:  6px;
  --font:       'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --sidebar-w:  220px;
}

body { font-family: var(--font); color: var(--text); background: var(--bg); font-size: 14px; line-height: 1.5; }
a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: 'Fira Mono', monospace; background: var(--surface); padding: 2px 6px; border-radius: 4px; font-size: 12px; }

/* ── Layout ────────────────────────────────────────────────────── */
#root { min-height: 100vh; }

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px 16px;
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.workspace-switcher {
  position: relative;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}
.workspace-name { flex: 1; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.workspace-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 8px; right: 8px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 200;
}
.workspace-option {
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
}
.workspace-option:hover { background: var(--surface); }
.workspace-option.active { color: var(--red); font-weight: 500; }
.ws-role { font-size: 11px; color: var(--muted); }

.sidebar-nav { flex: 1; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.15s;
}
.nav-item:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--red-light); color: var(--red); }
.nav-item svg { flex-shrink: 0; }

.sidebar-user {
  padding: 14px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 11px; color: var(--muted); }
.logout-btn { background: none; border: none; cursor: pointer; color: var(--muted); padding: 4px; border-radius: 4px; display: flex; }
.logout-btn:hover { color: var(--red); background: var(--red-light); }

/* ── Main content ───────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
}
.page-content { padding: 28px 32px; max-width: 1100px; }

/* ── Page header ────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}
.page-title { font-size: 22px; font-weight: 700; color: var(--text); }
.page-subtitle { font-size: 13px; color: var(--muted); margin-top: 3px; }
.page-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm); border: 1.5px solid var(--border);
  background: var(--white); color: var(--text); font-family: var(--font);
  font-size: 13.5px; font-weight: 500; cursor: pointer; transition: all 0.15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--text); }
.btn.primary { background: var(--red); border-color: var(--red); color: var(--white); }
.btn.primary:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn.danger { background: none; border-color: #E74C3C; color: #E74C3C; }
.btn.danger:hover { background: #FDECEA; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ── Form elements ──────────────────────────────────────────────── */
.form-control {
  width: 100%; padding: 8px 12px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-family: var(--font); font-size: 14px;
  color: var(--text); background: var(--white); transition: border-color 0.15s;
}
.form-control:focus { outline: none; border-color: var(--red); }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.form-group { margin-bottom: 16px; }
.form-hint { font-size: 12px; color: var(--muted); margin-top: 5px; }

/* Toggle checkbox */
.toggle-label { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13.5px; font-weight: 400; color: var(--text); text-transform: none; letter-spacing: 0; }
.toggle-label input[type=checkbox] { display: none; }
.toggle-track {
  width: 36px; height: 20px; border-radius: 10px; background: var(--border);
  position: relative; transition: background 0.2s; flex-shrink: 0;
}
.toggle-track::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%; background: var(--white);
  transition: transform 0.2s; box-shadow: var(--shadow-sm);
}
input[type=checkbox]:checked + .toggle-track { background: var(--red); }
input[type=checkbox]:checked + .toggle-track::after { transform: translateX(16px); }

/* Form layout */
.form-layout { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; }
.form-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 16px; }
.form-card-danger { border-color: #FDECEA; }
.form-section-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 16px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }

/* ── Cards ──────────────────────────────────────────────────────── */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.product-card {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; transition: all 0.15s;
}
.product-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.product-cover { position: relative; height: 160px; background: var(--surface); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.product-cover img { width: 100%; height: 100%; object-fit: cover; }
.product-cover-empty { color: var(--subtle); }
.product-cover .status-dot { position: absolute; top: 8px; right: 8px; width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--white); }
.status-dot.status-green { background: var(--green); }
.status-dot.status-amber { background: var(--amber); }
.status-dot.status-grey  { background: var(--grey); }
.product-info { padding: 12px 14px; }
.product-name { font-weight: 600; font-size: 13.5px; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.product-board { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.product-stats { display: flex; align-items: center; gap: 4px; font-size: 11.5px; }
.stat { color: var(--muted); }
.stat-draft { color: var(--amber); font-weight: 500; }
.stat-sep { color: var(--border); }

/* ── Stats bar ──────────────────────────────────────────────────── */
.stats-bar { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 24px; }
.stat-pill { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 16px; display: flex; align-items: center; gap: 8px; }
.stat-pill-value { font-size: 18px; font-weight: 700; color: var(--text); }
.stat-pill-label { font-size: 12px; color: var(--muted); }
.stat-pill-alert { border-color: var(--amber); }
.stat-pill-alert .stat-pill-value { color: var(--amber); }

/* ── Tabs ───────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab { background: none; border: none; padding: 10px 16px; font-family: var(--font); font-size: 13.5px; font-weight: 500; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.15s; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--red); border-bottom-color: var(--red); }

.tab-panel { }
.tab-panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; }
.tab-hint { font-size: 12.5px; color: var(--muted); }

/* ── Images grid ────────────────────────────────────────────────── */
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.image-thumb { position: relative; aspect-ratio: 2/3; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); cursor: grab; border: 2px solid transparent; transition: border-color 0.15s; }
.image-thumb:hover { border-color: var(--red); }
.image-thumb.dragging { opacity: 0.5; }
.image-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.image-delete-btn { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.55); color: var(--white); border: none; border-radius: 50%; width: 22px; height: 22px; cursor: pointer; font-size: 14px; display: none; align-items: center; justify-content: center; }
.image-thumb:hover .image-delete-btn { display: flex; }
.image-used-badge { position: absolute; bottom: 4px; left: 4px; background: rgba(39,174,96,.85); color: white; font-size: 10px; padding: 1px 5px; border-radius: 3px; }

/* ── Titles ─────────────────────────────────────────────────────── */
.titles-section-heading { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 10px; }
.titles-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.title-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.title-text { flex: 1; font-size: 13.5px; }
.title-meta { display: flex; gap: 8px; align-items: center; }
.title-used { font-size: 11px; color: var(--muted); }
.title-date { font-size: 11px; color: var(--subtle); }
.add-title-row { display: flex; gap: 8px; }
.icon-btn { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 16px; width: 28px; height: 28px; border-radius: 4px; display: flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: var(--surface); }
.icon-btn.danger:hover { color: #E74C3C; background: var(--red-light); }

/* ── Pin log ────────────────────────────────────────────────────── */
.pin-log { display: flex; flex-direction: column; gap: 8px; }
.pin-log-row { display: flex; align-items: center; gap: 14px; padding: 12px 14px; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.pin-log-thumb { width: 50px; height: 70px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.pin-log-thumb-empty { width: 50px; height: 70px; background: var(--surface); border-radius: 4px; flex-shrink: 0; }
.pin-log-info { flex: 1; min-width: 0; }
.pin-log-title { font-size: 13.5px; font-weight: 500; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pin-log-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pin-log-date { font-size: 11.5px; color: var(--muted); }
.pin-log-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ── Badges ─────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge-green  { background: #D5F5E3; color: #1E8449; }
.badge-blue   { background: #D6EAF8; color: #1A5276; }
.badge-amber  { background: #FDEBD0; color: #A04000; }
.badge-red    { background: #FADBD8; color: #922B21; }
.badge-orange { background: #FDEBD0; color: #A04000; }
.badge-grey   { background: var(--surface); color: var(--muted); }

/* ── Product detail meta ────────────────────────────────────────── */
.product-meta { display: flex; align-items: center; gap: 10px; margin-top: 5px; flex-wrap: wrap; }
.meta-item { font-size: 13px; color: var(--muted); }
.meta-link { font-size: 13px; color: var(--red); }

/* ── Auth pages ─────────────────────────────────────────────────── */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 24px; }
.auth-card { background: var(--white); border: 1px solid var(--border); border-radius: 16px; padding: 40px; width: 100%; max-width: 420px; box-shadow: var(--shadow-md); }
.auth-logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; color: var(--text); margin-bottom: 28px; }
.auth-title { font-size: 24px; font-weight: 700; margin-bottom: 10px; }
.auth-subtitle { font-size: 14px; color: var(--muted); margin-bottom: 24px; line-height: 1.6; }
.auth-google-btn { margin-bottom: 16px; display: flex; justify-content: center; }
.auth-note { font-size: 12.5px; color: var(--muted); text-align: center; }
.invite-info { background: var(--surface); border-radius: var(--radius-sm); padding: 14px 16px; margin-bottom: 20px; font-size: 14px; line-height: 1.7; }
.invite-email { font-size: 12.5px; color: var(--muted); margin-top: 6px; }

/* ── Admin ──────────────────────────────────────────────────────── */
.admin-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.admin-table th { text-align: left; padding: 10px 14px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); border-bottom: 2px solid var(--border); }
.admin-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }
.user-cell { display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.user-avatar-placeholder { width: 32px; height: 32px; border-radius: 50%; background: var(--red-light); color: var(--red); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.user-name { font-weight: 500; font-size: 13.5px; }
.user-email { font-size: 12px; color: var(--muted); }
.table-actions { display: flex; gap: 6px; }
.invite-form { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.invite-form .form-control { flex: 1; min-width: 200px; }
.code-area { font-family: 'Fira Mono', monospace; font-size: 12px; }
.text-muted { color: var(--muted); font-size: 12.5px; }

/* ── Pin edit ───────────────────────────────────────────────────── */
.pin-edit-current-img { width: 100%; max-height: 250px; object-fit: contain; border-radius: var(--radius-sm); background: var(--surface); margin-bottom: 12px; }
.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius-sm);
  padding: 20px; text-align: center; cursor: pointer;
  transition: border-color 0.15s; position: relative;
}
.upload-zone:hover { border-color: var(--red); }
.upload-zone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.upload-zone svg { color: var(--subtle); margin-bottom: 8px; }
.upload-zone p { font-size: 13px; color: var(--muted); }
.upload-preview { width: 100%; max-height: 300px; object-fit: contain; border-radius: var(--radius-sm); background: var(--surface); margin-top: 10px; }

/* ── SEO assistant ──────────────────────────────────────────────── */
.seo-btn { background: none; border: 1.5px solid var(--border); border-radius: 20px; padding: 3px 10px; font-size: 11.5px; font-weight: 500; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; gap: 5px; transition: all 0.15s; font-family: var(--font); margin-left: 8px; }
.seo-btn:hover { border-color: var(--red); color: var(--red); }
.seo-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.seo-panel { margin-top: 8px; border: 1.5px solid var(--border); border-radius: 10px; overflow: hidden; display: none; }
.seo-panel.open { display: block; }
.seo-panel-header { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--border); font-size: 12px; font-weight: 600; color: var(--muted); }
.seo-lang-toggle { display: flex; gap: 4px; }
.seo-lang-btn { padding: 2px 10px; border-radius: 12px; border: 1.5px solid var(--border); font-size: 11px; font-weight: 600; cursor: pointer; background: none; color: var(--muted); font-family: var(--font); transition: all 0.15s; }
.seo-lang-btn.active { background: var(--red); color: var(--white); border-color: var(--red); }
.seo-suggestions { padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.seo-suggestion { padding: 10px 12px; border-radius: 8px; border: 1.5px solid var(--border); font-size: 13px; line-height: 1.6; color: var(--text); cursor: pointer; transition: all 0.15s; background: var(--white); }
.seo-suggestion:hover { border-color: var(--red); background: var(--surface); }
.seo-char-count { font-size: 10.5px; color: var(--muted); margin-top: 4px; }
.seo-loading { padding: 20px; text-align: center; color: var(--muted); font-size: 13px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.seo-error { padding: 12px; color: var(--red); font-size: 13px; text-align: center; }

/* Tag chips */
.tag-suggestions-wrap { margin-top: 8px; display: none; }
.tag-suggestions-wrap.open { display: block; }
.tag-suggestions-label { font-size: 11.5px; color: var(--muted); margin-bottom: 6px; }
.tag-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-chip-wrap { display: inline-flex; align-items: center; gap: 3px; }
.tag-chip { padding: 4px 10px; border-radius: 14px; border: 1.5px solid var(--border); font-size: 12px; color: var(--muted); cursor: pointer; background: var(--surface); transition: all 0.15s; font-family: var(--font); }
.tag-chip:hover { border-color: var(--red); color: var(--red); }
.tag-chip.selected { background: var(--red); color: var(--white); border-color: var(--red); }
.tag-trends-btn { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%; border: none; background: none; cursor: pointer; color: var(--muted); padding: 0; transition: color 0.15s; flex-shrink: 0; }
.tag-trends-btn:hover { color: var(--red); }
.tag-chips-actions { margin-top: 8px; display: flex; gap: 8px; }
.alt-suggestion { margin-top: 8px; padding: 10px 12px; border-radius: 8px; border: 1.5px solid var(--border); background: var(--surface); display: none; }
.alt-suggestion.open { display: block; }
.alt-suggestion-text { font-size: 13px; color: var(--text); line-height: 1.6; margin-bottom: 8px; }
.alt-suggestion-footer { display: flex; align-items: center; justify-content: space-between; }
.alt-suggestion-chars { font-size: 11px; color: var(--muted); }

/* ── Impersonation banner ───────────────────────────────────────── */
.impersonation-banner { background: #FFF3CD; border-bottom: 1px solid #FFEAA7; padding: 10px 20px; display: flex; align-items: center; justify-content: space-between; font-size: 13.5px; position: sticky; top: 0; z-index: 200; }

/* ── Toast ──────────────────────────────────────────────────────── */
.toast { position: fixed; bottom: 24px; right: 24px; padding: 12px 18px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 500; box-shadow: var(--shadow-md); z-index: 1000; opacity: 0; transform: translateY(8px); transition: all 0.25s; max-width: 320px; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: #D5F5E3; color: #1E8449; }
.toast-error   { background: #FADBD8; color: #922B21; }
.toast-info    { background: #D6EAF8; color: #1A5276; }

/* ── Empty & loading states ─────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty-state p { margin-bottom: 16px; }
.page-loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 48px; color: var(--muted); font-size: 14px; }
.page-error { padding: 24px; color: var(--red); }
.error-banner { background: #FADBD8; border: 1px solid #F1948A; border-radius: var(--radius-sm); padding: 12px 16px; color: #922B21; font-size: 13.5px; margin-bottom: 16px; }

/* ── Spinner ────────────────────────────────────────────────────── */
.spinner { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--red); border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
  .page-content { padding: 16px; }
  .form-layout { grid-template-columns: 1fr; }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}
