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

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #F4F5F7;
  --surface: #FFFFFF;
  --border: #E5E7EB;
  --accent: #006FFF;
  --accent-hover: #0060E6;
  --danger: #DC2626;
  --text: #1A1A1A;
  --text-muted: #6B7280;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
}

body {
  font-family: 'Lato', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: 52px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-header .logo {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.2px;
}

.app-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  padding: 0 24px;
}

.nav-crumb {
  font-size: 14px;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}
a.nav-crumb:hover { color: var(--accent); }

.nav-crumb-current {
  color: var(--text);
  font-weight: 600;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-sep {
  color: var(--border);
  font-size: 16px;
  user-select: none;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0;
}

.app-header .user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--text-muted);
}

/* ── Layout ── */
.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px;
}

/* ── Auth ── */
#auth-section {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 52px);
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px;
  width: 360px;
  box-shadow: var(--shadow);
}

.auth-card h2 {
  margin-bottom: 22px;
  font-size: 20px;
  font-weight: 700;
}

/* ── Forms ── */
.form-group {
  margin-bottom: 14px;
}

label {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="file"],
select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 8px 11px;
  font-size: 15px;
  font-family: 'Lato', sans-serif;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,111,255,0.1);
}

input[type="file"] {
  padding: 6px 11px;
  cursor: pointer;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  font-family: 'Lato', sans-serif;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-sm {
  padding: 5px 11px;
  font-size: 12px;
}

/* ── Alert (auth errors only) ── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  font-size: 14px;
}
.alert-error { background: #FEF2F2; border: 1px solid #FECACA; color: #B91C1C; }

/* ── Toast notifications ── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 340px;
  pointer-events: none;
}

.toast {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.4;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  pointer-events: all;
  animation: toastIn 0.2s ease;
  border-left: 3px solid var(--border);
}
.toast.toast-error   { border-left-color: var(--danger); color: #B91C1C; }
.toast.toast-success { border-left-color: #16A34A; color: #15803D; }
.toast.toast-info    { border-left-color: var(--accent); color: #1D4ED8; }

.toast-msg { flex: 1; }

.toast-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  padding: 0;
  font-family: inherit;
  flex-shrink: 0;
}
.toast-close:hover { color: var(--text); }

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

/* ── Spinner ── */
.spinner {
  width: 15px; height: 15px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Dashboard page header ── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.page-header h1 {
  font-size: 20px;
  font-weight: 700;
}

/* ── Uploads table ── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.uploads-table {
  width: 100%;
  border-collapse: collapse;
}

.uploads-table thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: #FAFAFA;
}

.uploads-table tbody tr {
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}
.uploads-table tbody tr:last-child { border-bottom: none; }
.uploads-table tbody tr:hover { background: #F9FAFB; }

.uploads-table tbody td {
  padding: 11px 16px;
  font-size: 14px;
  vertical-align: middle;
}

.uploads-table .col-name { font-weight: 600; }
.uploads-table .col-actions { text-align: right; width: 60px; }

/* ── Status pill ── */
.status-pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.status-pill.pending  { background: #F3F4F6; color: #6B7280; }
.status-pill.partial  { background: #EFF6FF; color: #1D4ED8; }
.status-pill.done     { background: #F0FDF4; color: #15803D; }


.prefix-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 14px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.prefix-row input {
  border: none;
  box-shadow: none;
  padding: 4px 0;
  font-size: 17px;
  font-weight: 600;
  flex: 1;
  color: var(--text);
  background: transparent;
}
.prefix-row input:focus { outline: none; box-shadow: none; border: none; }
.prefix-row input::placeholder { color: var(--text-muted); font-weight: 400; }

.prefix-saved {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.2s;
}
.prefix-saved.visible { opacity: 1; }

/* ── Upload section (drop zone) ── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 20px;
  background: var(--surface);
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent);
  background: #EFF6FF;
  color: var(--text);
}
.drop-zone .drop-icon { font-size: 30px; margin-bottom: 8px; }
.drop-zone p { font-size: 14px; }
.drop-zone .drop-hint { font-size: 12px; margin-top: 4px; color: var(--text-muted); }
.drop-zone input { display: none; }

/* ── Manage section ── */
.manage-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

/* ── Image grid ── */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.image-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  cursor: grab;
  transition: box-shadow 0.15s, border-color 0.15s;
  user-select: none;
  box-shadow: var(--shadow);
}
.image-card:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.image-card.sortable-chosen { box-shadow: 0 0 0 2px var(--accent); }
.image-card.sortable-ghost  { opacity: 0.3; }

.image-card .thumb-wrap {
  width: 100%;
  padding-top: 66%;
  position: relative;
  background: #F3F4F6;
  overflow: hidden;
}
.image-card .thumb-wrap img {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}

.image-card .card-info {
  padding: 6px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}
.image-card .card-name {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.image-card .order-badge {
  position: absolute;
  top: 5px; left: 5px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 99px;
}
.image-card .processed-badge {
  position: absolute;
  top: 5px; right: 5px;
  background: #16A34A;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 99px;
}

/* ── Process / download bar ── */
.process-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

/* ── Dialog (modal) ── */
@keyframes backdropIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes dialogIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: backdropIn 0.2s ease forwards;
}

.dialog {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  width: 480px;
  max-width: calc(100vw - 40px);
  padding: 24px;
  animation: dialogIn 0.2s ease forwards;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.dialog-header h2 { font-size: 16px; font-weight: 700; }
.dialog-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  padding: 2px 6px;
  font-family: inherit;
}
.dialog-close:hover { color: var(--text); }

/* ── Native confirm dialog ── */
#confirm-dialog {
  border: none;
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  padding: 24px;
  width: 340px;
  max-width: calc(100vw - 40px);
  font-family: inherit;
  position: fixed;
  top: 50%;
  left: 50%;
  translate: -50% -50%;
  margin: 0;
  animation: dialogIn 0.2s ease forwards;
}
#confirm-dialog::backdrop {
  background: rgba(0,0,0,0.35);
  animation: backdropIn 0.2s ease forwards;
}
#confirm-dialog p {
  margin: 0 0 20px;
  font-size: 15px;
  color: var(--text);
}
.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ── Admin settings card ── */
.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 560px;
  box-shadow: var(--shadow);
}
.settings-card h2 {
  margin-bottom: 20px;
  font-size: 17px;
  font-weight: 700;
}
.settings-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin: 18px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.settings-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.watermark-preview { margin-top: 10px; }
.watermark-preview img {
  max-height: 72px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: repeating-conic-gradient(#E5E7EB 0% 25%, #F3F4F6 0% 50%) 0 0 / 10px 10px;
}

/* ── Range slider ── */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  height: 4px;
}
input[type="range"]::-webkit-slider-runnable-track {
  background: var(--border);
  height: 4px;
  border-radius: 2px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  margin-top: -6px;
  background-color: var(--accent);
  height: 16px; width: 16px;
  border-radius: 50%;
}
.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.slider-row input[type="range"] { flex: 1; }
.slider-val {
  min-width: 36px;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  text-align: right;
}

/* ── Footer ── */
.app-footer {
  border-top: 1px solid var(--border);
  padding: 16px 24px;
  margin-top: auto;
}

.app-footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Misc ── */
.hidden { display: none !important; }

.empty-state {
  text-align: center;
  padding: 48px 0;
  color: var(--text-muted);
  font-size: 14px;
}
