/* ===============================
   LAYOUT CONTAINERS
================================ */

#content {
    width: 1000px;
    margin: 16px auto;
    display: block;
    grid-template-columns: 260px 1fr;
    gap: 8px;
    min-height: auto;
}

/* kill float system */
#leftcontent,
#centrecontent {
    float: none !important;
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
}

#centrecontent {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.05);
}

/* ===============================
   HOMEPAGE HEADING LINKS
================================ */

#centrecontent h2 a:link,
#centrecontent h2 a:visited {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

#centrecontent h2 {
    margin: 0 0 4px;
    font-size: 1.5rem;
    font-weight: 600;
}

#centrecontent h2 a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

#centrecontent p {
    margin: 0 0 14px;
    color: var(--text-muted);
}

#footer {
    width: 1000px;
    margin: 16px auto;
    font-size: 0.9rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    padding-top: 8px;
    text-align: right;
}

/* ===============================
   SIDEBAR
================================ */

#leftcontent {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    position: sticky;
    top: 90px;
    align-self: start;
    width: 240px;
}

.secondary {
    background: var(--border);
    color: var(--text-strong);
}

/* ===============================
   SIDEBAR BOXES
================================ */

.greybox,
.whitebox {
    background: #f2f3f6;
    border-radius: var(--radius-md);
    padding: 12px;
    margin-bottom: 16px;
}

.greybox {
    padding: 1rem;
}

/* ===============================
   REPORT LAYOUT
================================ */

body.report-body {
    background: #ffffff;
}

.report-body #content {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem;
}

@media print {
    body.report-body {
        background: #fff;
    }

    .report-body #content {
        padding: 0;
        max-width: none;
    }
}



/* ===============================
   NAV BAR
================================ */

#menu {
    width: 970px;
    margin: 0 auto;
    background: #666;
}

#navlist ul {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
}

#navlist a {
    flex: 1;
    text-align: center;
    padding: 8px 0;
    color: #f5f5f5;
    text-decoration: none;
    font-weight: 500;
    border-right: 1px solid #7a7a7a;
}

#navlist a:hover {
    background: #8a8a8a;
}

/* SEARCH */
#leftsearchForm {
    display: flex;
    align-items: center;
    overflow: visible;
}

#leftsearchForm input,
#leftsearchForm button {
    height: 30px;
}

#leftsearchForm input {
    flex: 1;
    height: 34px;
    padding: 0 0.5rem;
    border: 1px solid var(--border);
    border-right: none;
    border-radius: 8px 0 0 8px;
    background: white;
}

#leftsearchForm button {
    width: 36px;
    height: 34px;
    border: 1px solid var(--border);
    border-left: none;
    border-radius: 0 8px 8px 0;
    background: var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-default);
    overflow: visible;
}

#leftsearchForm button svg {
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    stroke: var(--text-muted);
}

/* CATALOGUE */

.catalogue-grid {
    display: grid;
    grid-template-columns: repeat(5, auto);
    gap: 0.45rem 0.8rem;
}

.catalogue-grid a {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-default);
    text-decoration: none;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 1.2rem;
    height: 1.2rem;
    border-radius: 6px;

    transition: background 0.15s ease, color 0.15s ease;
}

.catalogue-grid a:hover {
    background: var(--accent);
    color: white;
}




.page-wrapper {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 2rem;
}

.page-wrapper::after {
    content: "";
    display: block;
    clear: both;
}

/* --- GRID LAYOUT --- */

.layout {
    display: grid !important;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 2rem;
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 2rem;
    align-items: start;
}

/* prevent overflow weirdness */
#centrecontent {
    min-width: 0;
}

/* responsive collapse */
@media (max-width: 900px) {
    .layout {
        grid-template-columns: 1fr !important;
    }
}


.form-grid {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 1rem 1.2rem;
    align-items: center;
}

.form-grid .full-row {
    grid-column: 1 / -1;
}

.form-grid label {
    font-weight: 500;
    color: var(--text-default);
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.field-error input,
.field-error textarea,
.field-error select {
    border-color: #dc2626 !important;
    background: #fef2f2 !important;
}

.field-error .ts-control {
    border-color: #dc2626 !important;
    background: #fef2f2 !important;
}

.error-message {
    color: #d32f2f;
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

.field-inline {
    display: flex;
    gap: 0.6rem;
    align-items: center;
}

.field-inline input,
.field-inline select {
    flex: 1;
}

.form-actions {
    margin-top: 2rem;
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    grid-column: 1 / -1;
}

@media (max-width: 700px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
}

.form-input {
    border: 1px solid var(--border);
    background: #f3f4f6;
}

.form-input.invalid {
    border-color: #d32f2f;
    background: #fff5f5;
}

.ts-control {
    border: 1px solid var(--border);
    background: #f3f4f6;
    border-radius: var(--radius-sm); /* match your inputs */
    min-height: 44px;   /* match height */
    padding: 6px 10px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

/* Focus state */
.ts-wrapper.focus .ts-control {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-soft);
}

/* The text input inside */
.ts-control input {
    background: transparent;
    border: none;
    outline: none;
    font-size: 1rem;
    flex: 1;
}

/* Chips */
.ts-control .item {
    background: var(--accent-muted);
    color: var(--accent-strong);
    border-radius: 6px;
    padding: 4px 8px;
    margin: 2px;
    font-size: 0.9rem;
}

.reorder-panel {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
    width: 100%;
}

.reorder-panel select {
    flex: 1;
    width: 525px;
    height: 320px;
}

.reorder-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.reorder-buttons button {
    width: 100%;
}

.link-button {
    background: none;
    border: none;
    padding: 0;
    color: #0a58ca;
    text-decoration: underline;
    cursor: pointer;
    font: inherit;
}

.link-button:hover {
    text-decoration: none;
}

/* ===============================
   TOP LEVEL ACTION PANEL
================================ */
.action-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 0.5rem 0 1.5rem;
}

.action-button {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.75rem;
    border-radius: 6px;
    background: #f3f4f6;
    color: var(--text-strong);
    font-weight: 500;
    text-decoration: none;
    border: 1px solid var(--border);
    cursor: pointer;
}

.action-button,
.action-button:visited,
.action-button:hover,
.action-button:active {
    color: var(--text-strong);
    text-decoration: none;
}

.action-button:hover {
    background: var(--border);
}

.action-danger {
    background: #fee2e2;
    border-color: #fecaca;
    color: #991b1b;
}

/* ===============================
   List Action Icons (books, authors, etc.)
================================ */
.actions {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
}

.actions form {
    display: inline-flex;
    margin: 0;
}

.actions button {
    font: inherit;
    line-height: 1;
    background: transparent;
    border: none;
    box-shadow: none;
    outline: none;
}

.actions button,
.actions a {
    color: inherit;
}

.actions button:hover,
.actions button:focus,
.actions button:active {
    background: transparent;
    box-shadow: none;
    outline: none;
}

.action-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
}

.action-icon i {
    width: 16px;
    height: 16px;
}

.action-icon,
.action-icon:visited,
.action-icon:hover,
.action-icon:active {
    color: var(--text-muted);
    text-decoration: none;
}

.actions .action-icon:hover {
    color: var(--accent-dark);
}

/* Prevent action column wrapping */
.actions-column {
    white-space: nowrap;
    vertical-align: top;
}

.section {
    margin-top: 2rem;
}

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem;
    font-size: 1rem;
    margin-bottom: 1rem;
}

.breadcrumb-sep {
    display: flex;
    align-items: center;
    color: #9ca3af;
}

.breadcrumb-current {
    font-weight: 600;
    color: var(--text-strong);
}

.breadcrumb-home {
    display: flex;
    align-items: center;
    color: var(--accent-dark);
}

.breadcrumb-home:hover {
    color: var(--accent);
}

/* ===============================
   STATUS LABELS
================================ */

span.error_label {
    font-weight: bold;
    color: #dc2626;
}

span.success_label {
    font-weight: bold;
    color: #16a34a;
}

.book-line {
    display: inline-block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: top;
    width: 100%;
}

/* ===============================
   TABLE STYLING
================================ */

table.tabledata {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

table.tabledata th {
    background: #f3f4f6;
    text-align: left;
    padding: 10px;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
}

table.tabledata td {
    padding: 10px;
    border-bottom: 1px solid var(--border);
}

table.tabledata tr:hover {
    background: #fafafa;
}

.link-reset {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font: inherit;
    text-align: left;
    color: var(--accent-dark); /* match your link green */
}

.link-reset:hover,
.link-reset:focus {
    opacity: 0.75;
}

/* visited links shouldn't go purple */
.link-reset:visited {
    color: var(--accent);
}

/* ===============================
   BOOK VIEW STYLING
================================ */
.book-hero {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

.book-cover {
    flex: 0 0 180px;
}

.cover-image {
    width: 100%;
    aspect-ratio: 2 / 3;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    object-fit: cover;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.cover-placeholder {
    width: 200px;
    height: 300px;

    /* lighter cover */
    background: linear-gradient(135deg, #1f2937, #334155);

    /* brighter spine */
    border-left: 12px solid #0f172a;

    border-radius: var(--radius-sm);
    color: #f9fafb;

    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;

    padding: 14px;
    text-align: center;

    box-shadow:
            inset 0 0 0 1px rgba(255,255,255,0.12),
            0 10px 24px rgba(0,0,0,0.25);

    position: relative;
    overflow: hidden;
}

/* edge highlight */
.cover-placeholder::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 6px;
    height: 100%;
    background: rgba(255,255,255,0.15);
}

.cover-placeholder .cover-title {
    font-size: 0.9rem;
    line-height: 1.25;
    opacity: 0.9;

    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-meta {
    flex: 1;
}

.book-id {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.book-title {
    max-width: 500px;
    font-size: 1.1rem;
    margin: 0.25rem 0 0.5rem;
}

.book-author {
    font-size: 1.1rem;
    color: var(--text-default);
    margin-bottom: 0.75rem;
}

.book-facts {
    display: flex;
    gap: 1.2rem;
    flex-wrap: wrap;
    font-size: 0.95rem;
    color: var(--text-default);
}

.book-publisher {
    margin-top: 0.6rem;
    font-size: 0.95rem;
    color: var(--text-default);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.publisher-icon {
    width: 16px;
    height: 16px;
    opacity: 0.7;
}

.book-notes,
.book-borrowing {
    margin-top: 1.4rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-default);
    max-width: 70ch;
}

.currency {
    padding: 0 0.4rem;
    color: var(--text-muted);
}

.author-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.author-row {
    font-size: 0.95rem;
    color: var(--text-default);
}

.isbn-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cover-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.75rem;
    border-radius: 6px;
    background: var(--accent-muted);
    color: var(--accent-strong);
    border: 1px solid var(--accent-border);
    font-weight: 500;
    font-size: 0.9rem;
}

/* ===============================
   SECTION BLOCKS
================================ */
.section-block {
    margin-top: 1.4rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    max-width: 70ch;
}

.section-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.6rem;
    color: var(--text-strong);
    letter-spacing: 0.02em;
}

/* ===============================
   LOAN UI
================================ */
.loan-status {
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.available .status-dot { background: var(--success); }
.on-loan .status-dot { background: var(--warning); }
.overdue .status-dot { background: var(--danger); }

.loan-form {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    max-width: 380px;
}

.loan-form select,
.loan-form input {
    padding: 0.5rem;
    border-radius: 6px;
    border: 1px solid #d1d5db;
}

.loan-meta {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 0.8rem;
    color: var(--text-default);
}

.loan-history {
    font-size: 0.9rem;
    color: var(--text-default);
    border-collapse: collapse;
}

.loan-history th {
    text-align: left;
    font-weight: 600;
    padding: 0 1rem 0.35rem 0;
    color: var(--text-strong);
}

.loan-history td {
    padding: 0.25rem 1rem 0.25rem 0;
}

.muted {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ===============================
   BORROWER DASHBOARD
================================ */

.borrower-hero {
    margin-bottom: 1.2rem;
}

.borrower-name {
    font-size: 1.4rem;
    margin-bottom: 0.3rem;
}

.borrower-contact,
.borrower-address {
    font-size: 0.95rem;
    color: var(--text-default);
}

.borrower-stats {
    display: flex;
    gap: 2rem;
}

.stat-value {
    font-size: 1.4rem;
    font-weight: 600;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.stat.overdue .stat-value {
    color: #dc2626;
}

/* ===============================
   REPORT TABLES
================================ */

.report-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
    color: var(--text-default);
}

.report-table th {
    text-align: left;
    font-weight: 600;
    padding: 0.6rem 1rem 0.6rem 0;
    border-bottom: 1px solid var(--border);
    color: var(--text-strong);
}

.report-table td {
    padding: 0.5rem 1rem 0.5rem 0;
    border-bottom: 1px solid #f1f5f9;
}

.report-table tr:hover {
    background: #f9fafb;
}

.report-empty {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-top: 0.5rem;
}

/* --- Force Tom Select to match .form-input --- */

.ts-wrapper {
    width: 100%;
    border: none !important;
    background: transparent !important;
}

.ts-wrapper.multi {
    border: none !important;
}

.ts-control {
    background: #f3f4f6 !important;
    border: 1px solid var(--border) !important;
    border-radius: 12px !important; /* match your other inputs */
    min-height: 52px; /* match height visually */
    padding: 10px 12px !important;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    box-shadow: none !important;
}

/* Remove default white dropdown arrow styling */
.ts-wrapper.single .ts-control {
    background-image: none !important;
}

/* Internal search input */
.ts-control input {
    background: transparent !important;
    border: none !important;
    outline: none !important;
    font-size: 1rem;
    color: var(--text-strong); /* match your body text */
    padding: 0;
    margin: 0;
}

/* Placeholder styling */
.ts-control input::placeholder {
    color: #9ca3af;
}

/* Chips */
.ts-control .item {
    background: var(--accent-muted);
    border: 1px solid var(--accent-border);
    color: var(--accent-strong);
    border-radius: var(--radius-sm);
    padding: 4px 10px;
    margin: 4px 6px 4px 0;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
}

.ts-control .remove {
    margin-left: 6px;
    color: var(--text-muted);
    cursor: pointer;
}

.ts-control .remove:hover {
    color: var(--text-strong);
}

/* Focus state to match other inputs */
.ts-wrapper.focus .ts-control {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 2px var(--accent-soft);
   transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

/* FORCE chip styling */
.ts-wrapper.multi .ts-control > .item {
    background: var(--accent-muted) !important;
    border: 1px solid var(--accent-border) !important;
    color: var(--accent-strong) !important;
    border-radius: 8px !important;
    padding: 4px 10px !important;
    margin: 4px 6px 4px 0 !important;
    font-size: 0.95rem;
}

/* Remove button styling */
.ts-wrapper.multi .ts-control > .item .remove {
    margin-left: 6px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
}

.ts-wrapper.multi .ts-control > .item .remove:hover {
    color: var(--text-strong);
}

/* --- Dropdown container --- */
.ts-dropdown {
    background: #ffffff !important;
    border: 1px solid var(--border) !important;
    border-radius: 10px !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.06) !important;
    padding: 6px 0;
    margin-top: 6px;
    font-size: 1rem;
    transition: opacity 0.12s ease, transform 0.12s ease;
}

.ts-wrapper.dropdown-active .ts-dropdown {
    transform: translateY(2px);
}

/* Remove harsh square corners */
.ts-dropdown-content {
    border-radius: 10px;
}

/* --- Dropdown options --- */
.ts-dropdown .option {
    padding: 10px 14px !important;
    cursor: pointer;
    color: var(--text-strong);
    background: transparent;
}

/* Hover state */
.ts-dropdown .option:hover {
    background: #f3f4f6 !important;
}

/* Active keyboard selection */
.ts-dropdown .option.active {
    background: var(--accent-muted) !important;
    color: var(--accent-strong);
}

/* Selected option */
.ts-dropdown .option.selected {
    font-weight: 500;
}

/* Subtle scroll styling */
.ts-dropdown-content::-webkit-scrollbar {
    width: 8px;
}

.ts-dropdown-content::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.lookup-status.success {
    color: #16a34a;
    font-size: 0.9rem;
    margin-left: 0.5rem;
}

.lookup-status.error {
    color: #dc2626;
    font-size: 0.9rem;
    margin-left: 0.5rem;
}

.cover-preview {
    display: block;
    margin-top: 0.5rem;
    height: 80px;
    border-radius: 6px;
}

.category-tree details {
    margin: 0;
    padding: 0;
}

.category-tree summary {
    list-style: none;
    cursor: pointer;
    padding: 0.12rem 0;
    line-height: 1.25;
}

.category-tree summary::-webkit-details-marker {
    display: none;
}

.category-tree .children {
    margin: 0;
    padding-left: 0.6rem;
    border-left: 1px solid #e6e6e6;
}

.category-tree .leaf-node {
    padding: 0.12rem 0;
    line-height: 1.25;
}

.category-tree a,
.category-tree span {
    display: block;
}

.current-category {
    font-weight: 600;
    color: var(--text-muted);
    cursor: default;
}

/* Every row is flex-based */
.category-tree summary,
.category-tree .leaf-node {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    line-height: 1.25;
    padding: 0.12rem 0;
}

/* Arrow column */
.category-tree .tree-summary::before,
.category-tree .leaf-node::before {
    content: "";
    width: 0.75rem;   /* fixed arrow column width */
    flex-shrink: 0;
}

/* Real arrow only for expandable nodes */
.category-tree .tree-summary::before {
    content: "▸";
    font-size: 0.75rem;
    transition: transform 0.15s ease;
}

/* Rotate arrow when open */
.category-tree details[open] > .tree-summary::before {
    transform: rotate(90deg);
}

/* Children indentation */
.category-tree .children {
    margin-left: 1rem;   /* THIS controls depth */
    border-left: 1px solid #e6e6e6;
    padding-left: 0.6rem;
}

.category-tree summary {
    outline: none;
}

.category-tree summary:focus {
    outline: none;
}

.category-tree summary::-moz-focus-inner {
    border: 0;
}