/* ──────── Reset & Base ──────── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #0b0d17;
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.06);
  --border-card: rgba(255, 255, 255, 0.08);
  --border-card-hover: rgba(255, 255, 255, 0.14);
  --text-primary: #e8eaf0;
  --text-secondary: #8b8fa3;
  --text-muted: #5c6078;
  --accent: #6c5ce7;
  --accent-light: #a29bfe;
  --accent-glow: rgba(108, 92, 231, 0.35);
  --success: #00cec9;
  --danger: #ff6b6b;
  --danger-hover: #ee5a5a;
  --radius: 16px;
  --radius-sm: 10px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* ──────── Animated Background ──────── */
.bg-blob {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
  animation: blobMove 20s ease-in-out infinite alternate;
}

.blob-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #6c5ce7, transparent 70%);
  top: -10%;
  left: -5%;
}

.blob-2 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, #0984e3, transparent 70%);
  bottom: -10%;
  right: -5%;
  animation-delay: -7s;
}

.blob-3 {
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, #00cec9, transparent 70%);
  top: 40%;
  left: 50%;
  animation-delay: -14s;
}

@keyframes blobMove {
  0% {
    transform: translate(0, 0) scale(1);
  }
  33% {
    transform: translate(40px, -30px) scale(1.08);
  }
  66% {
    transform: translate(-20px, 20px) scale(0.95);
  }
  100% {
    transform: translate(10px, -10px) scale(1.03);
  }
}

/* ──────── App Shell ──────── */
.app {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem 1rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ──────── Header ──────── */
header {
  text-align: center;
  margin-bottom: 2.5rem;
  animation: fadeInDown 0.6s ease-out;
}

header h1 {
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  background: linear-gradient(
    135deg,
    var(--accent-light),
    var(--accent),
    #0984e3
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
  font-weight: 400;
  margin-top: 0.35rem;
}

/* ──────── Main Grid ──────── */
main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  flex: 1;
  animation: fadeInUp 0.6s ease-out 0.15s both;
}

/* ──────── Cards ──────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  transition:
    border-color var(--transition),
    box-shadow var(--transition);
}

.card:hover {
  border-color: var(--border-card-hover);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.25);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-icon {
  font-size: 1.25rem;
}

.card-title h2 {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.75rem;
  min-height: 1.4rem;
}

.char-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ──────── Buttons ──────── */
.actions {
  display: flex;
  gap: 0.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.9rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn svg {
  flex-shrink: 0;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #5a4bd1);
  color: #fff;
  box-shadow: 0 2px 12px var(--accent-glow);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.18);
}

.btn-danger {
  background: rgba(255, 107, 107, 0.12);
  color: var(--danger);
  border: 1px solid rgba(255, 107, 107, 0.2);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(255, 107, 107, 0.22);
  border-color: rgba(255, 107, 107, 0.35);
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ──────── Textarea ──────── */
.textarea-wrapper {
  flex: 1;
  display: flex;
  min-height: 0;
}

#text-area {
  width: 100%;
  min-height: 320px;
  resize: vertical;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  padding: 1rem;
  color: var(--text-primary);
  font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 0.88rem;
  line-height: 1.65;
  outline: none;
  transition:
    border-color var(--transition),
    box-shadow var(--transition);
}

#text-area::placeholder {
  color: var(--text-muted);
}

#text-area:focus {
  border-color: rgba(108, 92, 231, 0.4);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.1);
}

/* ──────── Drop Zone ──────── */
.drop-zone {
  border: 2px dashed rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: rgba(0, 0, 0, 0.15);
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(108, 92, 231, 0.06);
}

.drop-zone.drag-over {
  transform: scale(1.01);
  box-shadow: 0 0 30px rgba(108, 92, 231, 0.15);
}

.drop-icon-wrapper {
  margin-bottom: 0.75rem;
}

.drop-icon {
  color: var(--text-muted);
  transition: color var(--transition);
}

.drop-zone:hover .drop-icon {
  color: var(--accent-light);
}

.drop-text {
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.3rem;
}

.drop-subtext {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.drop-subtext a {
  color: var(--accent-light);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--transition);
}

.drop-subtext a:hover {
  color: #fff;
}

/* ──────── File Info ──────── */
.file-info {
  display: none;
  align-items: center;
  gap: 0.75rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  margin-top: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.file-info.visible {
  display: flex;
}

.file-info-icon {
  font-size: 1.5rem;
}

.file-info-details {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  overflow: hidden;
}

.file-name {
  font-weight: 500;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ──────── Status ──────── */
.status {
  font-size: 0.78rem;
  color: var(--text-muted);
  transition: color var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status.success {
  color: var(--success);
}

.status.error {
  color: var(--danger);
}

.status.saving {
  color: var(--accent-light);
}

/* ──────── Auth Modal ──────── */
.auth-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(11, 13, 23, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease;
}

.auth-modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.auth-modal-content {
  width: 90%;
  max-width: 400px;
  text-align: center;
  padding: 2rem;
  transform: translateY(0);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.auth-modal-overlay.hidden .auth-modal-content {
  transform: translateY(20px);
}

.auth-modal-content h2 {
  margin-bottom: 0.5rem;
}

.auth-modal-content .subtitle {
  margin-bottom: 1.5rem;
}

.auth-input-group {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

#apparent-key-input {
  flex: 1;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 1rem;
  outline: none;
  transition:
    border-color var(--transition),
    box-shadow var(--transition);
}

#apparent-key-input:focus {
  border-color: rgba(108, 92, 231, 0.4);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.1);
}

#btn-submit-key {
  padding: 0.75rem 1.25rem;
  font-size: 0.95rem;
}

#auth-error {
  margin-top: 0.5rem;
}

#auth-error.hidden {
  display: none;
}

/* ──────── Toast ──────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column-reverse;
  gap: 0.5rem;
  z-index: 9999;
}

.toast {
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  color: #fff;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  transform: translateX(120%);
  opacity: 0;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  max-width: 340px;
}

.toast.show {
  transform: translateX(0);
  opacity: 1;
}

.toast-success {
  background: rgba(0, 206, 201, 0.85);
  border: 1px solid rgba(0, 206, 201, 0.4);
}

.toast-error {
  background: rgba(255, 107, 107, 0.85);
  border: 1px solid rgba(255, 107, 107, 0.4);
}

.toast-info {
  background: rgba(108, 92, 231, 0.85);
  border: 1px solid rgba(108, 92, 231, 0.4);
}

/* ──────── Loading Overlay ──────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background: var(--bg-primary);
  transition: opacity 0.5s ease;
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent-light);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-overlay p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ──────── Footer ──────── */
footer {
  text-align: center;
  padding: 1.5rem 0 0.75rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* ──────── Animations ──────── */
@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

/* ──────── Responsive ──────── */
@media (max-width: 768px) {
  main {
    grid-template-columns: 1fr;
  }

  header h1 {
    font-size: 1.8rem;
  }

  .card {
    padding: 1rem 1.15rem;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .actions {
    width: 100%;
  }

  .actions .btn {
    flex: 1;
    justify-content: center;
  }

  #text-area {
    min-height: 220px;
  }

  .drop-zone {
    min-height: 160px;
  }
}

/* ──────── Upload progress bar ──────── */
.upload-progress {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 0.75rem;
  display: none;
}

.upload-progress.active {
  display: block;
}

.upload-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  border-radius: 2px;
  width: 0%;
  transition: width 0.3s ease;
}
