@import url("/theme.css");

/* Upload Page specific styles */

/* Hero */
.hero {
  text-align: center;
  max-width: 760px;
  margin: 42px auto 0;
  padding: 0 var(--s-4);
}
.hero h1 {
  margin: 0;
  font-size: clamp(38px, 5vw, 58px);
  line-height: 1.04;
  letter-spacing: -.045em;
}
.hero h1 em {
  color: var(--bg);
  font-style: normal;
}

/* Container & card */
.container {
  max-width: 1200px;
  margin: var(--s-6) auto 60px;
  padding: 0 var(--s-4);
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: var(--s-5) var(--s-6);
}

/* Grid layout */
.formGrid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(380px, 36vw, 560px);
  grid-template-rows: auto auto;
  grid-template-areas:
    "leftColumn rightTop"
    "leftColumn rightBottom";
  gap: var(--s-5) var(--s-6);
  align-items: start;
}
@media (max-width: 940px) {
  .formGrid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "leftColumn"
      "rightTop"
      "rightBottom";
  }
}

.leftColumn {
  grid-area: leftColumn;
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: var(--s-4);
}

.leftTop {
  grid-area: leftTop;
  display: grid;
  row-gap: var(--s-3);
}
.rightTop {
  grid-area: rightTop;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: var(--s-4);
  margin-top: 5px; /* baseline alignment */
}
@media (max-width: 940px) {
  .rightTop {
    margin-top: 0;
  }
}

.leftBottom,
.rightBottom {
  grid-area: auto;
  display: flex;
  align-items: stretch;
  gap: var(--s-3);
}
.leftBottom {
  min-width: 0;
}
.rightBottom {
  grid-area: rightBottom;
  flex-direction: column;
  gap: var(--s-3);
}
.leftBottom > *,
.rightBottom > * {
  flex: 1;
}

/* Labels */
.dropLabel,
.label {
  display: block;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: var(--s-2);
}
.group input:disabled {
  opacity: .62;
  cursor: not-allowed;
}
.fieldHelp {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

/* --- Expiry alignment & spacing fix (final perfect version) --- */
.rightTop .group:first-child {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  margin-top: 2px; /* nudged slightly down for baseline alignment */
  padding-top: 0;
}

.rightTop .group:first-child .label {
  margin-bottom: 14px; /* balanced spacing under label */
  line-height: 1.25;
}

/* aligns the select box with upload box on the left */
.rightTop select#expirySelect {
  height: calc(var(--control-h) + 5px);
  padding-left: var(--s-4);
  display: flex;
  align-items: center;
}

/* perfect gap between select and custom-hours input */
#customHours {
  margin-top: 12px;
}

/* Dropzone */
.drop {
  border: 2px dashed var(--border);
  border-radius: 16px;
  background: linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.06),
      rgba(255, 255, 255, 0.06)
    ),
    rgba(148, 163, 184, 0.08);
  padding: var(--s-6);
  display: grid;
  place-items: center;
  text-align: center;
  user-select: none;
  min-height: clamp(240px, 28vh, 380px);
  cursor: pointer;
  transition: border-color .18s ease, background-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.drop:hover {
  transform: translateY(-1px);
  border-color: color-mix(in oklab, var(--border) 60%, var(--bg) 40%);
  box-shadow: 0 14px 34px rgba(2, 8, 23, 0.45),
    0 3px 10px rgba(2, 8, 23, 0.5);
}
.drop.drag {
  background: rgba(59, 130, 246, 0.12);
  border-color: var(--bg);
}
.drop:focus-within {
  border-color: var(--bg);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--bg) 24%, transparent);
}
.drop .icon {
  width: clamp(46px, 4vw, 60px);
  height: clamp(46px, 4vw, 60px);
  margin-bottom: var(--s-3);
  background: radial-gradient(circle at 30% 30%, #ffffff33 0%, transparent 60%),
    linear-gradient(135deg, var(--bg), var(--bg-2));
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: #fff;
  box-shadow: var(--shadow);
}
.drop .icon svg {
  width: 26px;
  height: 26px;
}
.drop .hint {
  color: var(--text);
  font-weight: 700;
}
.drop .sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

input[type="file"].vh {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* File cards */
.fileCard {
  background: linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.04),
      rgba(255, 255, 255, 0.04)
    ),
    transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--s-3) var(--s-4);
}
.fileCard:hover {
  border-color: color-mix(in oklab, var(--border) 60%, var(--bg) 40%);
  box-shadow: 0 10px 24px rgba(2, 8, 23, 0.5),
    0 3px 8px rgba(2, 8, 23, 0.5);
  transform: translateY(-1px);
}
video.preview {
  background: #000;
  border-radius: 8px;
}

/* Inputs & selects */
input[type="text"],
input[type="password"],
input[type="number"],
select {
  width: 100%;
  height: var(--control-h);
  padding: 0 var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  color: var(--text);
  background-color: var(--card);
  font-size: 14px;
  line-height: var(--control-h);
}
input:hover,
select:hover {
  border-color: color-mix(in oklab, var(--border) 60%, var(--bg) 40%);
}
input:focus,
select:focus {
  border-color: var(--bg);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--bg) 25%, transparent);
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--s-4) center;
  background-size: 16px 16px;
  padding-right: 42px;
}
[data-theme="light"] select option {
  background: #fff;
  color: #0f172a;
}
[data-theme="dark"] select option {
  background: #0b1220;
  color: #e5e7eb;
}

/* Buttons */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  flex-wrap: wrap;
  margin-bottom: var(--s-3);
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: var(--control-h);
  padding: 0 var(--s-4);
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  font-weight: 700;
  background: var(--bg);
  color: #fff;
  transition: all 0.15s ease;
}
.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 34px rgba(2, 8, 23, 0.45),
    0 3px 10px rgba(2, 8, 23, 0.5);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.btn.warn {
  background: #f97316;
  color: #fff;
}
.btn.warn:disabled {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
  opacity: 0.65;
  cursor: not-allowed;
  box-shadow: none;
}
.btn.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}
.btn.secondary:hover {
  background: color-mix(in oklab, var(--card) 88%, var(--text) 12%);
  border-color: color-mix(in oklab, var(--border) 60%, var(--bg) 40%);
}

/* Progress */
.progress {
  height: 10px;
  background: rgba(148, 163, 184, 0.25);
  border-radius: 9999px;
  overflow: hidden;
  border: 1px solid var(--border);
  width: 100%;
  margin-top: var(--s-3);
  margin-bottom: var(--s-2);
}
.progress > div {
  height: 100%;
  width: 0%;
  background: var(--bg);
  transition: width 0.2s ease, background 0.3s ease;
}
.progress > div.done {
  background: color-mix(in oklab, var(--green) 62%, var(--bg));
}
.progress > div.error {
  background: var(--danger);
}

#progressText {
  margin-top: var(--s-2);
  color: var(--muted);
}

/* Result & error boxes */
.muted {
  color: var(--muted);
  font-size: 13px;
}
#out,
#err,
#warn {
  border-radius: 12px;
  padding: var(--s-3) var(--s-4);
  word-break: break-word;
  border: 1px solid;
}
#err:empty,
#warn:empty,
#out:empty {
  display: none;
}
#out {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.25);
}
#err {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.25);
  color: var(--danger);
}
#warn {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.25);
  color: var(--amber);
}

/* spacing between cards */
#selected .fileCard {
  margin-bottom: 14px;
}
#selected .fileCard:last-child {
  margin-bottom: 0;
}

/* --- Card Alignment Fix --- */
.fileCard {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  align-items: center;
  gap: var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--s-3) var(--s-4);
  background: linear-gradient(0deg, rgba(255, 255, 255, 0.04),
    rgba(255, 255, 255, 0.04)), transparent;
}
.fileCard video.preview {
  flex-shrink: 0;
  width: 120px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  background: #000;
}
.fileCard > .fileMeta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
}
.fileMeta { min-width: 0; }
.fileDisplayTitle {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.uploadResult {
  grid-column: 1 / -1;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
  margin-top: 2px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.uploadResultLink {
  display: grid;
  gap: 5px;
  min-width: 0;
}
.uploadResultLabel {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.uploadResultLink a {
  overflow: hidden;
  color: color-mix(in oklab, var(--bg) 72%, var(--text) 28%);
  font-size: 14px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.uploadResultActions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}
.uploadResultActions .btn { justify-content: center; }

/* --- Selected Card Highlight (for title editing) --- */
.fileCard {
  cursor: pointer;
  position: relative;
}
.fileCard.active {
  border-color: var(--bg);
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--bg) 40%, transparent);
  transition: box-shadow 0.15s ease;
}

/* --- Full Width File Cards --- */
#selected {
  width: 100%;
  padding: 0;
  margin: 0;
}

#selected .fileCard {
  width: 100%;
  box-sizing: border-box;
  display: grid;
  align-items: center;
}
.fileTitleState {
  display: none;
  width: fit-content;
  padding: 3px 7px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--bg) 18%, transparent);
  color: color-mix(in oklab, var(--text) 82%, var(--bg) 18%);
  font-size: 11px;
  font-weight: 750;
}
.fileCard.active .fileTitleState { display: inline-flex; }
.fileOriginalName {
  overflow: hidden;
  max-width: 100%;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.removeFileBtn {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  width: 32px;
  height: 32px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: color-mix(in oklab, var(--card) 92%, transparent);
  color: var(--muted);
  cursor: pointer;
  z-index: 1;
}
.removeFileBtn:hover {
  border-color: color-mix(in oklab, var(--danger) 55%, var(--border));
  background: color-mix(in oklab, var(--danger) 12%, var(--card));
  color: var(--danger);
}
.removeFileBtn:disabled { opacity: 0.4; cursor: not-allowed; }
.removeFileBtn[hidden] { display: none; }
.removeFileBtn svg {
  width: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 2;
}
.fileCard > .fileMeta { padding-right: 34px; }

@media (max-width: 720px) {
  .hero { margin-top: 28px; }
  .hero h1 { font-size: clamp(36px, 11vw, 46px); }
  .container { margin-top: 22px; padding: 0 12px; }
  .card { padding: 16px; border-radius: 16px; }
  .formGrid { gap: 20px; }
  .drop { min-height: 220px; padding: 20px; }
  .toolbar .btn { flex: 1; justify-content: center; }
  .fileCard {
    grid-template-columns: 96px minmax(0, 1fr);
    align-items: flex-start;
    padding: 10px;
  }
  .fileCard video.preview { width: 96px; height: 64px; }
  .uploadResult { align-items: stretch; flex-direction: column; }
  .uploadResultLink a { white-space: normal; overflow-wrap: anywhere; }
  .uploadResultActions { display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); }
  .uploadResultActions .btn { width: 100%; padding: 0 10px; }
}
