/* UploadX - main stylesheet */

:root {
  --bg: #0b0b0c;
  --card-a: #0f0f0f;
  --card-b: #202020;

  --blue: #4a90e2;
  --yellow: #ffcc00;

  --white: #ffffff;
  --text: #ffffffcc;
  --muted: #aaaaaa;
  --muted-2: #adadad;

  --line: rgba(255, 255, 255, 0.14);
  --line-soft: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.3);

  --r-lg: 24px;
  --r-md: 14px;
  --r-pill: 999px;

  --font: "Tanha", sans-serif;
  --ease: cubic-bezier(0.16, 0.84, 0.44, 1);

  --mx: 50%;
  --my: 50%;
}

* {
  box-sizing: border-box;
}

body {
  font-family: var(--font);
  background: var(--bg);
  margin: 0;
  padding: 1rem;
  direction: rtl;
  user-select: none;
  color: var(--text);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* cursor trail dot */
.trail {
  position: fixed;

  width: 60px;
  height: 60px;

  border-radius: 50%;

  background: #4a90e2;

  filter: blur(28px);

  opacity: 0.4;

  animation: fade 0.6s linear forwards;

  pointer-events: none;
}

@keyframes fade {
  to {
    transform: scale(2);

    opacity: 0;
  }
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #444;
}

hr {
  border: none;
  height: 1px;
  width: 100%;
  margin: 2.5rem 0;
  position: relative;
  overflow: visible;

  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.1) 15%,
    rgba(255, 255, 255, 0.2) 50%,
    rgba(255, 255, 255, 0.1) 85%,
    transparent
  );
}

.container {
  max-width: 900px;
  margin: auto;
  width: 100%;
  box-sizing: border-box;
  position: relative;
  z-index: 1;
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Header ---------- */
.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  margin: 1.2rem 0 2.1rem;
  text-align: center;
  animation: riseIn 0.6s var(--ease) both;
}
.brand-mark {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.1),
    rgba(255, 255, 255, 0.02)
  );
  border: 1px solid var(--line);
  position: relative;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.brand-mark svg {
  width: 24px;
  height: 24px;
  color: var(--white);
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 19px;
  padding: 1px;
  background: conic-gradient(
    from 0deg,
    rgba(74, 144, 226, 0),
    rgba(74, 144, 226, 0.9),
    rgba(74, 144, 226, 0) 30%
  );
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: spin 4s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

h1 {
  text-align: center;
  margin: 0;
  color: #fff;
  font-size: clamp(1.5rem, 2.6vw, 1.9rem);
  font-weight: 700;
}
.subtitle {
  color: var(--muted);
  font-size: 0.87rem;
  margin: 0.1rem 0 0;
}

/* ---------- Glass panel material ---------- */
.glass {
  position: relative;
  border-radius: var(--r-lg);
  background:
    linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.07) 0%,
      rgba(255, 255, 255, 0.015) 100%
    ),
    linear-gradient(
      135deg,
      var(--card-a) 0%,
      var(--card-b) 50%,
      var(--card-a) 100%
    );
  border: 1px solid transparent;
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    inset 0 -1px 0 rgba(0, 0, 0, 0.35);
  overflow: hidden;
  isolation: isolate;
}
/* top rim light */
.glass::before {
  content: "";
  position: absolute;
  top: 0;
  left: 8%;
  right: 8%;
  height: 1px;
  z-index: 2;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.65),
    transparent
  );
}
/* rotating border gradient */
@property --angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

.glass::after {
  content: "";
  position: absolute;
  inset: -2px;
  padding: 3px;
  border-radius: inherit;

  background: conic-gradient(
    from var(--angle),
    transparent 0deg,
    transparent 305deg,

    rgba(255, 255, 255, 0.05) 315deg,
    rgba(255, 255, 255, 0.7) 322deg,
    #4a90e2 330deg,
    #ffffff 337deg,
    #4a90e2 344deg,

    transparent 355deg
  );

  filter: blur(2px);

  animation: orbit 4s linear infinite;

  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);

  -webkit-mask-composite: xor;
  mask-composite: exclude;
}

@keyframes orbit {
  to {
    --angle: 360deg;
  }
}
/* cursor-following highlight */
.glass-hl {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(
    300px circle at var(--px, 50%) var(--py, 50%),
    rgba(255, 255, 255, 0.05),
    transparent 62%
  );
  transition: opacity 0.3s;
}
.glass:hover .glass-hl {
  opacity: 1;
}

/* ---------- Upload box ---------- */
.upload-box {
  padding: 2.3rem 1.5rem;
  text-align: center;
  cursor: pointer;
  position: relative;
  border: 1px dashed var(--line-strong);
  transition:
    transform 0.3s var(--ease),
    border-color 0.3s;
  animation: riseIn 0.6s var(--ease) 0.08s both;
}
.upload-box:hover {
  transform: scale(0.98);
  border-color: rgba(255, 255, 255, 0.5);
}
.upload-icon {
  width: 42px;
  height: 42px;
  margin: 0 auto 0.8rem;
  color: var(--text);
  position: relative;
  z-index: 2;
  animation: bob 3.4s ease-in-out infinite;
}
@keyframes bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}
.upload-text {
  font-weight: 600;
  font-size: 0.96rem;
  position: relative;
  z-index: 2;
}
.upload-hint {
  margin-top: 0.35rem;
  font-size: 0.78rem;
  color: var(--muted);
  position: relative;
  z-index: 2;
}
#fileInput {
  display: none;
}

.progress-wrapper {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  height: 6px;
  border-radius: 12px;
  background: #444;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.2s;
  direction: ltr;
  z-index: 2;
}
.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 12px;
  background: var(--blue);
  transition: width 0.2s;
}
.progress-text {
  position: absolute;
  right: 18px;
  bottom: 22px;
  font-size: 0.75rem;
  color: #fff;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 2;
}

/* ---------- Room panel ---------- */
.room-panel {
  margin-top: 1.4rem;
  padding: 1.5rem 1.3rem;
  text-align: center;
  animation: riseIn 0.6s var(--ease) 0.16s both;
}
.room-row {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  flex-wrap: wrap;
  position: relative;
  z-index: 2;
}

#roomInput {
  font-family: var(--font);
  padding: 0.65rem 1rem;
  font-weight: 500;
  font-size: 0.88rem;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  color: #fff;
  width: 190px;
  text-transform: uppercase;
  outline: none;
  text-align: center;
  letter-spacing: 1px;
  transition: 0.3s;
}
#roomInput::placeholder {
  color: var(--muted);
  letter-spacing: normal;
}
#roomInput:focus {
  border-color: rgba(255, 255, 255, 0.5);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08);
}

#createRoomBtn,
#joinRoomBtn {
  font-family: var(--font);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.15rem;
  font-weight: 600;
  font-size: 0.86rem;
  border-radius: var(--r-pill);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition:
    transform 0.2s var(--ease),
    background 0.25s,
    border-color 0.25s,
    box-shadow 0.25s;
}
#createRoomBtn {
  border: none;
  background: #fff;
  color: #000;
}
#createRoomBtn:hover {
  background: #d3d3d3;
}
#createRoomBtn:active {
  transform: scale(0.95);
}

#joinRoomBtn {
  border: 1px solid #2a2a2a;
  background: rgba(255, 255, 255, 0.02);
  color: #adadad;
  backdrop-filter: blur(8px);
}
#joinRoomBtn:hover {
  background: rgba(255, 255, 255, 0.06);
}
#joinRoomBtn:active {
  transform: scale(0.95);
}

#createRoomBtn::after,
#joinRoomBtn::after {
  content: "";
  position: absolute;
  top: 0;
  left: -130%;
  width: 55%;
  height: 100%;
  background: linear-gradient(
    120deg,
    transparent,
    rgba(255, 255, 255, 0.5),
    transparent
  );
  transform: skewX(-18deg);
  transition: left 0.55s ease;
  pointer-events: none;
}
#createRoomBtn:hover::after,
#joinRoomBtn:hover::after {
  left: 140%;
}

#currentRoomInfo {
  color: var(--muted);
  margin-top: 1.2rem;
  font-size: 0.87rem;
  font-weight: 500;
  position: relative;
  z-index: 2;
}

#copyRoomBtn {
  font-family: var(--font);
  margin-top: 0.6rem;
  padding: 0.45rem 0.95rem;
  font-weight: 600;
  font-size: 0.8rem;
  border: 1px solid var(--yellow);
  border-radius: var(--r-pill);
  background: var(--yellow);
  color: #000;
  cursor: pointer;
  display: none;
  align-items: center;
  gap: 0.4rem;
  position: relative;
  z-index: 2;
  transition: 0.25s;
}
#copyRoomBtn:hover {
  background: none;
  color: var(--yellow);
}
#copyRoomBtn:active {
  transform: scale(0.95);
}

/* ---------- Gallery ---------- */
.gallery {
  margin-top: 1.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
  position: relative;
  z-index: 1;
  animation: riseIn 0.6s var(--ease) 0.22s both;
}

.file-item {
  animation: cardIn 0.5s var(--ease) both;
  perspective: 700px;
}
@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.card {
  width: 100%;
  min-height: 126px;
  max-width: 100%;
  box-sizing: border-box;
  background: linear-gradient(
    135deg,
    var(--card-a) 0%,
    var(--card-b) 50%,
    var(--card-a) 100%
  );
  color: var(--text);
  padding: 0.9rem 0.8rem;
  border-radius: var(--r-md);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
  gap: 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  overflow: hidden;
  position: relative;
  transition:
    transform 0.25s var(--ease),
    border-color 0.25s;
  transform-style: preserve-3d;
  will-change: transform;
}
.card:hover {
  border-color: rgba(255, 255, 255, 0.4);
}

.ext-badge {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: #dcdcdc;
  padding: 0.25rem 0.55rem;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.card .truncate-2lines {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-all;
  margin: 0;
  font-size: 0.87rem;
}

.card .file-size {
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted);
  direction: ltr;
}

.action-buttons {
  display: flex;
  gap: 0.55rem;
  margin-top: 0.55rem;
  justify-content: center;
  width: 100%;
}

.download,
.share-btn {
  font-family: var(--font);
  position: relative;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 34px;
  height: 34px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.4);
  text-decoration: none;
  backdrop-filter: blur(8px);
  transition: all 0.3s;
  cursor: pointer;
  flex-shrink: 0;
  overflow: hidden;
}

.download::before,
.share-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -160%;
  width: 60%;
  height: 100%;
  background: linear-gradient(
    120deg,
    transparent,
    rgba(255, 255, 255, 0.5),
    transparent
  );
  transform: skewX(-18deg);
  transition: left 0.5s ease;
}
.download:hover::before,
.share-btn:hover::before {
  left: 160%;
}

.download::after,
.share-btn::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 120%;
  left: 50%;
  transform: translateX(-50%) translateY(5px);
  background-color: rgba(0, 0, 0, 0.9);
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
  pointer-events: none;
  z-index: 10;
}

.download:hover::after,
.share-btn:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.download:hover,
.share-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.6);
  transform: translateY(-2px);
}

.download svg,
.share-btn svg {
  width: 15px;
  height: 15px;
}

.gallery-empty {
  grid-column: 1/-1;
  text-align: center;
  padding: 2.2rem 1rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
}
.gallery-empty svg {
  width: 32px;
  height: 32px;
  color: #555;
}
.gallery-empty b {
  color: #fff;
  font-size: 0.9rem;
}
.gallery-empty span {
  font-size: 0.78rem;
}

/* ---------- Download progress ---------- */
#downloadProgressSection {
  animation: fadeIn 0.3s ease-in-out;
  margin-top: 1.4rem;
}
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.dl-panel {
  padding: 1rem 1.2rem;
  max-width: 400px;
  margin: 0 auto;
  text-align: center;
}
.dl-panel p#downloadFileName {
  color: #fff;
  font-size: 0.88rem;
  margin: 0 0 0.9rem;
  position: relative;
  z-index: 2;
}
.dl-track {
  position: relative;
  height: 6px;
  background: #333;
  border-radius: 3px;
  overflow: hidden;
  direction: ltr;
  z-index: 2;
}
#downloadProgressBar {
  height: 100%;
  width: 0%;
  background: var(--blue);
  border-radius: 8px;
  transition: width 0.1s linear !important;
}
.dl-meta {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.72rem;
  margin-top: 0.45rem;
  direction: ltr;
  position: relative;
  z-index: 2;
}

/* ---------- Toasts ---------- */
#toast-container {
  position: fixed;
  bottom: 25px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999999999;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(92vw, 380px);
}
.toast {
  display: flex;
  align-items: center;
  margin-bottom: 6px;
  gap: 12px;
  background: #101010;
  color: white;
  padding: 13px 17px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  width: 100%;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  position: relative;
  opacity: 0;
  animation: slideDown 0.4s var(--ease) forwards;
}
.toast.hide {
  animation: slideUp 0.35s var(--ease) forwards;
}
.toast-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.toast-message {
  flex: 1;
  font-size: 13.5px;
}
.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: #fff;
  width: 100%;
  border-radius: 8px;
  animation: progress linear forwards;
}
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes slideUp {
  to {
    opacity: 0;
    transform: translateY(8px);
  }
}
@keyframes progress {
  from {
    width: 100%;
  }
  to {
    width: 0%;
  }
}

/* ---------- Share fallback modal ---------- */
.share-fallback-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}
.share-fallback-box {
  background: #1e1e1e;
  padding: 1.5rem;
  border-radius: 12px;
  max-width: 90%;
  color: #fff;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.15);
}
.share-fallback-input {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.5rem;
  border-radius: 8px;
  border: none;
  background: #2a2a2a;
  color: #fff;
  text-align: center;
}
.share-fallback-close {
  font-family: var(--font);
  margin-top: 1rem;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
}

button:focus-visible,
input:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.25);
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

@media (max-width: 600px) {
  body {
    padding: 0.8rem;
  }
  .gallery {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.7rem;
  }
  .card {
    padding: 0.75rem;
    min-height: 112px;
  }
  .card .truncate-2lines {
    font-size: 0.82rem;
  }
  .download,
  .share-btn {
    width: 31px;
    height: 31px;
  }
  .download::after,
  .share-btn::after {
    display: none;
  }
  #roomInput {
    width: 100%;
    max-width: 220px;
  }
  .room-row {
    width: 100%;
  }
}
