/* ===================================================
   BibWeb – style.css
   =================================================== */

/* === 1. Design Tokens === */
:root {
    --color-primary:        #1d4ed8;
    --color-primary-hover:  #1e40af;
    --color-secondary:      #64748b;
    --color-secondary-hover:#475569;
    --color-success:        #16a34a;
    --color-success-hover:  #15803d;
    --color-danger:         #dc2626;
    --color-danger-hover:   #b91c1c;
    --color-warning:        #d97706;

    --color-bg:             #f1f5f9;
    --color-surface:        #ffffff;
    --color-border:         #e2e8f0;
    --color-border-strong:  #cbd5e1;
    --color-border-focus:   #93c5fd;
    --color-text:           #0f172a;
    --color-text-muted:     #64748b;
    --color-link:           #1d4ed8;
    --color-link-hover:     #1e40af;
    --color-row-hover:      #dbeafe;
    --color-row-alt:        #eff6ff;
    --color-btn-border:     #334155;

    --color-nav-bg:         #1e3a5f;
    --color-nav-text:       #f8fafc;
    --color-nav-link:       #cbd5e1;
    --color-nav-link-hover: #ffffff;

    --space-xs:  .25rem;
    --space-sm:  .5rem;
    --space-md:  1rem;
    --space-lg:  1.5rem;
    --space-xl:  2rem;
    --space-2xl: 3rem;

    --radius-sm: .25rem;
    --radius-md: .375rem;
    --radius-lg: .5rem;

    --font-family:    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    --font-size-xs:   .75rem;
    --font-size-sm:   .875rem;
    --font-size-base: 1rem;
    --font-size-lg:   1.125rem;
    --font-size-xl:   1.25rem;
    --font-size-2xl:  1.5rem;
    --font-size-3xl:  1.875rem;

    --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,.07);
    --shadow-lg: 0 10px 15px rgba(0,0,0,.1);

    --container-max:    1400px;
    --container-narrow: 960px;
    --nav-height:       3.5rem;
}

/* === 2. Reset === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}
html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.6;
    min-height: 100vh;
}
a { color: var(--color-link); text-decoration: none; }
a:hover { color: var(--color-link-hover); text-decoration: underline; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
h1, h2, h3 { line-height: 1.3; font-weight: 600; }
h1 { font-size: var(--font-size-2xl); }
h2 { font-size: var(--font-size-xl); }
h3 { font-size: var(--font-size-lg); }

/* === 3. Layout === */
.container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 var(--space-lg);
}
.container--narrow { max-width: var(--container-narrow); }
.page-content { padding: var(--space-xl) 0 var(--space-2xl); }

/* === 4. Navigation === */
.site-nav {
    background: var(--color-nav-bg);
    height: var(--nav-height);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-md);
}
.site-nav .container {
    display: flex;
    align-items: center;
    height: 100%;
    gap: var(--space-xl);
}
.site-nav__brand {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--color-nav-text);
    letter-spacing: .03em;
    white-space: nowrap;
}
.site-nav__brand:hover { color: var(--color-nav-link-hover); text-decoration: none; }

.site-nav__links {
    display: flex;
    gap: var(--space-sm);
    list-style: none;
}
.site-nav__links a {
    color: var(--color-nav-link);
    font-size: var(--font-size-sm);
    font-weight: 500;
    padding: .375rem var(--space-sm);
    border-radius: var(--radius-md);
    transition: color .15s, background .15s;
}
.site-nav__links a:hover,
.site-nav__links a.active {
    color: var(--color-nav-link-hover);
    background: rgba(255,255,255,.12);
    text-decoration: none;
}
.site-nav__user {
    margin-left: auto;
    color: var(--color-nav-link);
    font-size: var(--font-size-sm);
    white-space: nowrap;
}
.site-nav__user a { color: var(--color-nav-link); }
.site-nav__user a:hover { color: var(--color-nav-link-hover); }

/* === 5. Page header === */
.page-header {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    flex-wrap: wrap;
}
.page-header h1 { flex: 1; min-width: 0; }
.page-header > .btn { flex-shrink: 0; margin-top: .2rem; }

.page-header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
    flex-shrink: 0;
    margin-top: .2rem;
}

.page-title-block { flex: 1; min-width: 0; }
.subtitle {
    color: var(--color-text-muted);
    font-size: var(--font-size-lg);
    margin-top: var(--space-xs);
    font-weight: 400;
}

/* === 6. Cards === */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: var(--space-lg);
    margin-bottom: var(--space-md);
}
.card-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--color-border-strong);
    color: var(--color-text);
}
.table-card { padding: 0; overflow: hidden; }
.card.search-card {
    padding: var(--space-md) var(--space-lg);
    border: 1.5px solid var(--color-secondary);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-lg);
}
.dashboard-card { display: flex; flex-direction: column; }
.dashboard-card h2 { font-size: var(--font-size-lg); margin-bottom: var(--space-xs); }
.dashboard-card p { color: var(--color-text-muted); margin-bottom: var(--space-md); flex: 1; }
.dashboard-card__actions { display: flex; gap: var(--space-sm); flex-wrap: wrap; }

/* === 7. Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    padding: .5rem 1rem;
    font-size: var(--font-size-sm);
    font-weight: 500;
    border: 1px solid var(--color-btn-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s;
    line-height: 1.5;
}
.btn:hover { text-decoration: none; }
.btn-primary  { background: var(--color-primary);   color: #fff; }
.btn-primary:hover  { background: var(--color-primary-hover); color: #fff; }
.btn-secondary { background: var(--color-surface); color: var(--color-secondary); }
.btn-secondary:hover { background: var(--color-bg); color: var(--color-secondary-hover); }
.btn-success  { background: var(--color-success);   color: #fff; }
.btn-success:hover  { background: var(--color-success-hover); color: #fff; }
.btn-danger   { background: var(--color-danger);    color: #fff; }
.btn-danger:hover   { background: var(--color-danger-hover); color: #fff; }
.btn-warning  { background: var(--color-warning);   color: #fff; }
.btn-warning:hover  { background: #b45309; color: #fff; }
.btn-block    { display: flex; width: 100%; }
.btn-compact  { padding: .25rem .6rem; font-size: var(--font-size-xs); }

/* === 8. Forms === */
.form-group { margin-bottom: var(--space-md); }
.form-group label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 500;
    margin-bottom: var(--space-xs);
}
.form-control {
    display: block;
    width: 100%;
    padding: .5rem .75rem;
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-md);
    transition: border-color .15s, box-shadow .15s;
    line-height: 1.5;
}
.form-control--title {
    font-size: var(--font-size-lg);
    font-weight: 600;
}
.form-control:focus {
    outline: none;
    border-color: var(--color-border-focus);
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.form-select {
    padding: .5rem .75rem;
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: border-color .15s;
}
.form-select:focus {
    outline: none;
    border-color: var(--color-border-focus);
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.form-check {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
    font-size: var(--font-size-sm);
    cursor: pointer;
}
.form-check input[type="checkbox"] { cursor: pointer; }

.chkd-col { text-align: center; }
.chkd-col input[type="checkbox"] { cursor: pointer; width: 1.1rem; height: 1.1rem; }

/* === 9. Search & filter === */
.search-row {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}
.search-input {
    flex: 1;
    border-color: var(--color-primary);
}
.filter-row {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
    align-items: center;
}
.filter-row .form-select { flex: 1; min-width: 150px; border-color: var(--color-primary); }

/* === 10. Tables === */
.data-table { width: 100%; border-collapse: collapse; font-size: var(--font-size-sm); }
.data-table thead { background: var(--color-bg); }
.data-table th {
    padding: var(--space-sm) var(--space-md);
    text-align: left;
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--color-text-muted);
    background: var(--color-bg);
    border-bottom: 2px solid var(--color-border-strong);
    white-space: nowrap;
}
.data-table td {
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--color-border-strong);
    vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table > tbody > tr:nth-child(even) { background: var(--color-row-alt); }
.data-table tbody tr:hover { background: var(--color-row-hover); }
.clickable-row { cursor: pointer; }
.text-right { text-align: right; }

/* === 10b. Pagination === */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-lg) 0;
    flex-wrap: wrap;
    border-top: 1px solid var(--color-border-strong);
}
.pagination-info {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin: 0 var(--space-sm);
}
.pagination-goto {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin: 0 var(--space-sm);
}
.pagination-page-input {
    width: 4rem;
    text-align: center;
    padding: .2rem var(--space-xs);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
}
.pagination .btn.disabled {
    opacity: .4;
    pointer-events: none;
    cursor: default;
}

/* === 11. Detail view === */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
}
.detail-list {
    display: grid;
    grid-template-columns: 9rem 1fr;
    row-gap: var(--space-xs);
    column-gap: var(--space-md);
}
.detail-list dt {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--color-text-muted);
    padding-top: .15rem;
}
.detail-list dd { font-size: var(--font-size-sm); }
.abstract-text { font-size: var(--font-size-sm); line-height: 1.75; }

/* === 12. Alphabet nav === */
.alpha-nav {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    margin-bottom: var(--space-lg);
}
.alpha-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    padding: 0 var(--space-xs);
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-secondary);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    text-decoration: none;
    transition: background .15s, border-color .15s, color .15s;
}
.alpha-btn:hover,
.alpha-btn.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
    text-decoration: none;
}

/* === 13. uthor expandable rows === */
.author-row { cursor: pointer; }
.author-row:nth-of-type(4n+3) { background: var(--color-bg); }
.author-row:hover { background: var(--color-row-hover); }
.author-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    font-size: .65rem;
    color: var(--color-text-muted);
    transition: transform .2s;
    margin-right: var(--space-xs);
    user-select: none;
}
.author-toggle.open { transform: rotate(90deg); }
.books-row td { padding: 0; background: var(--color-bg); }
.books-row.visible td { padding: var(--space-sm) var(--space-md) var(--space-sm) 2.5rem; }
.sub-table { width: 100%; border-collapse: collapse; font-size: var(--font-size-xs); }
.sub-table td {
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--color-border-strong);
    color: var(--color-text-muted);
}
.sub-table tr:last-child td { border-bottom: none; }
.sub-table .book-title { color: var(--color-text); }
.book-count {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    padding: .1rem .5rem;
}

/* === 14. Results meta === */
.results-meta {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-bottom: var(--space-sm);
}
.text-center { text-align: center; }

/* === 15. Alerts === */
.alert {
    padding: .75rem var(--space-md);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    margin-bottom: var(--space-md);
    border: 1px solid transparent;
}
.alert-danger  { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.alert-warning { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.alert-warning ul { margin: .5rem 0 .75rem 1.25rem; }
.alert-warning .btn { margin-top: .25rem; }

/* === 16. Login page === */
.login-page {
    background: var(--color-nav-bg);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-wrap { width: 100%; padding: var(--space-lg); }
.login-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--space-2xl);
    max-width: 400px;
    margin: 0 auto;
}
.login-title {
    font-size: var(--font-size-3xl);
    text-align: center;
    margin-bottom: var(--space-xs);
    color: var(--color-nav-bg);
}
.login-sub {
    text-align: center;
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    margin-bottom: var(--space-xl);
}

/* === 17. Utilities === */
.text-muted  { color: var(--color-text-muted); }
.text-sm     { font-size: var(--font-size-sm); }
.text-xs     { font-size: var(--font-size-xs); }
.empty-state {
    text-align: center;
    padding: var(--space-2xl);
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
}

/* === 18. Hylleplasseringsmatrise === */
.shelf-card { overflow: hidden; }

.shelf-matrix-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    padding: var(--space-sm) 0 var(--space-md);
}
.shelf-matrix-scroll { overflow-x: auto; }

/* Pentagon-piler til venstre og høyre */
.shelf-dir {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 4.5rem;
    padding: .6rem 1.2rem;
    font-size: var(--font-size-sm);
    font-weight: 700;
    color: #fff;
    background: var(--color-primary);
    white-space: nowrap;
    user-select: none;
}
.shelf-dir--left {
    clip-path: polygon(18% 0%, 100% 0%, 100% 100%, 18% 100%, 0% 50%);
    padding-left: 1.6rem;
}
.shelf-dir--right {
    clip-path: polygon(0% 0%, 82% 0%, 100% 50%, 82% 100%, 0% 100%);
    padding-right: 1.6rem;
}

/* Tabellen */
.shelf-grid { border-collapse: collapse; }

.shelf-section-hdr {
    text-align: center;
    font-size: var(--font-size-xs);
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    background: var(--color-primary);
    color: #fff;
    padding: .4rem 1rem;
    border: 1px solid rgba(255,255,255,.25);
}
.shelf-unit-hdr {
    text-align: center;
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--color-text-muted);
    background: var(--color-bg);
    padding: .35rem .75rem;
    border: 1px solid var(--color-border);
    white-space: nowrap;
}
.shelf-unit-active {
    color: var(--color-primary);
    background: #eff6ff;
    font-weight: 700;
}
.shelf-rack-cell {
    text-align: center;
    width: 3.2rem;
    height: 2.2rem;
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
    vertical-align: middle;
}
.shelf-rack-active {
    background: #f59e0b;
    color: #fff;
    font-weight: 700;
    border-color: #d97706;
    font-size: var(--font-size-base);
}
.shelf-rack-na {
    background: var(--color-bg);
    color: transparent;
    border-color: var(--color-border);
}
.shelf-caption {
    text-align: center;
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-top: var(--space-xs);
}

/* === 19. Edit forms === */
.form-group .form-select { display: block; width: 100%; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
}
.form-row--3 { grid-template-columns: 1fr 1fr 1fr; }

.author-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    margin-bottom: var(--space-sm);
    min-height: 2rem;
}
.author-tag {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: .2rem .6rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    font-size: var(--font-size-sm);
}
.tag-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-muted);
    padding: 0;
    line-height: 1;
    font-size: 1.1rem;
}
.tag-remove:hover { color: var(--color-danger); }

.author-add-row {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
}
.author-add-row .form-select { flex: 1; }

.tab-nav {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--color-border-strong);
    margin-bottom: var(--space-lg);
}
.tab-btn {
    padding: .5rem var(--space-md);
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color .15s, border-color .15s;
}
.tab-btn:hover { color: var(--color-primary); text-decoration: none; }
.tab-btn.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
    text-decoration: none;
}

.form-actions {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
    margin-top: var(--space-lg);
    padding-top: var(--space-md);
    border-top: 1px solid var(--color-border-strong);
}
.form-actions--right { justify-content: flex-end; }

/* === 20. Utlånsstatus === */
.loan-card { }

.loan-status {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) 0;
}
.loan-dot {
    display: inline-block;
    width: .65rem;
    height: .65rem;
    border-radius: 50%;
    flex-shrink: 0;
}
.loan-dot--in  { background: var(--color-success); }
.loan-dot--out { background: var(--color-danger); }

.loan-status--in  { color: var(--color-success); }
.loan-status--out { color: var(--color-danger); font-weight: 500; }
.loan-status--out strong { color: var(--color-text); }

.loan-form-hidden { display: none; }
.loan-card form { margin-top: var(--space-md); }

/* Inline badge i bokliste */
.loan-badge-sm {
    display: inline-block;
    margin-left: var(--space-xs);
    padding: .1rem .45rem;
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: #fff;
    background: var(--color-danger);
    border-radius: 999px;
    vertical-align: middle;
    white-space: nowrap;
}

/* === 21. Responsive === */
@media (max-width: 1200px) {
    .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .site-nav .container { gap: var(--space-md); }
    .filter-row { flex-direction: column; }
    .filter-row .form-select { min-width: unset; }
    .detail-list { grid-template-columns: 7rem 1fr; }
    .data-table th:nth-child(4),
    .data-table td:nth-child(4) { display: none; }
}
