/* Arts Engine — Custom Styles
   Supplements localsite/css/base.css
   Uses CSS variables for dark mode compatibility */

/* =========================================================
   Layout
   ========================================================= */

.ae-container {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  width: 100%;
}

.ae-left {
  flex: 65;
  min-width: 300px;
}

.ae-right {
  flex: 35;
  min-width: 260px;
  container-type: inline-size;
}

@media (max-width: 767px) {
  .ae-container {
    flex-direction: column;
  }
  .ae-right {
    order: -1; /* GitHub token widget first on mobile */
  }
}

/* =========================================================
   Panels
   ========================================================= */

.ae-panel {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  position: relative;
}

.ae-panel h3 {
  margin: 0 0 14px 0;
  font-size: 0.95rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #555;
}

.dark .ae-panel {
  background: #2a2a2a;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

.dark .ae-panel h3 {
  color: #aaa;
}

/* =========================================================
   Prompt Input
   ========================================================= */

#promptInput {
  width: 100%;
  min-height: 110px;
  padding: 12px 14px;
  border: 1.5px solid #ddd;
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
  box-sizing: border-box;
  transition: border-color 0.2s;
  background: #fafafa;
  color: #222;
}

#promptInput:focus {
  outline: none;
  border-color: #4a90e2;
  background: #fff;
}

.dark #promptInput {
  background: #1e1e1e;
  border-color: #444;
  color: #e0e0e0;
}

.dark #promptInput:focus {
  border-color: #6aacf5;
  background: #222;
}

/* =========================================================
   CSV Upload
   ========================================================= */

.ae-csv-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.ae-csv-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1.5px dashed #bbb;
  border-radius: 8px;
  background: transparent;
  color: #666;
  cursor: pointer;
  font-size: 0.88rem;
  transition: all 0.2s;
}

.ae-csv-btn:hover {
  border-color: #4a90e2;
  color: #4a90e2;
  background: rgba(74,144,226,0.05);
}

.dark .ae-csv-btn {
  border-color: #555;
  color: #aaa;
}

.dark .ae-csv-btn:hover {
  border-color: #6aacf5;
  color: #6aacf5;
}

.ae-csv-name {
  font-size: 0.85rem;
  color: #888;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dark .ae-csv-name { color: #777; }

/* =========================================================
   Loaded Prompts List
   ========================================================= */

#promptList {
  margin-top: 12px;
  max-height: 220px;
  overflow-y: auto;
}

.prompt-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  margin-bottom: 4px;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 0.88rem;
  border: 1px solid transparent;
}

.prompt-item:hover {
  background: rgba(74,144,226,0.08);
  border-color: rgba(74,144,226,0.2);
}

.prompt-item.selected {
  background: rgba(74,144,226,0.12);
  border-color: rgba(74,144,226,0.3);
}

.dark .prompt-item:hover,
.dark .prompt-item.selected {
  background: rgba(106,172,245,0.1);
  border-color: rgba(106,172,245,0.2);
}

.prompt-item-num {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #e8edf5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: #555;
}

.dark .prompt-item-num {
  background: #3a3a3a;
  color: #aaa;
}

.prompt-item-text {
  flex: 1;
  line-height: 1.4;
  color: #333;
}

.dark .prompt-item-text { color: #ccc; }

.prompt-item-industry {
  font-size: 0.78rem;
  color: #888;
  margin-top: 2px;
}

/* =========================================================
   Aspect Ratio Selector
   ========================================================= */

.ae-ratio-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.ae-ratio-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border: 1.5px solid #ddd;
  border-radius: 10px;
  background: #fafafa;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 64px;
}

.ae-ratio-btn:hover {
  border-color: #4a90e2;
  background: rgba(74,144,226,0.05);
}

.ae-ratio-btn.active {
  border-color: #4a90e2;
  background: rgba(74,144,226,0.1);
}

.dark .ae-ratio-btn {
  background: #1e1e1e;
  border-color: #444;
}

.dark .ae-ratio-btn:hover,
.dark .ae-ratio-btn.active {
  border-color: #6aacf5;
  background: rgba(106,172,245,0.1);
}

/* Visual ratio indicator box */
.ratio-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.ratio-box {
  background: #ccd9ee;
  border-radius: 3px;
}

.dark .ratio-box {
  background: #3a5a8a;
}

.ae-ratio-btn.active .ratio-box {
  background: #4a90e2;
}

.dark .ae-ratio-btn.active .ratio-box {
  background: #6aacf5;
}

.ratio-label {
  font-size: 0.75rem;
  color: #666;
  font-weight: 500;
  white-space: nowrap;
}

.dark .ratio-label { color: #aaa; }

.ae-ratio-btn.active .ratio-label {
  color: #4a90e2;
}

.dark .ae-ratio-btn.active .ratio-label {
  color: #6aacf5;
}

/* =========================================================
   Output Type + Model Selector
   ========================================================= */

.ae-type-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.ae-type-btn {
  padding: 7px 16px;
  border: 1.5px solid #ddd;
  border-radius: 20px;
  background: transparent;
  color: #555;
  cursor: pointer;
  font-size: 0.88rem;
  transition: all 0.2s;
}

.ae-type-btn:hover:not(.disabled):not(.active) {
  border-color: #4a90e2;
  color: #4a90e2;
}

.ae-type-btn.active {
  border-color: #4a90e2;
  background: #4a90e2;
  color: #fff;
}

.ae-type-btn.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.dark .ae-type-btn {
  border-color: #444;
  color: #aaa;
}

.dark .ae-type-btn.active {
  background: #4a7fc2;
  border-color: #4a7fc2;
  color: #fff;
}

.ae-model-select {
  padding: 7px 10px;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  background: #fafafa;
  color: #333;
  font-size: 0.88rem;
  cursor: pointer;
}

.dark .ae-model-select {
  background: #1e1e1e;
  border-color: #444;
  color: #ddd;
}

/* =========================================================
   Generate Button
   ========================================================= */

#generateBtn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 28px;
  background: linear-gradient(135deg, #4a90e2 0%, #5ba3f5 100%);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(74,144,226,0.35);
}

#generateBtn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(74,144,226,0.45);
}

#generateBtn:active {
  transform: translateY(0);
}

#generateBtn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

#generateBtn .material-icons {
  font-size: 1.1rem;
}

/* Variations input */
.ae-variations-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.ae-variations-row label {
  font-size: 0.88rem;
  color: #666;
}

.dark .ae-variations-row label { color: #aaa; }

#variationsInput {
  width: 60px;
  padding: 6px 8px;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  text-align: center;
  font-size: 0.9rem;
  background: #fafafa;
  color: #333;
}

.dark #variationsInput {
  background: #1e1e1e;
  border-color: #444;
  color: #ddd;
}

/* =========================================================
   Status / Progress
   ========================================================= */

#statusBar {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.88rem;
  display: none;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

#statusBar.show { display: flex; }

#statusBar.info {
  background: rgba(74,144,226,0.1);
  color: #2a6fc0;
  border: 1px solid rgba(74,144,226,0.2);
}

#statusBar.success {
  background: rgba(40,167,69,0.1);
  color: #1a7a35;
  border: 1px solid rgba(40,167,69,0.2);
}

#statusBar.error {
  background: rgba(220,53,69,0.1);
  color: #a52030;
  border: 1px solid rgba(220,53,69,0.2);
}

.dark #statusBar.info {
  background: rgba(106,172,245,0.12);
  color: #90c2f8;
}

.dark #statusBar.success {
  background: rgba(80,200,100,0.12);
  color: #5fd880;
}

.dark #statusBar.error {
  background: rgba(240,80,90,0.12);
  color: #f07080;
}

/* Spinner */
.ae-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: ae-spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes ae-spin {
  to { transform: rotate(360deg); }
}

/* =========================================================
   Storyboard Flowchart
   ========================================================= */

#storyboardContainer {
  min-height: 160px;
  overflow-x: auto;
  padding: 10px 0;
  position: relative;
}

.ae-flow-wrapper {
  display: flex;
  align-items: flex-start;
  gap: 0;
  flex-wrap: wrap;
  position: relative;
}

.ae-scene-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.ae-node-card {
  width: 150px;
  min-height: 120px;
  border: 2px solid #dde4f0;
  border-radius: 10px;
  background: #f7f9fc;
  padding: 10px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
}

.ae-node-card:hover {
  border-color: #4a90e2;
  box-shadow: 0 2px 10px rgba(74,144,226,0.2);
  transform: translateY(-2px);
}

.ae-node-card.active {
  border-color: #4a90e2;
  background: rgba(74,144,226,0.06);
}

.dark .ae-node-card {
  background: #252525;
  border-color: #3a3a3a;
}

.dark .ae-node-card:hover,
.dark .ae-node-card.active {
  border-color: #6aacf5;
  background: rgba(106,172,245,0.08);
}

.ae-node-num {
  font-size: 0.72rem;
  font-weight: 700;
  color: #4a90e2;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.dark .ae-node-num { color: #6aacf5; }

.ae-node-thumb {
  width: 100%;
  height: 70px;
  object-fit: cover;
  border-radius: 6px;
  background: #e0e8f5;
}

.dark .ae-node-thumb { background: #333; }

.ae-node-prompt {
  font-size: 0.75rem;
  color: #555;
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.dark .ae-node-prompt { color: #aaa; }

.ae-node-label {
  font-size: 0.7rem;
  color: #888;
  margin-top: 2px;
}

/* Arrow connector between nodes */
.ae-node-arrow {
  display: flex;
  align-items: center;
  padding: 0 4px;
  margin-top: 48px; /* center vertically with node */
  color: #c0cbd8;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.dark .ae-node-arrow { color: #444; }

/* Add scene button */
.ae-add-scene-btn {
  width: 44px;
  height: 44px;
  border: 2px dashed #ccc;
  border-radius: 10px;
  background: transparent;
  color: #aaa;
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  margin-top: 48px;
  margin-left: 8px;
  flex-shrink: 0;
}

.ae-add-scene-btn:hover {
  border-color: #4a90e2;
  color: #4a90e2;
  background: rgba(74,144,226,0.05);
}

.dark .ae-add-scene-btn {
  border-color: #444;
  color: #555;
}

.dark .ae-add-scene-btn:hover {
  border-color: #6aacf5;
  color: #6aacf5;
}

/* Empty state */
.ae-flow-empty {
  text-align: center;
  padding: 30px 20px;
  color: #aaa;
  font-size: 0.88rem;
}

.dark .ae-flow-empty { color: #666; }

/* =========================================================
   Gallery
   ========================================================= */

#galleryPanel {
  display: none;
}

#galleryPanel.show {
  display: block;
}

.ae-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}

.ae-gallery-item {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 1;
  background: #e8edf5;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.ae-gallery-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}

.ae-gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.dark .ae-gallery-item {
  background: #333;
}

.ae-gallery-item .ae-item-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 8px 10px;
  background: linear-gradient(transparent, rgba(0,0,0,0.65));
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.2s;
}

.ae-gallery-item:hover .ae-item-overlay {
  opacity: 1;
}

.ae-item-btn {
  padding: 4px 10px;
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: 5px;
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.15s;
}

.ae-item-btn:hover {
  background: rgba(255,255,255,0.3);
}

/* Text output */
.ae-text-output {
  background: #f7f9fc;
  border: 1px solid #e0e8f5;
  border-radius: 10px;
  padding: 16px;
  font-size: 0.92rem;
  line-height: 1.65;
  white-space: pre-wrap;
  color: #333;
  margin-top: 4px;
}

.dark .ae-text-output {
  background: #1e1e1e;
  border-color: #333;
  color: #ddd;
}

/* =========================================================
   Settings Panel (right column)
   ========================================================= */

.ae-settings-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ae-settings-row label {
  font-size: 0.88rem;
  color: #555;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dark .ae-settings-row label { color: #aaa; }

/* =========================================================
   Save to GitHub
   ========================================================= */

#saveGithubBtn {
  display: none;
  width: 100%;
  padding: 10px;
  background: #2da44e;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 10px;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

#saveGithubBtn:hover { background: #218838; }

#saveGithubBtn.show {
  display: flex;
}

/* =========================================================
   Backend status indicator
   ========================================================= */

.ae-backend-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: #888;
  padding: 4px 0;
}

.ae-backend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ccc;
}

.ae-backend-dot.online { background: #28a745; }
.ae-backend-dot.offline { background: #dc3545; }
.ae-backend-dot.checking {
  background: #ffc107;
  animation: ae-pulse 1s ease-in-out infinite;
}

@keyframes ae-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* =========================================================
   Lightbox / full image overlay
   ========================================================= */

.ae-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.ae-lightbox.show { display: flex; }

.ae-lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.6);
}

.ae-lightbox-close {
  position: fixed;
  top: 20px;
  right: 24px;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
  opacity: 0.8;
}

.ae-lightbox-close:hover { opacity: 1; }

/* =========================================================
   Responsive tweaks
   ========================================================= */

@container (max-width: 280px) {
  .ae-ratio-group {
    gap: 6px;
  }
  .ae-ratio-btn {
    min-width: 52px;
    padding: 8px;
  }
}
