/* ============================================================
   Nginx-Fancyindex-Theme — modernized stylesheet
   - System font stack (no external font dependency → works offline)
   - CSS variables for light / dark mode
   - Card-style listing, refined search box, smooth hover states
   ============================================================ */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #2b2f36;
  --text-muted: #8a929e;
  --border: #e8ebf0;
  --accent: #3b82f6;
  --accent-strong: #2563eb;
  --row-hover: #f1f5fb;
  --row-stripe: #eef2f8;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 10px 30px rgba(16, 24, 40, .05);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a21;
    --text: #e6e9ef;
    --text-muted: #8b93a3;
    --border: #262b34;
    --accent: #60a5fa;
    --accent-strong: #93c5fd;
    --row-hover: #1d212a;
    --row-stripe: #1c212b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 10px 30px rgba(0, 0, 0, .35);
  }
}

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

html {
  font-size: 16px;
  color: var(--text);
  line-height: 1.6;
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI',
    Roboto, 'Helvetica Neue', Arial, 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

body {
  padding: 40px 16px 56px;
  background: var(--bg);
}

a {
  color: var(--accent-strong);
  text-decoration: none;
  transition: color .2s ease;
}

a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* ---------- Layout ---------- */
.wrapper {
  max-width: 880px;
  margin: 0 auto;
}

.site-header {
  text-align: center;
  margin-bottom: 6px;
}

/* ---------- Directory breadcrumb (same line) ---------- */
.dir-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
  margin: 24px 6px 14px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: .95rem;
}

.dir-label {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--text-muted);
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: .9rem;
  line-height: 1.4;
  word-break: break-all;
}

.breadcrumb a {
  color: var(--accent-strong);
}

.breadcrumb a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.breadcrumb .sep {
  color: var(--text-muted);
  user-select: none;
  white-space: pre;
}

/* ---------- Search ---------- */
.search-form {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 16px 0 4px;
}

input[type="search"] {
  display: block;
  width: min(380px, 100%);
  margin: 0;
  padding: 11px 18px;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  outline: none;
  box-shadow: var(--shadow);
  transition: border-color .2s ease, box-shadow .2s ease;
}

input[type="search"]::placeholder {
  color: var(--text-muted);
}

input[type="search"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, .18);
}

input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

/* 返回根目录按钮 */
.home-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: 999px;
  box-shadow: var(--shadow);
  white-space: nowrap;
  transition: background .2s ease, transform .1s ease;
}

.home-btn:hover {
  color: #fff;
  background: var(--accent-strong);
  text-decoration: none;
}

.home-btn:active {
  transform: translateY(1px);
}

.home-btn svg {
  display: block;
}

/* 返回上一级目录按钮（outline 风格，与根目录按钮区分） */
.up-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow);
  white-space: nowrap;
  transition: background .2s ease, transform .1s ease, border-color .2s ease;
}

.up-btn:hover {
  color: var(--accent-strong);
  border-color: var(--accent);
  background: var(--row-hover);
  text-decoration: none;
}

.up-btn:active {
  transform: translateY(1px);
}

.up-btn svg {
  display: block;
}

@media (max-width: 480px) {
  .home-btn span {
    display: none;   /* 窄屏只留图标 */
  }
  .home-btn {
    padding: 10px 12px;
  }
  .up-btn span {
    display: none;
  }
  .up-btn {
    padding: 10px 12px;
  }
}

/* ---------- Search results (recursive) ---------- */
#search-results {
  margin-top: 4px;
}

.search-status {
  margin: 6px 6px 12px;
  font-size: .82rem;
  color: var(--text-muted);
}

table.results {
  margin-top: 10px;
}

/* ---------- Listing table ---------- */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  font-size: .92rem;
}

thead th {
  text-align: left;
  font-weight: 600;
  font-size: .72rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 14px 16px;
  background: color-mix(in srgb, var(--surface) 92%, var(--border));
  border-bottom: 1px solid var(--border);
}

th + th { width: 22%; }
th + th + th + th { width: 6%; }

tr {
  outline: 0;
  border: 0;
  transition: background .2s ease;
}

/* 隔行底色（斑马纹） */
tbody tr:nth-child(even) td {
  background: var(--row-stripe);
}

tbody tr:hover td {
  background: var(--row-hover);
}

/* Parent directory link: replace nginx's "../" text with a readable label */
tr.parent a {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0;                 /* hide the original "../" text */
}

tr.parent a::before {
  content: "Parent directory/";
  font-size: 0.92rem;           /* restore a readable size */
}

tr.parent a:hover {
  color: var(--accent-strong);
}

td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  text-align: left;
  color: var(--text);
}

tr:last-child td {
  border-bottom: 0;
}

td a {
  display: block;
  font-weight: 500;
}

td:last-child,
th:last-child {
  text-align: right;
  padding-right: 16px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
  body { padding: 28px 12px 40px; }
  table { font-size: .85rem; }
  td, thead th { padding: 10px 12px; }
}
