/* ─────────────────────────────────────────
   AdForge Portal — authenticated user pages
   Inherits CSS vars from layout.ejs.
   Pages: dashboard, login, signup, ideas/new, ideas/:id
   ───────────────────────────────────────── */

/* LAYOUT */
.portal-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* PORTAL HEADER */
.portal-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.portal-header .logo {
  font-family: 'Bebas Neue', cursive;
  font-size: 22px;
  letter-spacing: 0.08em;
  color: var(--primary);
  text-decoration: none;
}
.portal-header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}
.portal-user {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}
.portal-user span {
  color: var(--muted);
  font-weight: 400;
}
.portal-nav {
  display: flex;
  gap: 4px;
}
.portal-nav a {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
}
.portal-nav a:hover, .portal-nav a.active {
  background: var(--deep);
  color: var(--text);
}

/* MAIN CONTENT */
.portal-main {
  flex: 1;
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 24px 80px;
  width: 100%;
}

/* PAGE HEADERS */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 32px;
  gap: 20px;
}
.page-title {
  font-family: 'Bebas Neue', cursive;
  font-size: 42px;
  color: var(--text);
  line-height: 1;
}
.page-subtitle {
  font-size: 15px;
  color: var(--muted);
  margin-top: 8px;
}

/* STATS BAR */
.stats-bar {
  display: flex;
  gap: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 28px;
  margin-bottom: 36px;
  box-shadow: 0 2px 12px var(--shadow);
}
.stat-item {
  flex: 1;
  text-align: center;
}
.stat-value {
  font-family: 'Bebas Neue', cursive;
  font-size: 32px;
  color: var(--primary);
  line-height: 1;
}
.stat-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  margin-top: 4px;
}
.stat-item.credits .stat-value { color: #22C55E; }

/* IDEA CARDS GRID */
.ideas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}
.idea-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 2px 12px var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: box-shadow 0.2s, transform 0.2s;
}
.idea-card:hover {
  box-shadow: 0 6px 24px var(--shadow-lg);
  transform: translateY(-2px);
}
.idea-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.idea-title {
  font-family: 'Bebas Neue', cursive;
  font-size: 20px;
  color: var(--text);
  line-height: 1.1;
}
.idea-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}
.idea-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}
.meta-stat {
  display: flex;
  align-items: center;
  gap: 5px;
}

/* BADGES */
.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  text-transform: capitalize;
  white-space: nowrap;
}
.badge-draft    { background: var(--deep); color: var(--muted); }
.badge-active   { background: #DCFCE7; color: #16A34A; }
.badge-generating { background: var(--primary-soft); color: var(--primary); }
.badge-paused   { background: #FEF9C3; color: #CA8A04; }

/* ASSET TYPE BADGES */
.asset-type-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.asset-type-badge.script { background: #F0F9FF; color: #0369A1; }
.asset-type-badge.image  { background: #FDF4FF; color: #A21CAF; }
.asset-type-badge.video  { background: #F0FDF4; color: #15803D; }

/* FORMS */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--deep);
  padding: 24px;
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 8px 40px var(--shadow-lg);
}
.auth-logo {
  font-family: 'Bebas Neue', cursive;
  font-size: 28px;
  letter-spacing: 0.08em;
  color: var(--primary);
  text-align: center;
  margin-bottom: 8px;
}
.auth-tagline {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 36px;
}
.field {
  margin-bottom: 20px;
}
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.field input, .field textarea, .field select {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.2s;
  box-sizing: border-box;
}
.field input:focus, .field textarea:focus {
  outline: none;
  border-color: var(--primary);
}
.field input::placeholder, .field textarea::placeholder { color: #C4BFB8; }
.field-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
  display: block;
}
.auth-error {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  color: #B91C1C;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 20px;
}
.auth-divider {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  margin: 20px 0;
}

/* BUTTONS (shared portal) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 600;
  font-size: 14px;
  padding: 11px 22px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
  text-decoration: none;
  line-height: 1;
}
.btn-primary {
  background: var(--primary); color: #fff;
  box-shadow: 0 4px 16px rgba(232,93,43,0.3);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(232,93,43,0.4);
  background: var(--primary-light);
}
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover { border-color: var(--primary); transform: translateY(-1px); }
.btn-sm { font-size: 12px; padding: 8px 16px; }
.btn-lg { font-size: 16px; padding: 16px 32px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-loading { opacity: 0.8; }

/* SPINNERS */
.spinner-sm {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner-lg {
  width: 44px; height: 44px;
  border: 4px solid rgba(232,93,43,0.15);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.spinner-overlay {
  position: fixed; inset: 0;
  background: rgba(255,251,245,0.85);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(4px);
}
.spinner-overlay-inner { text-align: center; }
.spinner-overlay-inner p { margin-top: 16px; font-size: 14px; color: var(--muted); font-weight: 500; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ALERTS */
.alert {
  position: fixed; top: 80px; left: 50%; transform: translateX(-50%);
  z-index: 1000; padding: 12px 24px;
  border-radius: 10px; font-size: 14px; font-weight: 500;
  max-width: 500px; width: calc(100% - 48px);
  text-align: center;
}
.alert-error   { background: #FEF2F2; color: #B91C1C; border: 1px solid #FECACA; }
.alert-success { background: #F0FDF4; color: #15803D; border: 1px solid #BBF7D0; }

/* IDEA FORM */
.idea-form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px;
  box-shadow: 0 4px 24px var(--shadow);
}
.idea-form-card h2 {
  font-family: 'Bebas Neue', cursive;
  font-size: 32px;
  color: var(--text);
  margin-bottom: 8px;
}
.idea-form-card .subtitle {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 32px;
}
.form-row { display: grid; gap: 20px; }
.form-row-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 600px) { .form-row-2 { grid-template-columns: 1fr; } }
.ai-hint {
  font-size: 12px;
  color: var(--muted);
  background: var(--deep);
  border-radius: 8px;
  padding: 8px 12px;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ai-hint svg { color: var(--primary); flex-shrink: 0; }

/* IDEA DETAIL */
.idea-detail-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px 36px;
  margin-bottom: 28px;
  box-shadow: 0 2px 12px var(--shadow);
}
.idea-detail-title {
  font-family: 'Bebas Neue', cursive;
  font-size: 36px;
  color: var(--text);
  margin-bottom: 12px;
}
.idea-detail-meta {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted);
}
.idea-detail-meta strong { color: var(--text); }

/* TABS */
.tabs-nav {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}
.tabs-nav button {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  padding: 10px 20px;
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.tabs-nav button:hover { color: var(--text); }
.tabs-nav button.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: block; }
.tab-panel.hidden { display: none; }

/* ASSET CARDS */
.assets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}
.script-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 2px 12px var(--shadow);
}
.script-header, .asset-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.asset-date { font-size: 12px; color: var(--muted); }
.script-content {
  padding: 20px;
  max-height: 200px;
  overflow-y: auto;
}
.script-content pre {
  font-size: 12px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
  margin: 0;
  font-family: 'Plus Jakarta Sans', sans-serif;
}
.script-actions, .asset-actions {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
}
.btn-copy {
  background: var(--deep);
  color: var(--text);
  font-size: 12px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 500;
  transition: background 0.15s;
}
.btn-copy:hover { background: var(--border); }

.image-card .asset-preview img,
.video-card .asset-preview {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  display: block;
  border-radius: 0;
  background: var(--deep);
}
.video-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  aspect-ratio: 16/9;
  background: var(--deep);
}
.video-play-icon { color: var(--muted); }
.video-placeholder p { font-size: 13px; color: var(--muted); margin: 0; }
.video-status { font-size: 12px; color: var(--muted); }

/* GENERATE BUTTONS */
.generate-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

/* EMPTY STATES */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--muted);
}
.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.4;
}
.empty-state h3 {
  font-family: 'Bebas Neue', cursive;
  font-size: 24px;
  color: var(--text);
  margin-bottom: 8px;
}
.empty-state p { font-size: 14px; margin-bottom: 24px; }

/* PORTAL FOOTER */
.portal-footer {
  border-top: 1px solid var(--border);
  padding: 24px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

/* RESPONSIVE */
@media (max-width: 600px) {
  .portal-header { padding: 0 16px; }
  .portal-main { padding: 24px 16px 60px; }
  .page-header { flex-direction: column; }
  .stats-bar { flex-wrap: wrap; gap: 16px; }
  .stat-item { min-width: 80px; }
  .auth-card { padding: 32px 24px; }
  .idea-form-card { padding: 24px 20px; }
  .idea-detail-header { padding: 24px 20px; }
}