/**
 * AI Design Generator — Complete Pro & Standard Front-end Styles
 *
 * @package AI_Design_Generator
 */

/* ─── Variables (Combined & Upgraded) ──────────────────────── */
:root {
  /* Core Colors */
  --aidg-bg: #f8fafc;
  --aidg-surface: #ffffff;
  --aidg-surface-alt: #f8f7fc;
  
  /* Sidebar (Dark Mode) */
  --aidg-sidebar: #1e293b;
  --aidg-sidebar-text: #f1f5f9;
  --aidg-sidebar-border: #334155;
  
  /* Borders & Accents */
  --aidg-border: #e2e8f0;
  --aidg-primary: #3b82f6;
  --aidg-primary-hover: #2563eb;
  --aidg-primary-light: #eff6ff;
  --aidg-accent: #3b82f6;
  
  /* Status Colors */
  --aidg-success: #10b981;
  --aidg-error: #ef4444;
  
  /* Text Colors */
  --aidg-text: #0f172a;
  --aidg-text-muted: #64748b;
  
  /* Layout & Sizing */
  --aidg-radius: 12px;
  --aidg-radius-sm: 8px;
  
  /* Shadows */
  --aidg-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  --aidg-shadow-lg: 0 8px 32px rgba(15, 23, 42, 0.12);
  
  /* Typography */
  --aidg-font: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ─── Containers ───────────────────────────────────────────── */
.aidg-generator {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
  font-family: var(--aidg-font);
  color: var(--aidg-text);
}

.aidg-generator-pro {
  font-family: var(--aidg-font);
  color: var(--aidg-text);
  max-width: 1200px;
  margin: 0 auto;
}

/* ─── Dashboard Layout (Pro) ───────────────────────────────── */
.aidg-dashboard-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 30px;
  margin-bottom: 40px;
  align-items: start;
}

@media (max-width: 768px) {
  .aidg-dashboard-layout { 
    grid-template-columns: 1fr; 
  }
}

/* ─── Usage Bar ────────────────────────────────────────────── */
.aidg-usage-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 20px;
  background: var(--aidg-surface-alt);
  border: 1px solid var(--aidg-border);
  border-radius: var(--aidg-radius);
  margin-bottom: 24px;
  font-size: 13px;
  color: var(--aidg-text-muted);
}

.aidg-credits-badge {
  background: var(--aidg-primary-light);
  color: var(--aidg-primary);
  padding: 2px 10px;
  border-radius: 20px;
  font-weight: 600;
}

/* ─── Panels & Cards ───────────────────────────────────────── */
/* Dark Sidebar Panel */
.aidg-panel-sidebar {
  background: var(--aidg-sidebar);
  color: var(--aidg-sidebar-text);
  border-radius: var(--aidg-radius);
  padding: 24px;
  box-shadow: var(--aidg-shadow);
}

.aidg-sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--aidg-sidebar-border);
}

.aidg-sidebar-header h4 { 
  margin: 0; 
  font-size: 16px; 
  font-weight: 600; 
  color: #fff; 
}

.aidg-badge-hd {
  background: rgba(59, 130, 246, 0.2); 
  color: #60a5fa;
  font-size: 11px; 
  font-weight: 700;
  padding: 4px 8px; 
  border-radius: 4px; 
  text-transform: uppercase;
  border: 1px solid #3b82f6;
}

/* Central Canvas Area */
.aidg-canvas-card {
  background: var(--aidg-surface);
  border: 1px solid var(--aidg-border);
  border-radius: var(--aidg-radius);
  padding: 30px;
  box-shadow: var(--aidg-shadow);
  margin-bottom: 30px;
}

.aidg-form-card {
  background: var(--aidg-surface);
  border: 1px solid var(--aidg-border);
  border-radius: var(--aidg-radius);
  padding: 28px;
  box-shadow: var(--aidg-shadow);
  margin-bottom: 32px;
}

/* ─── Forms & Inputs ───────────────────────────────────────── */
.aidg-form-group { 
  margin-bottom: 20px; 
}

.aidg-form-group label { 
  display: block; 
  font-size: 14px; 
  font-weight: 600; 
  margin-bottom: 8px; 
}

.aidg-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 540px) {
  .aidg-form-row {
    grid-template-columns: 1fr;
  }
}

/* Universal Inputs */
.aidg-form-group textarea,
.aidg-form-group select,
.aidg-form-group input[type="text"],
/* Update the general input class to have better line-height */
.aidg-input {
  width: 100%; 
  padding: 12px 14px; /* Slightly reduced top/bottom padding */
  font-family: var(--aidg-font); 
  font-size: 14px;
  line-height: 1.5; /* Ensure text isn't cramped */
  border: 1px solid var(--aidg-border); 
  border-radius: var(--aidg-radius-sm);
  background: var(--aidg-bg); 
  color: var(--aidg-text); 
  transition: all 0.2s;
  box-sizing: border-box;
}

/* Add this NEW rule specifically for dropdowns to fix the cut-off text */
select.aidg-input {
  height: auto;
  min-height: 48px; /* Force enough height for the text to fit */
}

.aidg-form-group textarea:focus,
.aidg-form-group select:focus,
.aidg-input:focus { 
  outline: none; 
  border-color: var(--aidg-primary); 
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15); 
}

.aidg-form-group textarea,
.aidg-prompt-box { 
  resize: vertical; 
  min-height: 120px; 
  font-size: 15px; 
  line-height: 1.6; 
}

/* Sidebar Specific Inputs */
.aidg-panel-sidebar .aidg-form-group label {
  color: #cbd5e1;
}

.aidg-panel-sidebar .aidg-input {
  background: #0f172a;
  color: #fff;
  border: 1px solid var(--aidg-sidebar-border);
}

.aidg-panel-sidebar .aidg-input:focus {
  border-color: var(--aidg-primary);
}

/* Radio & Custom Dimensions */
.aidg-radio-group { 
  display: flex; 
  gap: 15px; 
  margin-bottom: 10px; 
}

.aidg-radio-label { 
  display: flex; 
  align-items: center; 
  gap: 6px; 
  font-size: 13px; 
  cursor: pointer; 
  color: #94a3b8; 
}

.aidg-custom-dimensions { 
  display: flex; 
  align-items: center; 
  gap: 10px; 
}

.aidg-dim-input label { 
  font-size: 11px; 
  color: #94a3b8; 
  margin-bottom: 4px; 
}

.aidg-dim-icon { 
  color: #94a3b8; 
  font-weight: bold; 
  margin-top: 18px; 
}

/* Templates Grid */
.aidg-template-grid { 
  display: grid; 
  grid-template-columns: 1fr; 
  gap: 8px; 
}

.aidg-tpl-btn {
  background: #0f172a; 
  border: 1px solid var(--aidg-sidebar-border);
  padding: 10px; 
  border-radius: var(--aidg-radius-sm); 
  font-size: 13px;
  text-align: left; 
  cursor: pointer; 
  transition: all 0.2s; 
  color: #cbd5e1;
}

.aidg-tpl-btn:hover { 
  border-color: var(--aidg-primary); 
  background: #1e3a8a; 
  color: #fff; 
}

/* ─── Upload Area ──────────────────────────────────────────── */
.aidg-upload-area {
  position: relative;
  border: 2px dashed var(--aidg-border);
  border-radius: var(--aidg-radius);
  padding: 24px;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
  cursor: pointer;
  background: var(--aidg-bg);
}

.aidg-upload-area:hover,
.aidg-upload-area.aidg-drag-over {
  border-color: var(--aidg-primary);
  background: var(--aidg-primary-light);
}

.aidg-upload-area input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.aidg-upload-placeholder .dashicons {
  font-size: 36px;
  width: 36px;
  height: 36px;
  color: var(--aidg-primary);
  margin-bottom: 8px;
}

.aidg-upload-placeholder p {
  margin: 0 0 4px;
  font-weight: 600;
  font-size: 14px;
}

.aidg-upload-placeholder small {
  color: var(--aidg-text-muted);
  font-size: 12px;
}

.aidg-upload-preview {
  position: relative;
  display: inline-block;
}

.aidg-upload-preview img {
  max-height: 120px;
  border-radius: var(--aidg-radius-sm);
  border: 1px solid var(--aidg-border);
}

#aidg-remove-ref {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--aidg-error);
  color: #fff;
  border: none;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ─── Buttons ──────────────────────────────────────────────── */
.aidg-btn {
  display: inline-flex; 
  align-items: center; 
  justify-content: center; 
  gap: 8px;
  padding: 14px 24px; 
  font-size: 15px; 
  font-weight: 600; 
  border: none;
  border-radius: var(--aidg-radius-sm); 
  cursor: pointer; 
  text-decoration: none;
  transition: all 0.2s;
}

.aidg-btn-block { 
  width: 100%; 
  padding: 16px; 
  font-size: 16px; 
}

.aidg-btn-primary { 
  background: var(--aidg-primary); 
  color: #fff; 
}

.aidg-btn-primary:hover { 
  background: var(--aidg-primary-hover); 
  transform: translateY(-1px); 
}

.aidg-btn-primary:disabled { 
  opacity: 0.7; 
  cursor: not-allowed; 
  transform: none; 
}

.aidg-btn-secondary {
  background: var(--aidg-surface-alt);
  color: var(--aidg-text);
  border: 1px solid var(--aidg-border);
}

.aidg-btn-secondary:hover {
  background: var(--aidg-border);
}

.aidg-btn-success { 
  background: var(--aidg-success); 
  color: #fff; 
}

.aidg-btn-success:hover { 
  background: #059669; 
}

.aidg-btn-small { 
  padding: 8px 16px; 
  font-size: 13px; 
}

/* ─── Spinner ──────────────────────────────────────────────── */
.aidg-spinner {
  display: inline-block; 
  width: 18px; 
  height: 18px;
  border: 2.5px solid rgba(255,255,255,0.3); 
  border-top-color: #fff;
  border-radius: 50%; 
  animation: aidg-spin 0.8s linear infinite;
}

@keyframes aidg-spin { 
  to { transform: rotate(360deg); } 
}

/* ─── Status Messages ──────────────────────────────────────── */
.aidg-status { 
  margin-top: 16px; 
  padding: 14px; 
  border-radius: var(--aidg-radius-sm); 
  font-size: 14px; 
  text-align: center; 
  font-weight: 500;
}

.aidg-status-error { 
  background: #fef2f2; 
  color: #dc2626; 
  border: 1px solid #fecaca; 
}

.aidg-status-success {
  background: #ecfdf5;
  color: var(--aidg-success);
  border: 1px solid #a7f3d0;
}

/* ─── Result Areas ─────────────────────────────────────────── */
.aidg-result,
.aidg-result-card {
  background: var(--aidg-surface); 
  border: 1px solid var(--aidg-border);
  border-radius: var(--aidg-radius); 
  padding: 30px; 
  box-shadow: var(--aidg-shadow);
  margin-bottom: 30px;
}

.aidg-result {
  text-align: center;
}

.aidg-result-header { 
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
  margin-bottom: 20px; 
}

.aidg-result h3,
.aidg-result-header h3 { 
  margin: 0; 
  font-size: 20px; 
  color: var(--aidg-text); 
}

.aidg-result-image img,
.aidg-result-image-wrapper img { 
  width: 100%; 
  max-width: 100%;
  border-radius: var(--aidg-radius-sm); 
  border: 1px solid var(--aidg-border); 
  box-shadow: var(--aidg-shadow);
}

.aidg-result-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 20px;
}

/* ─── History / Portfolio ──────────────────────────────────── */
.aidg-history {
  margin-top: 8px;
}

.aidg-history h3 {
  font-size: 18px;
  margin-bottom: 16px;
}

.aidg-portfolio-section { 
  margin-top: 20px; 
}

.aidg-portfolio-header { 
  margin-bottom: 20px; 
}

.aidg-portfolio-header h3 { 
  margin: 0; 
  font-size: 18px; 
}

.aidg-portfolio-header p { 
  margin: 4px 0 0; 
  color: var(--aidg-text-muted); 
  font-size: 14px; 
}

/* ─── Compact History / Portfolio Grid ─────────────────────── */
.aidg-history-grid {
  display: grid; 
  /* Changed from 180px to 130px to make images smaller and fit more per row */
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); 
  gap: 12px;
  margin-top: 20px;
}

.aidg-history-item {
  position: relative; 
  border-radius: var(--aidg-radius-sm); 
  overflow: hidden;
  border: 1px solid var(--aidg-border); 
  background: var(--aidg-surface);
  aspect-ratio: 1; /* Keeps images perfectly square */
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
}

.aidg-history-item:hover {
  transform: translateY(-3px);
  box-shadow: var(--aidg-shadow-lg);
  border-color: var(--aidg-primary);
}

.aidg-history-item img { 
  width: 100%; 
  height: 100%; 
  object-fit: cover; 
  display: block; 
}

/* Make the download button overlay more elegant */
.aidg-history-overlay {
  position: absolute; 
  inset: 0; 
  background: rgba(15, 23, 42, 0.75); 
  display: flex;
  align-items: center; 
  justify-content: center; 
  opacity: 0; 
  transition: opacity 0.2s ease-in-out;
  backdrop-filter: blur(2px);
}

.aidg-history-item:hover .aidg-history-overlay { 
  opacity: 1; 
}

.aidg-history-overlay .aidg-btn {
  transform: translateY(10px);
  transition: transform 0.2s;
}

.aidg-history-item:hover .aidg-history-overlay .aidg-btn {
  transform: translateY(0);
}

.aidg-history-prompt {
  padding: 8px 10px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.9);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(15, 23, 42, 0.9);
}

.aidg-empty,
.aidg-empty-portfolio {
  padding: 30px; 
  text-align: center; 
  color: var(--aidg-text-muted); 
  background: var(--aidg-surface); 
  border-radius: var(--aidg-radius); 
  border: 1px dashed var(--aidg-border);
  font-size: 14px;
}

/* ─── Pagination ───────────────────────────────────────────── */
.aidg-pagination {
  display: flex; 
  flex-wrap: wrap; 
  justify-content: center; 
  gap: 8px; 
  margin-top: 40px; 
  padding-top: 24px; 
  border-top: 1px solid var(--aidg-border);
}

.aidg-pagination a, 
.aidg-pagination span.page-numbers {
  display: inline-flex; 
  align-items: center; 
  justify-content: center; 
  min-width: 40px; 
  height: 40px; 
  padding: 0 12px;
  border-radius: var(--aidg-radius-sm); 
  border: 1px solid var(--aidg-border); 
  background: var(--aidg-surface);
  color: var(--aidg-text); 
  font-size: 14px; 
  font-weight: 600; 
  text-decoration: none; 
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.aidg-pagination a:hover { 
  border-color: var(--aidg-primary); 
  color: var(--aidg-primary); 
  background: var(--aidg-primary-light); 
  transform: translateY(-1px);
}

.aidg-pagination span.current { 
  background: var(--aidg-primary); 
  color: #fff; 
  border-color: var(--aidg-primary); 
  box-shadow: 0 4px 10px rgba(59, 130, 246, 0.3);
}

/* ─── Login Notice ─────────────────────────────────────────── */
.aidg-login-notice {
  text-align: center;
  padding: 48px 24px;
  background: var(--aidg-surface-alt);
  border-radius: var(--aidg-radius);
  border: 1px solid var(--aidg-border);
}

.aidg-login-notice p {
  margin-bottom: 16px;
  font-size: 16px;
  color: var(--aidg-text-muted);
}
/* ─── V2 Additions: Model Selector & Capabilities ─────────── */

.aidg-model-desc {
    font-size: 12px;
    color: var(--aidg-text-muted, #888);
    margin-top: 6px;
    line-height: 1.4;
}

.aidg-capabilities {
    margin-top: 16px;
}

.aidg-cap-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.aidg-cap-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    background: rgba(99, 102, 241, 0.1);
    color: #6366f1;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.aidg-cap-realistic { background: rgba(16, 185, 129, 0.1); color: #059669; border-color: rgba(16, 185, 129, 0.2); }
.aidg-cap-humans { background: rgba(245, 158, 11, 0.1); color: #d97706; border-color: rgba(245, 158, 11, 0.2); }
.aidg-cap-animals { background: rgba(139, 92, 246, 0.1); color: #7c3aed; border-color: rgba(139, 92, 246, 0.2); }
.aidg-cap-products { background: rgba(59, 130, 246, 0.1); color: #2563eb; border-color: rgba(59, 130, 246, 0.2); }
.aidg-cap-text_render { background: rgba(236, 72, 153, 0.1); color: #db2777; border-color: rgba(236, 72, 153, 0.2); }
.aidg-cap-edit { background: rgba(20, 184, 166, 0.1); color: #0d9488; border-color: rgba(20, 184, 166, 0.2); }

.aidg-ref-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 500;
    color: #059669;
    background: rgba(16, 185, 129, 0.1);
    padding: 2px 8px;
    border-radius: 12px;
    margin-left: 8px;
}

.aidg-ref-no-support p {
    font-size: 12px;
    color: #d97706;
    background: rgba(245, 158, 11, 0.08);
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid rgba(245, 158, 11, 0.15);
    margin-top: 8px;
}

.aidg-prompt-hint {
    font-size: 12px;
    color: var(--aidg-text-muted, #888);
    margin-top: 6px;
}

.aidg-model-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 16px;
    background: rgba(99, 102, 241, 0.1);
    color: #6366f1;
    margin-right: 8px;
}

/* ─── Image Preview Lightbox ───────────────────────────────── */
.aidg-lightbox {
    position: fixed;
    z-index: 999999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

.aidg-lightbox.aidg-lightbox-active {
    opacity: 1;
    visibility: visible;
}

.aidg-lightbox img {
    max-width: 90%;
    max-height: 90vh;
    border-radius: var(--aidg-radius-sm);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    transform: scale(0.95);
    transition: transform 0.2s;
}

.aidg-lightbox.aidg-lightbox-active img {
    transform: scale(1);
}

.aidg-lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #fff;
    font-size: 40px;
    font-weight: 300;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.aidg-lightbox-close:hover {
    color: var(--aidg-primary);
}

/* Container to hold the prompt and the copy button */
.aidg-lightbox-prompt-container {
    position: relative;
    margin-top: 16px;
    max-width: 800px;
    width: 90%;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease 0.1s, transform 0.3s ease 0.1s;
}

.aidg-lightbox.aidg-lightbox-active .aidg-lightbox-prompt-container {
    opacity: 1;
    transform: translateY(0);
}

/* Style the Prompt text box */
.aidg-lightbox-prompt {
    color: #e2e8f0 !important;
    background: rgba(15, 23, 42, 0.8) !important;
    /* Added box-sizing so the right padding perfectly protects the text from the button */
    box-sizing: border-box !important;
    padding: 14px 55px 14px 20px !important; 
    border-radius: var(--aidg-radius-sm) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    font-size: 14px !important;
    line-height: 1.6 !important;
    text-align: center !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3) !important;
    margin: 0 !important;
    word-wrap: break-word !important;
    width: 100% !important;
}

/* Copy Button Styling - Theme Override */
.aidg-copy-btn {
    position: absolute !important;
    top: 50% !important;
    right: 8px !important;
    transform: translateY(-50%) !important;
    background: rgba(255, 255, 255, 0.15) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    width: 38px !important;
    height: 38px !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    box-shadow: none !important;
    outline: none !important;
    transition: all 0.2s ease !important;
}

.aidg-copy-btn:hover {
    background: rgba(255, 255, 255, 0.3) !important;
}

/* Force the SVG icon to appear correctly */
.aidg-copy-btn svg {
    width: 18px !important;
    height: 18px !important;
    display: block !important;
    stroke: #ffffff !important; /* Forces the icon to be bright white */
    fill: none !important;
}

/* "Copied!" Feedback Bubble */
.aidg-copy-feedback {
    position: absolute !important;
    top: -30px !important;
    right: 0 !important;
    background: var(--aidg-success) !important;
    color: #fff !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    padding: 4px 10px !important;
    border-radius: 4px !important;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s !important;
    pointer-events: none !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2) !important;
}

.aidg-copy-feedback.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(-5px) !important;
}