body {
  margin: 0;
  font-family: system-ui, sans-serif;
  background: #0f0f0f;
  color: #fff;
}

/* layout */

.layout {
  display: flex;
}

.container {
  max-width: 800px;
  margin: auto;
  padding: 2rem;
}

h1 {
  font-weight: 400;
}

.section {
  margin-bottom: 1.5rem;
}

.divider {
  border: none;
  border-top: 1px solid #333;
  margin: 2.5rem 0;
}

/* inputs */

textarea {
  width: 100%;
  min-height: 120px;
  padding: 1rem;
  margin-bottom: 2rem;
  background: #1a1a1a;
  color: #fff;
  border: 1px solid #333;
  border-radius: 6px;
}

/* ================= */
/* GLOBAL BUTTONS */
/* ================= */

button {
  background: #1f1f1f;
  border: 1px solid #3a3a3a;
  color: #e5e5e5;
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
  transition: all .15s ease;
}

button:hover {
  background: #2a2a2a;
  border-color: #555;
  color: #fff;
}

button:active {
  transform: scale(.96);
}

button:disabled {
  opacity: .5;
  cursor: default;
}

/* option buttons */

.options button {
  margin: .3rem;
  padding: .6rem 1rem;
}

.options button.active {
  background: #fff;
  color: #000;
}

/* ================= */
/* SIDEBAR */
/* ================= */

.sidebar {
  width: 220px;
  background: #111;
  padding: 1rem;
  border-right: 1px solid #222;
  min-height: 100vh;
}

.sidebar h2 {
  font-size: 1rem;
  margin-bottom: 1rem;
}

#project-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.project-item {
  padding: .5rem;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 4px;
  cursor: pointer;
}

.project-item:hover {
  background: #222;
}

.project-item.active {
  background: #fff;
  color: #000;
}

#new-project {
  margin-top: 1rem;
  width: 100%;
}

/* ================= */
/* SYSTEM CHECK */
/* ================= */

.system-check {
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

#backend-status {
  font-size: .9rem;
  opacity: .8;
}

/* ================= */
/* TIMELINE */
/* ================= */

.project-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.audio-toggle {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .9rem;
}

/*
#scene-strip {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding: 1rem 0;
}

.scene-thumb {
  min-width: 180px;
  cursor: pointer;
  position: relative;
}

.scene-thumb video {
  width: 100%;
  border-radius: 6px;
  border: 2px solid #333;
}

.scene-thumb.active video {
  border-color: #fff;
}
*/
#scene-strip {
  display: flex;
  flex-wrap: nowrap;
  gap: 1rem;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 1rem 0;
}

.scene-thumb {
  flex: 0 0 320px;
  width: 320px;
  min-width: 320px;
  max-width: 320px;
  cursor: pointer;
  position: relative;
}

/* placeholder video */
.scene-video-placeholder {
  width: 100%;
  height: 100%;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111;
  color: white;
  font-size: 24px;
  border-radius: 8px;
}

.scene-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scene-thumb video,
.scene-video,
.scene-video-placeholder {
  width: 100%;
  height: 100px;
  object-fit: cover;
  display: block;
  border-radius: 6px;
  border: 2px solid #333;
  box-sizing: border-box;
}

.scene-thumb.active video,
.scene-thumb.active .scene-video-placeholder {
  border-color: #fff;
}



.scene-thumb.dragging {
  opacity: .4;
  transform: scale(.98);
}

.scene-select {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 10;
}

.scene-badge {
  position: absolute;
  top: 6px;
  left: 36px;
  background: rgba(0,0,0,.7);
  padding: 2px 6px;
  font-size: .7rem;
  border-radius: 4px;
}

.thumb-controls {
  position: absolute;
  bottom: 6px;
  left: 6px;
  display: flex;
  gap: 4px;
}

.thumb-controls button {
  background: rgba(0,0,0,.7);
  border: none;
  font-size: .7rem;
  padding: 2px 5px;
  border-radius: 3px;
}

/* ================= */
/* TIMELINE TRACK */
/* ================= */

.timeline-container {
  margin-top: 20px;
  border-top: 1px solid #333;
  padding-top: 15px;
}

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

.timeline {
  background: #111;
  border: 1px solid #222;
  border-radius: 6px;
  padding: 10px;
}

.track {
  display: flex;
  align-items: center;
  height: 50px;
  background: #1b1b1b;
  border-radius: 4px;
  margin-bottom: 8px;
  overflow: hidden;
}

.track-label {
  width: 80px;
  font-size: 13px;
  color: #888;
  padding-left: 10px;
}

.track-content {
  flex: 1;
  position: relative;
  height: 100%;
}

.audio-bar {
  position: absolute;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg,#4CAF50,#2e7d32);
  border-radius: 3px;
  opacity: .9;
}

/* ================= */
/* ASSETS */
/* ================= */

.assets-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.asset-grid {
  margin-top: 15px;
  display: grid;
  grid-template-columns: repeat(auto-fill,minmax(180px,1fr));
  gap: 15px;
}

.asset-card {
  background: #111;
  border: 1px solid #222;
  border-radius: 8px;
  overflow: hidden;
  transition: .2s ease;
}

.asset-card:hover {
  transform: translateY(-4px);
  border-color: #444;
}

.asset-card img {
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.asset-footer {
  padding: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .85rem;
  opacity: .8;
  flex-wrap: wrap;
  gap: 4px;
}

.asset-footer button {
  padding: 4px 6px;
  font-size: 12px;
}

.asset-type-badge {
  flex-basis: 100%;
}

#open-asset-modal { border-color:#3a7cff; }
#upload-asset-btn { border-color:#9c5cff; }

/* ================= */
/* ASSET PREVIEW */
/* ================= */

.scene-asset-preview {
  display:flex;
  gap:10px;
  margin-top:10px;
}

.scene-asset-thumb {
  position:relative;
}

.scene-asset-thumb img {
  width:80px;
  height:80px;
  object-fit:cover;
  border-radius:6px;
}

.scene-asset-thumb button {
  position:absolute;
  top:-5px;
  right:-5px;
}


.scene-assets-panel {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #222;
}

.scene-assets-panel h3 {
  margin: 0 0 12px 0;
  font-size: 1rem;
}

.scene-asset-slots {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 12px;
}

.scene-asset-slot {
  min-height: 110px;
  background: #111;
  border: 1px dashed #333;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 10px;
}

.scene-asset-slot-label {
  font-size: 0.85rem;
  color: #888;
}
/* ================= */
/* MODAL */
/* ================= */

.asset-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

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

.asset-modal-content {
  background: #111;
  padding: 20px;
  width: 500px;
  border-radius: 10px;
  border: 1px solid #333;
}

.asset-type-select {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
}

.asset-type-select button.active {
  background: #444;
}

.asset-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ================= */
/* IMAGE PREVIEW */
/* ================= */

#image-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
}

.image-preview-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.85);
}

.image-preview-content {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#image-preview-img {
  max-width: 95%;
  max-height: 95%;
  object-fit: contain;
  border-radius: 8px;
}

#close-image-preview {
  position: absolute;
  top: 20px;
  right: 30px;
  background: none;
  border: none;
  color: #fff;
  font-size: 28px;
  cursor: pointer;
}

.hidden {
  display: none;
}

.container video {
  max-width: 420px;
  width: 100%;
  height: auto;
}


/* ================= */
/* FRAME MODAL */
/* ================= */

.modal-frame {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}

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

.modal-frame-content {
  background: #111;
  padding: 24px;
  width: 360px;
  border-radius: 10px;
  border: 1px solid #333;
  box-shadow: 0 10px 30px rgba(0,0,0,.6);
  text-align: center;
}

.modal-frame-actions {
  margin-top: 18px;
  display: flex;
  justify-content: center;
  gap: 10px;
}

.modal-frame-content label {
  display: block;
  margin: 10px 0;
  font-size: 14px;
}

.export-asset {
  opacity: 0.7;
}
.export-asset:hover {
  opacity: 1;
}


/* ================= */
/* COMPOSE MODAL */
/* ================= */

.compose-preview{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:15px;
  margin-bottom:15px;
}

.compose-preview img{
  width:80px;
  height:80px;
  object-fit:cover;
  border-radius:6px;
}

.compose-plus{
  font-size:24px;
  color:#aaa;
}


/* status globale */
.global-status {
  margin: 10px 0;
  padding: 10px;
  font-size: 13px;
  color: #ccc;
  background: rgba(0,0,0,0.4);
  border-radius: 6px;
  max-height: 120px;
  overflow-y: auto;
  font-family: monospace;
}

/* sezione asset scrollabile */
.asset-grid-wrapper {
  max-height: 400px;
  overflow-y: auto;
}




/* ===================================================== */
/* 🚪 LOGIN OVERLAY & BOX */
/* ===================================================== */

.login-overlay {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, #1a1a1a 0%, #0f0f0f 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000; /* Sopra a ogni modale */
}

.login-box {
  background: #111;
  padding: 3rem;
  border-radius: 12px;
  border: 1px solid #333;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  max-width: 400px;
  width: 90%;
}

.login-box h1 {
  margin: 0 0 0.5rem 0;
  font-size: 1.8rem;
  letter-spacing: -0.5px;
  color: #fff;
}

.login-box p {
  color: #888;
  font-size: 0.95rem;
  margin-bottom: 2rem;
  line-height: 1.5;
}

#google-login-btn {
  display: flex;
  justify-content: center;
  margin-top: 1rem;
}

/* Effetto fade-in quando appare */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-box {
  animation: fadeIn 0.5s ease-out;
}

/* ===================================================== */
/* 🚀 MAIN APP TRANSITION */
/* ===================================================== */

/* Per rendere l'apparizione dell'app più fluida */
#main-app {
  animation: fadeIn 0.8s ease-out;
}



/* ===================================================== */
/* chat */
/* ===================================================== */
.agent-conversation-section {
    width: 100%;
    margin-bottom: 20px;
    background: #1a1a1a;
    padding: 15px;
    border-radius: 10px;
}

/* Forza le card a stare una di fianco all'altra */
.chat-horizontal-strip {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;      /* Impedisce di andare a capo */
    gap: 15px;
    overflow-x: auto;       /* Solo scroll laterale */
    padding: 10px 0;
    scroll-behavior: smooth;
}

/* Card con larghezza fissa che non si restringe */
.chat-card {
    flex: 0 0 320px;        /* Larghezza fissa 320px, non si stringe */
    background: #252525;
    padding: 15px;
    border-radius: 8px;
    border-top: 4px solid #555;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.agent-card { border-top-color: #007bff; }
.user-card { border-top-color: #28a745; background: #1e1e1e; }

.card-role {
    font-size: 0.7rem;
    font-weight: bold;
    margin-bottom: 5px;
    opacity: 0.5;
}

/* Barra di scorrimento orizzontale sottile */
.chat-horizontal-strip::-webkit-scrollbar { height: 6px; }
.chat-horizontal-strip::-webkit-scrollbar-thumb { background: #444; border-radius: 10px; }

.agent-input-group { display: flex; gap: 10px; margin-top: 15px; }
.agent-input-group input { flex-grow: 1; padding: 10px; background: #000; border: 1px solid #333; color: white; }

.asset-ref-label {
  font-size: 11px;
  opacity: 0.9;
  padding: 5px 6px 2px 6px;
  line-height: 1.25;

  white-space: normal;
  overflow: hidden;
  text-overflow: unset;

  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;

  word-break: break-word;
}