/* ── Global ── */
body {
  background: #f8f9fb;
  color: #1a1a2e;
}

/* ── Login ── */
.login-card {
  width: 100%;
  max-width: 420px;
  border-radius: 1rem;
  border: 0;
}

.login-icon {
  font-size: 2.5rem;
  color: #4361ee;
}

.login-bg {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 60%, #0f3460 100%);
}

/* ── Navbar ── */
.navbar {
  border-bottom: 1px solid rgba(0,0,0,.1);
}

/* ── Drop Zone ── */
.drop-zone {
  border: 2px dashed #c0c8d8;
  border-radius: .75rem;
  padding: 2rem 1rem;
  text-align: center;
  cursor: pointer;
  background: #fff;
  transition: border-color .2s, background .2s;
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: #4361ee;
  background: #f0f4ff;
}

.drop-zone.has-file {
  border-color: #2ec4b6;
  background: #f0fdfb;
}

.dz-icon {
  font-size: 2rem;
  margin-bottom: .5rem;
  color: #9098b1;
}

.dz-thumb {
  max-width: 100%;
  max-height: 200px;
  border-radius: .5rem;
  object-fit: contain;
}

/* ── Result placeholder ── */
.result-placeholder {
  min-height: 340px;
  border: 2px dashed #dee2e6;
  border-radius: .75rem;
  background: #fff;
}

/* ── Result image viewer ── */
.result-viewer {
  overflow: hidden;
  border-radius: .75rem;
  background: #111;
  cursor: grab;
  user-select: none;
  max-height: 65vh;
  position: relative;
}

.result-viewer:active { cursor: grabbing; }

/* ── Indeterminate progress bar ── */
.progress-bar-indeterminate {
  animation: indeterminate 1.5s ease-in-out infinite;
  width: 40% !important;
}

@keyframes indeterminate {
  0%   { margin-left: 0;   width: 30%; }
  50%  { margin-left: 35%; width: 30%; }
  100% { margin-left: 70%; width: 30%; }
}

.result-img {
  display: block;
  max-width: 100%;
  max-height: 65vh;
  margin: 0 auto;
  transform-origin: 0 0;
  transition: none;
}

/* ── History ── */
.history-card {
  transition: transform .15s, box-shadow .15s;
  border-radius: .75rem;
  overflow: hidden;
}

.history-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,.12) !important;
}

.history-thumb-wrap {
  position: relative;
  overflow: hidden;
  background: #1a1a2e;
  aspect-ratio: 1 / 1;
  display: flex; align-items: center; justify-content: center;
}

.history-thumb {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform .3s;
}

.history-thumb-wrap:hover .history-thumb {
  transform: scale(1.04);
}

.thumb-badge {
  position: absolute; top: .4rem; right: .4rem;
  background: rgba(0,0,0,.65);
  color: #fff; font-size: .7rem; font-weight: 700;
  padding: .1rem .4rem; border-radius: .3rem;
  letter-spacing: .03em;
}

/* ── Engine cards ── */
.engine-card {
  display: block;
  padding: .5rem .7rem;
  border: 1.5px solid #dee2e6;
  border-radius: .5rem;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  background: #fff;
}

.engine-card:hover {
  border-color: #e63946;
  background: #fff5f5;
}

.engine-card.selected {
  border-color: #e63946;
  background: #fef1f2;
}

/* ── Model cards ── */
.model-card {
  display: block;
  padding: .6rem .75rem;
  border: 1.5px solid #dee2e6;
  border-radius: .5rem;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  background: #fff;
}

.model-card:hover {
  border-color: #4361ee;
  background: #f5f7ff;
}

.model-card.selected {
  border-color: #4361ee;
  background: #eef1fd;
}

.model-desc {
  font-size: .72rem;
  color: #6c757d;
  margin-top: .25rem;
  line-height: 1.4;
}

.model-badge {
  font-size: .65rem;
  background: #4361ee;
  color: #fff;
  padding: .15rem .45rem;
  border-radius: .25rem;
  font-weight: 600;
  flex-shrink: 0;
}

/* ── Library ── */
.lib-paste-zone {
  position: sticky; top: 0; z-index: 100;
  background: #1a1a2e;
  color: #cdd3f0;
  text-align: center;
  padding: .6rem 1rem;
  font-size: .9rem;
  border-bottom: 2px solid #2e3461;
}

.lib-paste-icon { margin-right: .4rem; }

.lib-card {
  border: 1.5px solid #e2e6ea;
  border-radius: .6rem;
  overflow: hidden;
  background: #fff;
  transition: box-shadow .15s;
}

.lib-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
}

.lib-thumb-wrap {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: #f1f3f5;
}

.lib-thumb {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform .25s;
}

.lib-thumb-wrap:hover .lib-thumb {
  transform: scale(1.05);
}

.lib-overlay {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: .25rem .4rem;
  background: linear-gradient(transparent, rgba(0,0,0,.5));
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.lib-size {
  font-size: .65rem; color: #fff; font-weight: 600;
}

.lib-type-badge {
  font-size: .6rem; font-weight: 700;
  padding: .1rem .35rem; border-radius: .25rem;
  text-transform: uppercase; letter-spacing: .04em;
}

.lib-type-paste  { background: #6c757d; color: #fff; }
.lib-type-before { background: #4361ee; color: #fff; }
.lib-type-after  { background: #2ec4b6; color: #fff; }

/* ── Log viewer ── */
.log-controls {
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: .5rem;
  padding: .75rem 1rem;
}

.log-output {
  background: #1a1a2e;
  border: 1px solid #dee2e6;
  border-radius: .5rem;
  padding: 1rem;
  font-family: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', 'Consolas', monospace;
  font-size: .8rem;
  line-height: 1.6;
  color: #c8c8d8;
  max-height: 75vh;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.log-line-error   { color: #e63946; }
.log-line-warning { color: #f0ad4e; }
.log-line-info    { color: #c8c8d8; }

/* ── Theme toggle button ── */
.btn-theme {
  font-size: 1.1rem;
  line-height: 1;
  padding: .25rem .4rem;
  border: none;
  background: transparent;
  cursor: pointer;
  opacity: .7;
  transition: opacity .15s;
}

.btn-theme:hover { opacity: 1; }

/* ============================================================
   DARK MODE — activated via [data-bs-theme="dark"] on <html>
   ============================================================ */
[data-bs-theme="dark"] body {
  background: #0f0f1a;
  color: #e0e0e0;
}

[data-bs-theme="dark"] .login-card {
  background: #1a1a2e;
  border: 1px solid #2e2e4a;
  color: #e0e0e0;
}

[data-bs-theme="dark"] .navbar {
  background: #0f0f1a !important;
  border-bottom-color: #2e2e4a;
}

[data-bs-theme="dark"] .card {
  background: #1a1a2e;
  border-color: #2e2e4a;
  color: #e0e0e0;
}

[data-bs-theme="dark"] .drop-zone {
  background: #1a1a2e;
  border-color: #2e2e4a;
}

[data-bs-theme="dark"] .drop-zone:hover,
[data-bs-theme="dark"] .drop-zone.drag-over {
  border-color: #4361ee;
  background: #22223a;
}

[data-bs-theme="dark"] .drop-zone.has-file {
  border-color: #2ec4b6;
  background: #1a2e2b;
}

[data-bs-theme="dark"] .dz-icon { color: #8888aa; }

[data-bs-theme="dark"] .result-placeholder {
  background: #1a1a2e;
  border-color: #2e2e4a;
  color: #8888aa;
}

[data-bs-theme="dark"] .history-card {
  background: #1a1a2e;
  border-color: #2e2e4a;
}

[data-bs-theme="dark"] .history-card:hover {
  background: #22223a;
  box-shadow: 0 6px 20px rgba(0,0,0,.4) !important;
}

[data-bs-theme="dark"] .history-thumb-wrap { background: #0f0f1a; }

[data-bs-theme="dark"] .engine-card {
  background: #1a1a2e;
  border-color: #2e2e4a;
  color: #e0e0e0;
}

[data-bs-theme="dark"] .engine-card:hover {
  border-color: #e63946;
  background: #2a1a1e;
}

[data-bs-theme="dark"] .engine-card.selected {
  border-color: #e63946;
  background: #2e1a20;
}

[data-bs-theme="dark"] .model-card {
  background: #1a1a2e;
  border-color: #2e2e4a;
  color: #e0e0e0;
}

[data-bs-theme="dark"] .model-card:hover {
  border-color: #4361ee;
  background: #1e2040;
}

[data-bs-theme="dark"] .model-card.selected {
  border-color: #4361ee;
  background: #1e2248;
}

[data-bs-theme="dark"] .model-desc { color: #8888aa; }

[data-bs-theme="dark"] .lib-card {
  background: #1a1a2e;
  border-color: #2e2e4a;
}

[data-bs-theme="dark"] .lib-card:hover {
  background: #22223a;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
}

[data-bs-theme="dark"] .lib-thumb-wrap { background: #0f0f1a; }

[data-bs-theme="dark"] .lib-paste-zone {
  background: #1a1a2e;
  border-bottom-color: #2e2e4a;
}

[data-bs-theme="dark"] .log-controls {
  background: #1a1a2e;
  border-color: #2e2e4a;
}

[data-bs-theme="dark"] .log-output {
  background: #0a0a14;
  border-color: #2e2e4a;
}



/* ── Utilities ── */
@media (max-width: 576px) {
  .btn-group .btn {
    font-size: .75rem;
    padding: .35rem .3rem;
  }
}
