/* ========== Reset & Base ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --bg: #f1f5f9;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ========== Login ========== */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  text-align: center;
}

.login-icon { font-size: 48px; margin-bottom: 12px; }
.login-logo { width: 56px; height: 56px; margin-bottom: 12px; border-radius: 8px; }
.login-card h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.login-desc { color: var(--text-muted); margin-bottom: 28px; font-size: 14px; }

.login-card input {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
  margin-bottom: 12px;
}
.login-card input:focus { border-color: var(--primary); }

.error-msg {
  color: var(--danger);
  font-size: 13px;
  margin-top: 12px;
  padding: 8px 12px;
  background: #fef2f2;
  border-radius: 6px;
}

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  gap: 6px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: #f1f5f9; color: var(--text); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 14px; font-size: 13px; }

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 16px;
  transition: background 0.2s;
}
.btn-icon:hover { background: #f1f5f9; }
.btn-danger:hover { background: #fef2f2; }

/* ========== App Layout ========== */
.app { min-height: 100vh; }

.header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header h1 { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.header-logo { width: 28px; height: 28px; border-radius: 4px; flex-shrink: 0; }
.header-right { display: flex; align-items: center; gap: 10px; }

/* ========== User Badge ========== */
.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
}
.badge-role {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.badge-role.admin { background: #fef3c7; color: #92400e; }
.badge-role.uploader { background: #dbeafe; color: #1e40af; }

/* ========== Tabs ========== */
.tabs {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  background: var(--card-bg);
}
.tab {
  padding: 14px 20px;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.main {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px;
}
.tab-panel { display: block; }

/* ========== Cards ========== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 16px; font-weight: 700; margin-bottom: 20px; }

/* ========== Drop Zone ========== */
.drop-zone {
  border: 2px dashed #cbd5e1;
  border-radius: 10px;
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--primary);
  background: #eff6ff;
}
.drop-zone-icon { color: #94a3b8; margin-bottom: 12px; }
.drop-zone-text { font-size: 15px; color: var(--text-muted); margin-bottom: 6px; }
.drop-zone-text .link { color: var(--primary); font-weight: 500; }
.drop-zone-hint { font-size: 12px; color: #94a3b8; }

/* ========== Progress ========== */
.progress-section { margin-top: 20px; }
.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 500;
}
.progress-bar {
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.3s ease;
}
.progress-fill.error { background: var(--danger); }
.progress-fill.processing {
  background: linear-gradient(90deg, var(--primary) 0%, #60a5fa 50%, var(--primary) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.upload-status { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* ========== Result ========== */
.result-section { margin-top: 20px; }
.result-label { font-size: 13px; font-weight: 600; color: #16a34a; margin-bottom: 8px; }
.result-url-row { display: flex; gap: 8px; }
.result-url {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text);
  background: #f8fafc;
  outline: none;
  font-family: 'SF Mono', 'Fira Code', monospace;
}
.result-url:focus { border-color: var(--primary); }
.copy-tip { font-size: 12px; color: #16a34a; margin-top: 6px; }

/* Small inline URL input for today's table */
.small-url {
  width: 100%;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 11px;
  font-family: monospace;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  cursor: pointer;
}
.small-url:focus { border-color: var(--primary); outline: none; }

/* URL row inside table cell */
.cell-url-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.cell-url-row .small-url { flex: 1; min-width: 0; }
.copy-btn-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #f8fafc;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
  transition: all 0.2s;
  color: var(--text-muted);
}
.copy-btn-sm:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.copy-btn-sm.copied { background: #16a34a; color: #fff; border-color: #16a34a; }

/* Copy button accent style for page generation */
.btn-copy-accent {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border: 1.5px solid var(--primary);
  border-radius: 8px;
  background: #eff6ff;
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-copy-accent:hover { background: var(--primary); color: #fff; }
.btn-copy-accent.copied { background: #16a34a; color: #fff; border-color: #16a34a; }

/* ========== History ========== */
.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.history-header h2 { margin-bottom: 0; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); font-size: 14px; }
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
tbody td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: none; }

.td-name { max-width: 180px; font-weight: 500; }
.td-url { max-width: 260px; }
.td-user { font-weight: 500; }
.td-nickname { white-space: nowrap; }
.td-nickname .btn-icon { font-size: 13px; opacity: 0.5; }
.td-nickname:hover .btn-icon { opacity: 1; }
.url-link {
  color: var(--primary);
  text-decoration: none;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  word-break: break-all;
}
.url-link:hover { text-decoration: underline; }
.td-size { white-space: nowrap; color: var(--text-muted); }
.td-time { white-space: nowrap; color: var(--text-muted); }
.td-actions { white-space: nowrap; }

/* ========== Pagination ========== */
.pagination {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-top: 16px;
}
.page-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}
.page-btn:hover { background: #f1f5f9; }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ========== Modal ========== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(2px);
}
.modal-card {
  position: relative;
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  z-index: 1;
}
.modal-card h3 { font-size: 18px; font-weight: 700; margin-bottom: 20px; }
.modal-card label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
  margin-top: 12px;
}
.modal-card label:first-of-type { margin-top: 0; }
.modal-card label small { font-weight: 400; color: #94a3b8; }
.modal-card input, .modal-card select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  margin-top: 4px;
}
.modal-card input:focus, .modal-card select:focus { border-color: var(--primary); }
.modal-card p { font-size: 14px; margin-bottom: 12px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
}
.modal-card .error-msg { margin-top: 8px; }

/* ========== Toast ========== */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1e293b;
  color: #fff;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 14px;
  opacity: 0;
  transition: all 0.3s;
  pointer-events: none;
  z-index: 1000;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ========== Responsive ========== */
@media (max-width: 640px) {
  .login-card { padding: 32px 24px; }
  .main { padding: 16px; }
  .card { padding: 20px; }
  .drop-zone { padding: 32px 16px; }
  .result-url-row { flex-direction: column; }
  .header-inner { padding: 12px 16px; }
  .header h1 { font-size: 15px; }
  .header-right { gap: 6px; }
  .td-url { max-width: 160px; }
  .tabs { padding: 0 16px; }
  .tab { padding: 12px 14px; font-size: 13px; }
}
