
/* ==========================================
   MAKTABA NOMANIA — BOOKS PAGE
========================================== */

.books-page {
    min-width: 0;
    padding-bottom: 40px;
}

.books-page .topbar {
    gap: 20px;
    margin-bottom: 28px;
}

.books-page .topbar h2 {
    margin: 0 0 7px;
    color: #183d2b;
    font-size: clamp(23px, 2.5vw, 30px);
    font-weight: 750;
    letter-spacing: -0.6px;
}

.books-page .topbar p {
    margin: 0;
    color: #728076;
    font-size: 14px;
}

#books-add-button {
    flex-shrink: 0;
    padding: 12px 18px;
    border: 1px solid #176b45;
    border-radius: 9px;
    background: #176b45;
    color: #ffffff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 650;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(23, 107, 69, 0.13);
    transition: background 150ms ease, transform 150ms ease;
}

#books-add-button:hover {
    background: #105638;
}

#books-add-button:active {
    transform: translateY(1px);
}

/* Summary cards */

.books-overview {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 28px;
}

.books-overview .stat-card {
    min-width: 0;
    padding: 22px;
    background: #ffffff;
    border: 1px solid #e3eae5;
    border-radius: 13px;
    box-shadow: 0 4px 16px rgba(25, 55, 37, 0.04);
}

.books-overview .stat-card p {
    margin: 0 0 12px;
    color: #68796e;
    font-size: 13px;
    font-weight: 600;
}

.books-overview .stat-card h4 {
    margin: 0;
    color: #176b45;
    font-size: 29px;
    font-weight: 750;
    letter-spacing: -0.5px;
}

/* Books table container */

.books-list-section {
    min-width: 0;
    padding: 24px;
    background: #ffffff;
    border: 1px solid #e3eae5;
    border-radius: 14px;
    box-shadow: 0 5px 22px rgba(25, 55, 37, 0.045);
}

.books-list-section .section-heading {
    margin-bottom: 20px;
}

.books-list-section .section-heading h3 {
    margin: 0 0 6px;
    color: #203b2b;
    font-size: 20px;
    font-weight: 750;
}

.books-list-section .section-heading p {
    margin: 0;
    color: #78857c;
    font-size: 13px;
}

.books-list-section > label {
    display: block;
    margin-bottom: 8px;
    color: #43564a;
    font-size: 13px;
    font-weight: 650;
}

#books-search {
    display: block;
    box-sizing: border-box;
    width: 100%;
    min-height: 46px;
    margin-bottom: 22px;
    padding: 12px 15px;
    border: 1px solid #dbe4de;
    border-radius: 9px;
    background: #fbfcfb;
    color: #24372b;
    font: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

#books-search:focus {
    border-color: #258458;
    box-shadow: 0 0 0 3px rgba(37, 132, 88, 0.11);
    background: #ffffff;
}

#books-search::placeholder {
    color: #9aa69e;
}

/* Horizontal scrolling on small screens */

.books-list-section .table-wrapper {
    width: 100%;
    overflow-x: auto;
    border: 1px solid #e5ebe7;
    border-radius: 10px;
}

.books-list-section table {
    width: 100%;
    min-width: 1000px;
    border-collapse: separate;
    border-spacing: 0;
    text-align: left;
}

.books-list-section thead th {
    padding: 15px 14px;
    background: #f3f7f4;
    border-bottom: 1px solid #dfe8e2;
    color: #53685a;
    font-size: 11px;
    font-weight: 750;
    letter-spacing: 0.45px;
    text-transform: uppercase;
    white-space: nowrap;
}

.books-list-section tbody td {
    padding: 15px 14px;
    border-bottom: 1px solid #edf1ee;
    color: #435449;
    font-size: 13px;
    vertical-align: middle;
}

.books-list-section tbody tr:last-child td {
    border-bottom: none;
}

.books-list-section tbody tr {
    transition: background-color 140ms ease;
}

.books-list-section tbody tr:hover {
    background: #f8fbf9;
}

.books-list-section tbody td:first-child {
    color: #63776a;
    font-weight: 650;
    white-space: nowrap;
}

.books-list-section .book-name-link {
    color: #176b45;
    font-weight: 700;
    text-decoration: none;
}

.books-list-section .book-name-link:hover {
    color: #105638;
    text-decoration: underline;
}

.books-list-section .books-empty {
    padding: 34px 18px;
    color: #7a897f;
    text-align: center;
}

/* View, Edit and Delete actions */

.books-list-section .book-actions-cell {
    white-space: nowrap;
}

.books-list-section .action-button,
.books-detail-actions .action-button,
.books-edit-actions .action-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    margin: 2px 4px 2px 0;
    padding: 7px 10px;
    border: 1px solid transparent;
    border-radius: 7px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 140ms ease, border-color 140ms ease;
}

.books-list-section .action-view,
.books-detail-actions .action-view,
.books-edit-actions .action-view {
    color: #285aa2;
    background: #edf4ff;
    border-color: #d6e5ff;
}

.books-list-section .action-view:hover,
.books-detail-actions .action-view:hover,
.books-edit-actions .action-view:hover {
    background: #dceaff;
}

.books-list-section .action-edit,
.books-detail-actions .action-edit,
.books-edit-actions .action-edit {
    color: #176b45;
    background: #eaf6ef;
    border-color: #cce8d6;
}

.books-list-section .action-edit:hover,
.books-detail-actions .action-edit:hover,
.books-edit-actions .action-edit:hover {
    background: #d7efdf;
}

.books-list-section .action-delete,
.books-detail-actions .action-delete {
    color: #b4232f;
    background: #fff0f0;
    border-color: #f2d0d0;
}

.books-list-section .action-delete:hover,
.books-detail-actions .action-delete:hover {
    background: #ffe0e0;
}

.books-list-section .action-button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* Book details panel */

#books-details-panel {
    margin-top: 26px;
    padding: 26px;
    background: #ffffff;
    border: 1px solid #e0e9e3;
    border-radius: 14px;
    box-shadow: 0 8px 26px rgba(25, 55, 37, 0.06);
    scroll-margin-top: 20px;
}

#books-details-panel[hidden] {
    display: none;
}

.books-details-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.books-details-header h3,
#books-details-panel > h3 {
    margin: 0;
    color: #183d2b;
    font-size: 22px;
    font-weight: 750;
}

.books-close-button {
    padding: 8px 13px;
    border: 1px solid #dce5df;
    border-radius: 8px;
    background: #f3f6f4;
    color: #43564a;
    font: inherit;
    font-size: 13px;
    font-weight: 650;
    cursor: pointer;
}

.books-close-button:hover {
    background: #e6ece8;
}

.books-details-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 0;
}

.books-details-list dt,
.books-details-list dd {
    min-width: 0;
    margin: 0;
    padding: 13px 14px;
    border-bottom: 1px solid #edf1ee;
    overflow-wrap: anywhere;
}

.books-details-list dt {
    color: #6c7d72;
    font-size: 13px;
}

.books-details-list dd {
    color: #263c2e;
    font-size: 14px;
    font-weight: 650;
}

.books-detail-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 22px;
}

/* Edit form */

#books-edit-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-top: 22px;
}

#books-edit-form .edit-book-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-width: 0;
}

#books-edit-form .edit-book-field label {
    color: #43564a;
    font-size: 13px;
    font-weight: 650;
}

#books-edit-form .edit-book-field input {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 11px 13px;
    border: 1px solid #d8e1db;
    border-radius: 8px;
    background: #fbfcfb;
    color: #24372b;
    font: inherit;
    font-size: 14px;
    outline: none;
}

#books-edit-form .edit-book-field input:focus {
    border-color: #258458;
    box-shadow: 0 0 0 3px rgba(37, 132, 88, 0.11);
    background: #ffffff;
}

#books-edit-form .edit-book-field input[readonly] {
    background: #f0f3f1;
    color: #647269;
}

#books-edit-form .books-edit-message {
    grid-column: 1 / -1;
    margin: 0;
    color: #52665a;
    font-size: 13px;
}

.books-edit-actions {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.books-edit-actions .action-button {
    min-height: 42px;
    padding: 10px 16px;
    font-size: 13px;
}

/* Keyboard accessibility */

.books-page button:focus-visible {
    outline: 3px solid rgba(37, 132, 88, 0.25);
    outline-offset: 2px;
}

/* Responsive */

@media (max-width: 900px) {
    .books-overview {
        gap: 12px;
    }

    .books-overview .stat-card {
        padding: 17px;
    }

    .books-list-section {
        padding: 18px;
    }
}

@media (max-width: 600px) {
    .books-page .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    #books-add-button {
        width: 100%;
        min-height: 44px;
    }

    .books-overview {
        grid-template-columns: 1fr;
    }

    .books-overview .stat-card {
        padding: 17px 19px;
    }

    .books-overview .stat-card h4 {
        font-size: 25px;
    }

    .books-list-section {
        padding: 14px;
    }

    #books-details-panel {
        padding: 17px;
    }

    .books-details-list {
        grid-template-columns: 1fr;
    }

    .books-details-list dd {
        padding-top: 4px;
        margin-bottom: 7px;
    }

    #books-edit-form {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .books-details-header h3,
    #books-details-panel > h3 {
        font-size: 19px;
    }
}

@media (prefers-reduced-motion: reduce) {
    #books-add-button,
    .books-list-section tbody tr,
    .books-list-section .action-button {
        transition: none;
    }
}

/* ===== 3 cards hamesha ek line mein (mobile aur laptop) ===== */
.books-overview {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 16px;
    margin-bottom: 24px;
}

.books-overview .stat-card {
    min-width: 0;
}

/* Low Stock card clickable */
.clickable-stat {
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.clickable-stat:hover {
    border-color: #d97706;
    background: #fffaf0;
}

.clickable-stat:focus-visible {
    outline: 3px solid rgba(217, 119, 6, 0.35);
    outline-offset: 2px;
}

.clickable-stat.active {
    border-color: #d97706;
    background: #fff3dc;
    box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.18);
}

/* Mobile: chhote cards taake teeno ek line mein aayein */
@media (max-width: 600px) {
    .books-overview {
        gap: 8px;
    }

    .books-overview .stat-card {
        padding: 12px 8px;
        text-align: center;
    }

    .books-overview .stat-card p {
        margin-bottom: 6px;
        font-size: 11px;
        line-height: 1.3;
    }

    .books-overview .stat-card h4 {
        font-size: 20px;
    }
}