/* =============================================================
   Digital Cat Library — Main Stylesheet
   Clean and minimal. No external dependencies.
   ============================================================= */

/* --- Custom properties ---------------------------------------- */
:root {
    --bg:           #f8f7f4;
    --surface:      #ffffff;
    --border:       #e0ddd6;
    --border-light: #ece9e3;
    --text:         #1c1b19;
    --text-muted:   #6b6560;
    --text-faint:   #9b958e;
    --accent:       #2a5a8c;
    --accent-dark:  #1d4068;
    --accent-bg:    #eef4fb;
    --accent-border:#c5d9f0;
    --success:      #15803d;
    --success-bg:   #f0fdf4;
    --success-border:#bbf7d0;
    --danger:       #b91c1c;
    --danger-bg:    #fef2f2;
    --danger-border:#fecaca;
    --radius:       4px;
    --radius-lg:    8px;
    --shadow-sm:    0 1px 3px rgba(0,0,0,.07);
    --container:    1120px;
    --font-sans:    -apple-system, BlinkMacSystemFont, 'Segoe UI',
                    system-ui, 'Helvetica Neue', Arial, sans-serif;
}

/* --- Reset ---------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
img  { max-width: 100%; display: block; }

/* --- Base ---------------------------------------------------- */
body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Layout -------------------------------------------------- */
.container { max-width: var(--container); margin: 0 auto; padding: 0 1.5rem; }
.main-content { flex: 1; padding-top: 2.25rem; padding-bottom: 3.5rem; }

/* --- Site header --------------------------------------------- */
.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: .9rem 0;
    position: sticky; top: 0; z-index: 100;
}
.header-inner {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.site-brand {
    font-size: 1rem;
    font-weight: 650;
    color: var(--text);
    letter-spacing: -.01em;
    white-space: nowrap;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.site-logo {
    height: 28px;
    width: auto;
    display: block;
    flex-shrink: 0;
}
.site-brand:hover { text-decoration: none; }
.site-nav {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    font-size: .875rem;
}
.site-nav a { color: var(--text-muted); }
.site-nav a:hover { color: var(--text); text-decoration: none; }
.nav-sep { width: 1px; height: 1rem; background: var(--border); }
.nav-user { color: var(--text-faint); font-size: .82rem; }
.nav-logout { color: var(--text-muted); }

/* --- Footer -------------------------------------------------- */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 1.25rem 0;
    font-size: .82rem;
    color: var(--text-faint);
    margin-top: auto;
}

/* --- Flash messages ------------------------------------------ */
.flash-messages { margin-bottom: 1.75rem; }
.flash {
    padding: .75rem 1rem;
    border-radius: var(--radius);
    font-size: .875rem;
    margin-bottom: .5rem;
    border: 1px solid transparent;
}
.flash--success { background: var(--success-bg); border-color: var(--success-border); color: var(--success); }
.flash--error   { background: var(--danger-bg);  border-color: var(--danger-border);  color: var(--danger); }
.flash--info    { background: var(--accent-bg);  border-color: var(--accent-border);  color: var(--accent); }

/* --- Buttons ------------------------------------------------- */
.btn {
    display: inline-block;
    padding: .5rem 1.25rem;
    border-radius: var(--radius);
    font-size: .875rem;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    text-align: center;
    transition: background .12s, border-color .12s, color .12s;
    font-family: inherit;
    line-height: 1.4;
    text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn--primary   { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn--primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.btn--secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn--secondary:hover { background: var(--bg); }
.btn--ghost     { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn--ghost:hover { background: var(--bg); color: var(--text); }
.btn--full      { width: 100%; display: block; }
.btn--small     { padding: .3rem .75rem; font-size: .8rem; }

/* --- Form controls ------------------------------------------- */
label {
    display: block;
    font-size: .82rem;
    font-weight: 550;
    color: var(--text-muted);
    margin-bottom: .3rem;
    letter-spacing: .01em;
}
input[type="text"],
input[type="number"],
input[type="password"],
input[type="email"],
select,
textarea {
    display: block;
    width: 100%;
    padding: .5rem .75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .9rem;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    appearance: none;
    transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(42,90,140,.12);
}
textarea { resize: vertical; line-height: 1.6; }
.checkbox-label {
    display: flex; align-items: center; gap: .5rem;
    font-size: .875rem; font-weight: 400; color: var(--text); cursor: pointer;
}
.checkbox-label input[type="checkbox"] { width: auto; }
.field-hint { font-size: .78rem; color: var(--text-faint); margin-top: .35rem; }

/* --- Auth page ----------------------------------------------- */
.auth-wrap { max-width: 400px; margin: 4rem auto; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 2rem; }
.login-logo {
    height: 80px;
    width: auto;
    margin: 0 auto 1.25rem;
}
.auth-title { font-size: 1.4rem; font-weight: 650; text-align: center; margin-bottom: .35rem; }
.auth-subtitle { color: var(--text-muted); text-align: center; font-size: .9rem; margin-bottom: 1.75rem; }
.auth-form .field-group { margin-bottom: .9rem; }
.auth-form .checkbox-label { margin-top: .25rem; }
.auth-form .btn { margin-top: 1.25rem; }

/* --- Page header --------------------------------------------- */
.page-header { margin-bottom: 2rem; }
.page-header h1 { font-size: 1.4rem; font-weight: 650; margin-bottom: .35rem; }
.page-subtitle { color: var(--text-muted); font-size: .9rem; }

/* --- Search form --------------------------------------------- */
.search-form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
}

/* General search sits above the grid with breathing room */
.general-search-section { margin-bottom: 1.5rem; }
.search-hint { font-size: .8rem; color: var(--text-faint); margin-top: .5rem; }

/* Divider between general and specific fields */
.field-divider {
    display: flex; align-items: center; gap: 1rem;
    margin-bottom: 1.5rem;
    color: var(--text-faint); font-size: .78rem;
}
.field-divider::before,
.field-divider::after {
    content: ''; flex: 1;
    border-top: 1px solid var(--border-light);
}

.search-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem 2rem;
}
.field-group { display: flex; flex-direction: column; }
.field-group--year { grid-column: span 1; display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.field-group--year > div { display: flex; flex-direction: column; }
.search-actions { display: flex; gap: .75rem; margin-top: 1.75rem; border-top: 1px solid var(--border-light); padding-top: 1.5rem; align-items: center; flex-wrap: wrap; }

/* Custom dropdown arrow — makes selects obviously clickable */
.select-wrap { position: relative; }
.select-wrap select { padding-right: 2.25rem; }
.select-wrap::after {
    content: '';
    position: absolute; right: .8rem; top: 50%; transform: translateY(-50%);
    pointer-events: none;
    width: 0; height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--text-muted);
}

/* --- Results header ------------------------------------------ */
.results-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 1rem; margin-bottom: 1.5rem;
}
.results-header h2 { font-size: 1.1rem; font-weight: 600; }
.filter-summary { margin-top: .4rem; font-size: .825rem; color: var(--text-muted); }
.filter-tag {
    display: inline-block; margin-right: .5rem;
    background: var(--bg); border: 1px solid var(--border);
    border-radius: 20px; padding: .1rem .6rem; font-size: .78rem;
}

/* --- Results list -------------------------------------------- */
.results-list { border-top: 1px solid var(--border); }
.result-item { padding: 1.25rem 0; border-bottom: 1px solid var(--border-light); }
.result-title { font-size: .975rem; font-weight: 550; line-height: 1.45; margin-bottom: .35rem; }
.result-title a { color: var(--text); }
.result-title a:hover { color: var(--accent); }
.result-meta { font-size: .82rem; color: var(--text-muted); margin-bottom: .3rem; }
.meta-dot { margin: 0 .4rem; color: var(--text-faint); }
.result-type { font-style: italic; }
.result-venue { font-size: .85rem; color: var(--text-muted); margin-bottom: .5rem; }
.result-actions { display: flex; align-items: center; gap: 1rem; margin-top: .35rem; }
.link-details { font-size: .82rem; color: var(--accent); }
.link-pdf {
    font-size: .78rem; font-weight: 550;
    background: var(--accent); color: #fff;
    padding: .2rem .65rem; border-radius: var(--radius);
}
.link-pdf:hover { background: var(--accent-dark); text-decoration: none; color: #fff; }

.empty-state { padding: 4rem 0; text-align: center; }
.empty-state p { color: var(--text-muted); margin-bottom: 1rem; }

/* --- Pagination ---------------------------------------------- */
.pagination {
    display: flex; align-items: center; justify-content: center;
    gap: 1.5rem; margin-top: 2.5rem;
}
.page-link { font-size: .875rem; }
.page-current { font-size: .82rem; color: var(--text-muted); }

/* --- Breadcrumb ---------------------------------------------- */
.breadcrumb { font-size: .82rem; color: var(--text-faint); margin-bottom: 1.5rem; }
.breadcrumb a { color: var(--text-faint); }
.breadcrumb a:hover { color: var(--accent); }
.bc-sep { margin: 0 .4rem; }

/* --- Record page --------------------------------------------- */
.type-badge {
    display: inline-block;
    font-size: .72rem; font-weight: 600;
    letter-spacing: .06em; text-transform: uppercase;
    color: var(--accent); background: var(--accent-bg);
    border: 1px solid var(--accent-border);
    padding: .2rem .65rem; border-radius: 20px;
    margin-bottom: .85rem;
}
.record-title { font-size: 1.55rem; font-weight: 650; line-height: 1.35; margin-bottom: .7rem; }
.record-authors { font-size: 1rem; color: var(--text-muted); margin-bottom: .2rem; }
.record-editors { font-size: .875rem; color: var(--text-muted); font-style: italic; }
.record-header  { margin-bottom: 2.25rem; }
.record-body    { display: grid; grid-template-columns: 1fr 280px; gap: 3.5rem; align-items: start; }
.record-section { margin-bottom: 2rem; }
.section-label  {
    font-size: .72rem; font-weight: 650;
    letter-spacing: .07em; text-transform: uppercase;
    color: var(--text-faint); margin-bottom: .75rem;
}
.record-abstract { font-size: .95rem; line-height: 1.8; }
.record-notes    { font-size: .875rem; color: var(--text-muted); line-height: 1.7; }

.keyword-list { display: flex; flex-wrap: wrap; gap: .4rem; }
.keyword {
    font-size: .78rem; padding: .2rem .65rem;
    border-radius: 20px; border: 1px solid var(--border);
    color: var(--text-muted); background: var(--bg);
}
.keyword--geographic { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.keyword--species    { background: #fefce8; border-color: #fde68a; color: #854d0e; }
.keyword--subject    { background: var(--accent-bg); border-color: var(--accent-border); color: var(--accent); }

/* Sidebar */
.pdf-download-btn { margin-bottom: 1.5rem; font-size: .9rem; }
.record-meta-list { font-size: .85rem; }
.record-meta-list dt {
    font-size: .72rem; font-weight: 650;
    letter-spacing: .06em; text-transform: uppercase;
    color: var(--text-faint); margin-top: 1.1rem;
}
.record-meta-list dd { margin: .2rem 0 0; line-height: 1.5; }
.meta-note { color: var(--text-muted); font-style: italic; }
.admin-record-tools { margin-top: 1.75rem; padding-top: 1rem; border-top: 1px solid var(--border-light); }

/* --- Admin --------------------------------------------------- */
.admin-page { }
.admin-page h1 { font-size: 1.35rem; font-weight: 650; margin-bottom: 1.75rem; }
.admin-page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.admin-page-header h1 { margin-bottom: 0; }
.count-note { font-size: .875rem; font-weight: 400; color: var(--text-muted); }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 2rem; }
.stat-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 1.35rem; text-align: center;
}
.stat-card--muted .stat-number { color: var(--text-muted); }
.stat-number { font-size: 2.25rem; font-weight: 700; color: var(--accent); line-height: 1; }
.stat-label  { font-size: .8rem; color: var(--text-muted); margin-top: .45rem; }
.admin-quick-links { display: flex; gap: .75rem; }

.admin-filter-form { display: flex; gap: .75rem; margin-bottom: 1.25rem; align-items: center; }
.admin-filter-input { max-width: 380px; }

.table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.admin-table th {
    text-align: left; padding: .6rem .75rem;
    font-size: .72rem; font-weight: 650;
    letter-spacing: .06em; text-transform: uppercase;
    color: var(--text-muted); border-bottom: 2px solid var(--border);
}
.admin-table td { padding: .65rem .75rem; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
.admin-table .col-id    { width: 55px; color: var(--text-faint); font-size: .8rem; }
.admin-table .col-title { max-width: 380px; }
.admin-table .row-hidden td { opacity: .45; }

.indicator { font-size: .85rem; font-weight: 600; }
.indicator--yes { color: var(--success); }
.indicator--no  { color: var(--text-faint); }

.toggle-btn {
    font-size: .78rem; font-weight: 550;
    padding: .2rem .65rem; border-radius: 20px;
    border: 1px solid; cursor: pointer; font-family: inherit;
    transition: background .1s;
}
.toggle-btn--on  { background: var(--success-bg); border-color: var(--success-border); color: var(--success); }
.toggle-btn--off { background: var(--bg); border-color: var(--border); color: var(--text-muted); }
.toggle-btn:hover { filter: brightness(.97); }

/* --- Edit form ----------------------------------------------- */
.form-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 1.5rem; margin-bottom: 1.25rem;
}
.form-card-title {
    font-size: .75rem; font-weight: 650;
    letter-spacing: .07em; text-transform: uppercase;
    color: var(--text-muted); margin-bottom: 1.1rem;
}
.field-group { margin-bottom: .9rem; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.field-row--4 { grid-template-columns: repeat(4, 1fr); }
.form-actions { display: flex; gap: .75rem; align-items: center; padding-top: .5rem; }

/* --- Utility ------------------------------------------------- */
em { font-style: italic; }