@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  color-scheme: dark;
  --bg: #080808;
  --panel: transparent;
  --card-bg: #121212;
  --card-hover: #181818;
  --input-bg: #181818;
  --input-border: rgba(255, 255, 255, 0.06);
  --input-focus: rgba(255, 0, 51, 0.5);
  --text: #ffffff;
  --muted: #a7a7a7;
  --green: #ff0033; /* Crimson brand color */
  --shadow: rgba(0, 0, 0, 0.6) 0 16px 40px;
  --radius: 16px;
  --pill: 9999px;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 50% -100px, rgba(255, 0, 51, 0.15), transparent 45%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  grid-template-rows: auto 1fr;
  gap: 20px;
  padding: 20px;
  max-width: 1700px;
  margin: 0 auto;
}

.workspace-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.side-column {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-content: start;
}

/* Typography styles matching Spotify's 700/400 bold/regular binary */
.eyebrow,
.panel-index,
.toggle-title,
.mode-button,
.export-button {
  text-transform: uppercase;
  letter-spacing: 1.6px;
  font-weight: 700;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 10px;
}

/* Header style - seamless top bar instead of card box */
.brand-card {
  grid-column: 1 / -1;
  background: transparent;
  padding: 8px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  border-radius: 0;
  box-shadow: none;
  border: none;
}

.brand-copy-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--green);
  display: grid;
  place-items: center;
  box-shadow: 0 0 20px rgba(255, 0, 51, 0.4);
  flex-shrink: 0;
}

.brand-play {
  width: 0;
  height: 0;
  margin-left: 4px;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 12px solid #fff;
}

.brand-copy h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.brand-copy-text {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

/* Panel cards - sleek floating rounded panels */
.panel-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.03);
  transition: border-color 200ms ease;
}

.panel-card:hover {
  border-color: rgba(255, 255, 255, 0.06);
}

.workspace-grid {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 20px;
  flex: 1;
}

.controls-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.panel-index {
  color: var(--green);
  font-size: 11px;
}

.panel-heading h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

/* Clean Upload Zone - transparent dashed container */
.upload-zone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 28px 20px;
  border-radius: 12px;
  background: transparent;
  border: 2px dashed rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: all 200ms ease;
}

.upload-zone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-zone:hover {
  border-color: var(--green);
  background: rgba(255, 0, 51, 0.02);
}

.upload-title {
  font-size: 14px;
  font-weight: 700;
}

.upload-hint {
  color: var(--muted);
  font-size: 12px;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  font-size: 12px;
  color: var(--muted);
}

#videoMeta {
  font-weight: 600;
  color: #fff;
}

/* Form layouts and de-boxing */
.field,
.swatch-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field + .field,
.field + .field-grid,
.field-grid + .field,
.field-grid + .field-grid {
  margin-top: 18px;
}

.field label,
.swatch-field span {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
}

/* Ensure horizontal alignment in 2-column layouts when one label wraps to two lines */
.field-grid .field label,
.field-grid .swatch-field span {
  min-height: 32px;
  display: flex;
  align-items: flex-end;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

/* Mode toggle styled as a premium sliding capsule */
.mode-toggle {
  display: flex;
  background: #090909;
  border-radius: 9999px;
  padding: 4px;
  margin-bottom: 20px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.mode-button {
  flex: 1;
  padding: 10px 14px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  border-radius: 9999px;
  transition: all 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

.mode-button:hover {
  color: #fff;
}

.mode-button.is-active {
  background: #fff;
  color: #000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Sleek flat toggle switches */
.toggle-field {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.toggle-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: normal;
}

.toggle-switch {
  position: relative;
  width: 50px;
  height: 28px;
  flex-shrink: 0;
}

.toggle-switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.toggle-slider {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: var(--pill);
  background: #282828;
  cursor: pointer;
  transition: background-color 160ms ease;
}

.toggle-slider::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  transition: transform 160ms cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--green);
}

.toggle-switch input:checked + .toggle-slider::after {
  transform: translateX(22px);
}

/* Text overlays elements style */
.text-toolbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.text-element-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.text-element-chip {
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--pill);
  padding: 8px 14px;
  background: #181818;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 180ms ease;
}

.text-element-chip:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.15);
}

.text-element-chip.is-selected {
  background: #fff;
  color: #000;
  border-color: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.text-add-button {
  padding: 8px 14px;
  background: transparent;
  color: var(--text);
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-radius: var(--pill);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 180ms ease;
}

.text-add-button:hover {
  border-color: var(--green);
  color: var(--green);
  background: rgba(255, 0, 51, 0.02);
}

/* Disable state overlay controls */
.text-controls {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  border: 0;
  min-inline-size: 0;
  transition: opacity 200ms ease;
}

.text-controls.is-disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* Inputs, Textareas, Select fields */
textarea,
select,
input[type="color"] {
  width: 100%;
  border: 1px solid var(--input-border);
  color: var(--text);
  background: var(--input-bg);
  box-shadow: none;
  transition: border-color 200ms ease, background-color 200ms ease;
}

textarea,
select {
  border-radius: 12px;
}

textarea {
  min-height: 100px;
  padding: 12px 14px;
  resize: vertical;
}

select {
  padding: 11px 14px;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg fill='white' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/><path d='M0 0h24v24H0z' fill='none'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px;
}

textarea:hover,
select:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

textarea:focus,
select:focus {
  outline: none;
  border-color: var(--green);
  background: #1e1e1e;
}

/* Premium compact Color Swatch */
input[type="color"] {
  height: 42px;
  border-radius: 8px;
  padding: 0;
  background: transparent;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 6px;
}

/* Custom premium Range Sliders */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: transform 120ms ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.3);
  background: var(--green);
}

/* Stage Actions & Export Redesign */
.stage-view {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.stage-actions {
  width: min(100%, 410px); /* Matches exactly the phone chassis width */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.export-button {
  width: 100%;
  padding: 16px;
  background: var(--green);
  color: #fff;
  cursor: pointer;
  border: 0;
  border-radius: var(--pill);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.6px;
  transition: all 180ms cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 8px 24px rgba(255, 0, 51, 0.25);
  white-space: nowrap;
}

.export-button:hover:not(:disabled) {
  transform: translateY(-2px);
  background: #ff1a4a;
  box-shadow: 0 12px 30px rgba(255, 0, 51, 0.4);
}

.export-button:active:not(:disabled) {
  transform: translateY(0);
}

.export-button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  box-shadow: none;
}

.stage-actions progress {
  width: 100%;
  height: 4px;
  margin-top: 0;
  border: 0;
  border-radius: var(--pill);
  overflow: hidden;
  background: #181818;
  opacity: 0;
  transition: opacity 200ms ease;
}

/* Dynamically reveal progress bar when active */
.stage-actions progress[value]:not([value="0"]) {
  opacity: 1;
}

.stage-actions progress::-webkit-progress-bar {
  background: #181818;
}

.stage-actions progress::-webkit-progress-value,
.stage-actions progress::-moz-progress-bar {
  background: var(--green);
}

.short-frame {
  position: relative;
  width: min(100%, 410px);
  aspect-ratio: 9 / 16;
  overflow: hidden;
  border-radius: 40px;
  background: #000;
  border: 12px solid #1a1a1a;
  box-shadow:
    0 25px 65px -15px rgba(0, 0, 0, 0.9),
    0 0 50px -10px rgba(255, 0, 51, 0.18),
    inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  touch-action: auto;
}

.short-frame.is-crop-mode {
  touch-action: pan-y;
}

.pad-background,
.preview-video,
.preview-guides,
.empty-state,
.overlay-box {
  position: absolute;
  inset: 0;
}

.pad-background {
  overflow: hidden;
}

.pad-fill {
  position: absolute;
  left: 0;
  width: 100%;
}

.preview-video {
  display: none;
  height: 100%;
  pointer-events: none;
}

.preview-guides {
  border-radius: 28px; /* Slightly less than outer border-radius to align perfectly with bezel inner rim */
  border: 1px solid rgba(255, 255, 255, 0.05);
  pointer-events: none;
}

.overlay-box {
  touch-action: none;
  pointer-events: none;
  z-index: 10;
}

/* Guides for alignment snaps */
.snap-guide {
  position: absolute;
  pointer-events: none;
  z-index: 5;
}

.snap-guide--vertical {
  top: 4%;
  bottom: 4%;
  width: 1px;
  background: rgba(255, 0, 51, 0.65);
  box-shadow: 0 0 8px rgba(255, 0, 51, 0.4);
  transform: translateX(-50%);
}

.snap-guide--horizontal {
  left: 4%;
  right: 4%;
  height: 1px;
  background: rgba(255, 0, 51, 0.65);
  box-shadow: 0 0 8px rgba(255, 0, 51, 0.4);
  transform: translateY(-50%);
}

/* Floating overlay text styles */
.overlay-item {
  position: absolute;
  width: max-content;
  cursor: grab;
  pointer-events: auto;
  transition: transform 100ms ease;
  touch-action: none;
}

.overlay-item.is-dragging {
  cursor: grabbing;
  transform: translate(-50%, -50%) scale(1.02);
}

.overlay-item.is-selected .overlay-text {
  box-shadow: 
    rgba(0, 0, 0, 0.5) 0 12px 36px,
    0 0 0 2px var(--green); /* Gorgeous red highlighted border for selected text block */
}

.overlay-text {
  display: block;
  width: 100%;
  min-width: 140px;
  padding: 0.6em 1em;
  border-radius: 12px;
  color: #fff;
  font-weight: 700;
  text-transform: uppercase;
  line-height: 1.05;
  letter-spacing: -0.03em;
  white-space: pre-wrap;
  word-break: normal;
  overflow-wrap: normal;
  text-wrap: balance;
  box-shadow: rgba(0, 0, 0, 0.5) 0 8px 24px;
  transition: box-shadow 150ms ease;
}

.empty-state {
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 32px;
  text-align: center;
  pointer-events: auto;
  cursor: pointer;
  transition: all 180ms ease;
  z-index: 20;
}

.empty-state[hidden] {
  display: none !important;
}

.empty-state strong {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
  transition: color 180ms ease;
}

.empty-state span {
  color: var(--muted);
  font-size: 13px;
  transition: color 180ms ease;
}

.empty-state:hover strong {
  color: var(--green); /* Crimson hover glow */
}

.empty-state:hover span {
  color: #ffffff; /* Brighten text on hover */
}

/* Loaded file info dynamic overlay inside Source upload card */
.loaded-file-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  width: 100%;
}

.file-icon {
  font-size: 24px;
  margin-bottom: 2px;
}

.file-name {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-meta {
  font-size: 11px;
  color: var(--muted);
}

.change-file-btn {
  margin-top: 8px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--green);
  padding: 6px 14px;
  border: 1px dashed rgba(255, 0, 51, 0.3);
  border-radius: var(--pill);
  background: rgba(255, 0, 51, 0.02);
  transition: all 180ms ease;
}

.upload-zone:hover .change-file-btn {
  background: var(--green);
  color: #fff;
  border-style: solid;
  border-color: var(--green);
}

/* Premium Export Button Success/Error modifiers */
.export-button.is-success {
  background: #1db954 !important; /* Spotify Premium Green */
  box-shadow: 0 8px 24px rgba(29, 185, 84, 0.35) !important;
}

.export-button.is-error {
  background: #ff3333 !important; /* Premium warning crimson */
  box-shadow: 0 8px 24px rgba(255, 51, 51, 0.35) !important;
}
/* High-end Responsive layouts scaling */
@media (max-width: 1260px) {
  .app-shell {
    grid-template-columns: 1fr;
    max-width: 800px;
  }
}

@media (max-width: 980px) {
  .workspace-grid {
    grid-template-columns: 1fr;
    display: flex;
    flex-direction: column;
  }
  
  .stage-panel {
    order: -1; /* Keep preview dominant at the top */
  }

  .stage-actions {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100% !important;
    max-width: none !important;
    background: rgba(18, 18, 18, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 1000;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.6);
  }

  .stage-actions progress {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    border-radius: 0;
  }

  .export-button {
    max-width: 480px;
    margin: 0 auto;
  }

  body {
    padding-bottom: 90px !important; /* Prevent content from being hidden behind sticky bar */
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 10px;
    gap: 16px;
  }


  .short-frame {
    width: min(100%, 370px);
  }
}
