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

:root {
  --bg-primary:     #faf9f7;
  --bg-card:        #ffffff;
  --bg-card-hover:  #f7f6f3;
  --accent:         #d97706;
  --accent-hover:   #b45309;
  --accent-light:   #fef3c7;
  --text-primary:   #1a1a1a;
  --text-secondary: #6b7280;
  --text-muted:     #9ca3af;
  --border:         #e5e3df;
  --border-focus:   #d97706;
  --shadow-sm:      0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:      0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg:      0 10px 30px rgba(0,0,0,0.1), 0 4px 8px rgba(0,0,0,0.06);
  --radius:         12px;
  --radius-sm:      8px;
  --radius-xs:      6px;
  --font:           'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

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

a { color: inherit; text-decoration: none; }

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

/* ── Header ── */
.site-header {
  background: rgba(250, 249, 247, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
  transition: opacity 0.15s;
}
.site-logo:hover { opacity: 0.7; }
.site-logo svg { color: var(--accent); flex-shrink: 0; }

.header-admin-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-xs);
  transition: background 0.15s, color 0.15s;
}
.header-admin-link:hover {
  background: var(--border);
  color: var(--text-primary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-light);
  padding: 2px 8px;
  border-radius: 99px;
  letter-spacing: 0.03em;
}

/* ── Main Content ── */
.main-content {
  padding-top: 48px;
  padding-bottom: 80px;
}

.page-header {
  margin-bottom: 32px;
}

.page-title {
  font-size: 28px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.page-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  margin-top: 6px;
}

/* ── File Grid ── */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

/* ── Card ── */
.card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.15s;
  cursor: pointer;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  background: var(--bg-card-hover);
}

.card:active { transform: translateY(0); }

.card-icon {
  width: 44px;
  height: 44px;
  background: var(--accent-light);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
}

.card-body { flex: 1; min-width: 0; }

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-date {
  font-size: 12px;
  color: var(--text-muted);
  display: block;
  margin-top: 8px;
}

.lock-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 26px;
  height: 26px;
  background: var(--accent-light);
  border-radius: 99px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

/* ── Empty State ── */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 64px 24px;
  color: var(--text-muted);
}

.empty-state svg { margin-bottom: 16px; opacity: 0.4; }
.empty-state p { font-size: 16px; margin-bottom: 6px; }
.empty-hint { font-size: 13px; }
.empty-hint code {
  background: var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  color: var(--text-secondary);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, opacity 0.15s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

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

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-card-hover); color: var(--text-primary); }

.btn-danger {
  background: transparent;
  color: #dc2626;
  border: 1px solid #fca5a5;
}
.btn-danger:hover:not(:disabled) { background: #fef2f2; }

.btn-sm { font-size: 13px; padding: 5px 10px; }
.btn-full { width: 100%; justify-content: center; }

.btn-spinner { display: inline-flex; }

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

.input {
  width: 100%;
  font-family: var(--font);
  font-size: 15px;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.12);
}
.input::placeholder { color: var(--text-muted); }

.form-error {
  font-size: 13px;
  color: #dc2626;
  margin-top: 6px;
  min-height: 18px;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
.input--shake { animation: shake 0.4s ease; }

/* ── Modal (dialog) ── */
dialog.modal {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  max-width: 400px;
  width: calc(100% - 32px);
  box-shadow: var(--shadow-lg);
  background: var(--bg-card);
}

dialog.modal::backdrop {
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
}

.modal-content { padding: 32px; }

.modal-icon {
  width: 48px;
  height: 48px;
  background: var(--accent-light);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  margin-bottom: 16px;
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}

.modal-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ── Auth Pages ── */
.auth-body { display: flex; flex-direction: column; }

.auth-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-md);
}

.auth-icon {
  width: 56px;
  height: 56px;
  background: var(--accent-light);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  margin-bottom: 20px;
}

.auth-icon--admin {
  background: #ede9fe;
  color: #7c3aed;
}

.auth-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 4px;
}

.auth-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.auth-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 20px;
  transition: color 0.15s;
}
.auth-back:hover { color: var(--text-primary); }

/* ── Viewer Bar ── */
.viewer-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.breadcrumb-sep { color: var(--text-muted); flex-shrink: 0; }

.viewer-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.viewer-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ── Admin Layout ── */
.admin-body { background: var(--bg-primary); }

.admin-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 24px;
  padding-top: 32px;
  padding-bottom: 48px;
  min-height: calc(100vh - 56px);
  align-items: start;
}

.admin-sidebar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  position: sticky;
  top: 72px;
}

.sidebar-section { padding: 20px; border-bottom: 1px solid var(--border); }
.sidebar-section:last-child { border-bottom: none; }

.sidebar-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.file-list { display: flex; flex-direction: column; gap: 2px; }

.file-list-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: background 0.12s;
  font-size: 13px;
  color: var(--text-secondary);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.file-list-item:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.file-list-item.active { background: var(--accent-light); color: var(--accent); font-weight: 500; }

.file-list-item-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-list-lock { flex-shrink: 0; color: var(--accent); }

/* ── Skeleton ── */
.skeleton-list { display: flex; flex-direction: column; gap: 8px; }
.skeleton {
  height: 36px;
  background: linear-gradient(90deg, var(--border) 25%, var(--bg-card-hover) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-xs);
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Admin Detail ── */
.admin-detail {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  min-height: 400px;
}

.detail-empty {
  height: 300px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
}
.detail-empty svg { opacity: 0.3; }

.detail-header { margin-bottom: 28px; }

.detail-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 4px;
}

.detail-meta {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.detail-section {
  margin-bottom: 28px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}
.detail-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.detail-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 99px;
}
.status-pill--protected { background: var(--accent-light); color: var(--accent); }
.status-pill--public { background: #d1fae5; color: #059669; }

.form-row { display: flex; gap: 8px; align-items: flex-start; }
.form-row .input { flex: 1; }
.form-row .btn { flex-shrink: 0; margin-top: 0; }

.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 20px; }

/* ── Upload Area ── */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 20px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  transition: border-color 0.15s, background 0.15s;
  cursor: default;
}
.upload-area.dragover {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}
.upload-area svg { margin-bottom: 8px; opacity: 0.5; }
.upload-area p { margin-bottom: 4px; }
.upload-hint { opacity: 0.7; }
.upload-label { cursor: pointer; margin-top: 8px; }

.upload-progress { margin-top: 12px; }
.progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 6px;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.2s;
  width: 0%;
}
.progress-text { font-size: 12px; color: var(--text-muted); text-align: center; }

/* ── Toast ── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
}

.toast {
  background: var(--text-primary);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast--success { background: #059669; }
.toast--error { background: #dc2626; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Spinner ── */
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
.spin { animation: spin 0.8s linear infinite; }

/* ── Footer ── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 0;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

/* Mobile nav tab — hidden by default, shown by JS on small screens */
#mobile-nav-wrap { display: none; }

/* ── Responsive ── */

/* Tablet: 2-col card grid */
@media (max-width: 900px) {
  .admin-layout {
    grid-template-columns: 260px 1fr;
    gap: 16px;
  }
}

/* Mobile: stack everything */
@media (max-width: 720px) {
  .container { padding: 0 16px; }

  /* Header */
  .header-admin-link { display: none; }
  .admin-badge { display: none; }

  /* Home page */
  .main-content { padding-top: 28px; padding-bottom: 48px; }
  .page-title { font-size: 22px; }
  .file-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .card { padding: 14px; gap: 8px; }
  .card-icon { width: 36px; height: 36px; }
  .card-title { font-size: 13px; }
  .card-desc { display: none; }
  .card-date { margin-top: 4px; font-size: 11px; }

  /* Admin layout: stack sidebar above detail */
  .admin-layout {
    grid-template-columns: 1fr;
    padding-top: 16px;
    gap: 12px;
  }
  .admin-sidebar {
    position: static;
  }
  .admin-detail {
    padding: 20px 16px;
    min-height: auto;
  }

  /* Admin: hide detail panel by default on mobile, show via JS toggle */
  .admin-detail.mobile-hidden { display: none; }
  .admin-sidebar.mobile-hidden { display: none; }

  .mobile-nav {
    display: flex;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 12px;
  }
  .mobile-nav-btn {
    flex: 1;
    padding: 10px;
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font);
    background: var(--bg-card);
    color: var(--text-secondary);
    border: none;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
  }
  .mobile-nav-btn.active {
    background: var(--accent-light);
    color: var(--accent);
  }

  /* Auth */
  .auth-card { padding: 24px 20px; }
  .auth-main { padding: 24px 16px; align-items: flex-start; padding-top: 40px; }

  /* Modal */
  .modal-content { padding: 24px 20px; }

  /* Detail sections */
  .form-row { flex-direction: column; }
  .form-row .btn { width: 100%; justify-content: center; }
  .detail-meta { flex-direction: column; gap: 4px; }
}

/* Very small phones */
@media (max-width: 400px) {
  .file-grid { grid-template-columns: 1fr; }
  .card { flex-direction: row; align-items: center; padding: 12px; gap: 12px; }
  .card-icon { flex-shrink: 0; }
  .lock-badge { top: 8px; right: 8px; width: 22px; height: 22px; }
}
