/* ADMIN_BOOKS_VISUAL_PHASE3E3C */
.admin-books-page,
.admin-books-page * {
    box-sizing: border-box;
}

.admin-books-page {
    --ab-ink: #18352b;
    --ab-ink-soft: #2d5043;
    --ab-gold: #d4a95a;
    --ab-gold-deep: #b8893a;
    --ab-cream: #faf6ec;
    --ab-line: rgba(31, 58, 46, .10);
    --ab-muted: #6b6255;
    display: grid;
    gap: 18px;
    width: 100%;
    min-width: 0;
}

.admin-books-page button,
.admin-books-page input,
.admin-books-page select {
    font: inherit;
}

.admin-books-hero {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    overflow: hidden;
    padding: 25px 26px;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 26px;
    color: #fff;
    background:
        radial-gradient(circle at 12% 0%, rgba(212, 169, 90, .28), transparent 33%),
        radial-gradient(circle at 100% 100%, rgba(255, 255, 255, .08), transparent 34%),
        linear-gradient(135deg, #173328, #2d5043);
    box-shadow: 0 20px 48px rgba(31, 58, 46, .18);
}

.admin-books-hero::after {
    content: "";
    position: absolute;
    inset-inline-end: -55px;
    bottom: -90px;
    width: 210px;
    height: 210px;
    border: 1px solid rgba(212, 169, 90, .26);
    border-radius: 50%;
    pointer-events: none;
}

.admin-books-hero > * {
    position: relative;
    z-index: 1;
}

.admin-books-hero span {
    color: var(--ab-gold);
    font-size: .78rem;
    font-weight: 950;
    letter-spacing: .08em;
}

.admin-books-hero h2 {
    margin: 6px 0;
    color: #fff;
    font-size: clamp(1.4rem, 2vw, 1.9rem);
    line-height: 1.3;
}

.admin-books-hero p {
    max-width: 720px;
    margin: 0;
    color: rgba(255, 255, 255, .77);
    line-height: 1.8;
}

.admin-books-hero-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.admin-books-primary,
.admin-books-secondary,
.admin-books-filters button,
.admin-book-actions button,
.admin-book-order-actions button {
    border: 0;
    cursor: pointer;
    transition:
        transform .2s ease,
        box-shadow .2s ease,
        background .2s ease;
}

.admin-books-primary,
.admin-books-secondary {
    min-height: 44px;
    border-radius: 14px;
    padding: 10px 16px;
    font-weight: 950;
    white-space: nowrap;
}

.admin-books-primary {
    color: var(--ab-ink);
    background: linear-gradient(135deg, var(--ab-gold), var(--ab-gold-deep));
    box-shadow: 0 10px 24px rgba(184, 137, 58, .24);
}

.admin-books-secondary {
    color: var(--ab-ink);
    background: #f5f1e8;
}

.admin-books-primary:hover,
.admin-books-secondary:hover,
.admin-book-actions button:hover,
.admin-book-order-actions button:hover {
    transform: translateY(-1px);
}

.admin-books-filters {
    display: grid;
    grid-template-columns:
        minmax(180px, 1.35fr)
        repeat(5, minmax(125px, .9fr))
        auto
        auto;
    gap: 10px;
    padding: 15px;
    border: 1px solid var(--ab-line);
    border-radius: 22px;
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 12px 30px rgba(31, 58, 46, .06);
}

.admin-books-filters input,
.admin-books-filters select {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    border: 1px solid rgba(31, 58, 46, .13);
    border-radius: 13px;
    padding: 0 12px;
    outline: none;
    color: #1a1815;
    background: #fff;
}

.admin-books-filters input:focus,
.admin-books-filters select:focus {
    border-color: var(--ab-gold-deep);
    box-shadow: 0 0 0 3px rgba(212, 169, 90, .13);
}

.admin-books-filters button {
    min-height: 44px;
    border-radius: 13px;
    padding: 0 14px;
    color: #fff;
    background: var(--ab-ink);
    font-weight: 950;
    white-space: nowrap;
}

.admin-books-filters .admin-books-secondary {
    color: var(--ab-ink);
    background: #f5f1e8;
}

.admin-books-content,
.admin-books-store-layout,
.admin-books-top-columns {
    min-width: 0;
}

.admin-books-store-layout {
    display: grid;
    gap: 18px;
}

.admin-books-top-columns {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    direction: rtl;
    gap: 18px;
    align-items: stretch;
}

.admin-book-group-block {
    display: grid;
    align-content: start;
    gap: 13px;
    min-width: 0;
    padding: 15px;
    border: 1px solid var(--ab-line);
    border-radius: 24px;
    background:
        radial-gradient(circle at top right, rgba(212, 169, 90, .10), transparent 28%),
        #fff;
    box-shadow: 0 14px 34px rgba(31, 58, 46, .07);
}

.admin-book-group-block.explanation {
    grid-column: 1;
}

.admin-book-group-block.exercises {
    grid-column: 2;
}

.admin-book-group-block.final-review,
.admin-book-group-block.other {
    width: 100%;
}

.admin-book-group-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    min-height: 58px;
    padding: 12px 14px;
    border: 1px solid rgba(212, 169, 90, .24);
    border-radius: 18px;
    background:
        linear-gradient(135deg, rgba(250, 246, 236, .98), rgba(255, 255, 255, .98));
}

.admin-book-group-title div {
    min-width: 0;
}

.admin-book-group-kicker {
    display: block;
    margin-bottom: 2px;
    color: var(--ab-gold-deep);
    font-size: .68rem;
    font-weight: 950;
}

.admin-book-group-title h3 {
    margin: 0;
    color: var(--ab-ink);
    font-size: 1.05rem;
    line-height: 1.35;
}

.admin-book-group-title > strong {
    display: grid;
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: 50%;
    color: var(--ab-gold);
    background: var(--ab-ink);
    font-size: .82rem;
}

.admin-book-group-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(205px, 1fr));
    align-content: start;
    gap: 13px;
    min-width: 0;
}

.admin-book-group-block.final-review .admin-book-group-list,
.admin-book-group-block.other .admin-book-group-list {
    grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
}

.admin-book-group-empty {
    grid-column: 1 / -1;
    min-height: 155px;
    display: grid;
    place-items: center;
    border: 1px dashed rgba(31, 58, 46, .16);
    border-radius: 18px;
    color: var(--ab-muted);
    background: rgba(250, 246, 236, .65);
    font-weight: 850;
    text-align: center;
}

.admin-book-card {
    display: grid;
    grid-template-rows: auto 1fr;
    min-width: 0;
    overflow: hidden;
    border: 1px solid rgba(31, 58, 46, .09);
    border-radius: 20px;
    background: #fff;
    box-shadow: 0 10px 24px rgba(31, 58, 46, .07);
    transition:
        transform .2s ease,
        box-shadow .2s ease,
        border-color .2s ease;
}

.admin-book-card:hover {
    transform: translateY(-3px);
    border-color: rgba(212, 169, 90, .48);
    box-shadow: 0 18px 34px rgba(31, 58, 46, .12);
}

.admin-book-cover {
    position: relative;
    aspect-ratio: 210 / 297;
    overflow: hidden;
    background:
        linear-gradient(145deg, #faf6ec, #eee5d3);
}

.admin-book-cover img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    background: #f7f2e8;
}

.admin-book-cover-placeholder {
    height: 100%;
    display: grid;
    place-items: center;
    font-size: 2.8rem;
}

.admin-book-cover > span {
    position: absolute;
    top: 9px;
    right: 9px;
    max-width: calc(100% - 18px);
    border-radius: 999px;
    padding: 5px 9px;
    font-size: .68rem;
    font-weight: 950;
    box-shadow: 0 5px 12px rgba(0, 0, 0, .08);
}

.admin-book-cover > span.ok {
    color: #11683c;
    background: rgba(232, 248, 238, .94);
}

.admin-book-cover > span.off {
    color: #a61f1f;
    background: rgba(255, 240, 236, .95);
}

.admin-book-body {
    display: grid;
    align-content: start;
    gap: 9px;
    min-width: 0;
    padding: 12px;
}

.admin-book-body h3 {
    display: -webkit-box;
    min-height: 2.7em;
    margin: 0;
    overflow: hidden;
    color: var(--ab-ink);
    font-size: .96rem;
    line-height: 1.35;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.admin-book-body > p {
    display: -webkit-box;
    min-height: 3.2em;
    margin: 0;
    overflow: hidden;
    color: var(--ab-muted);
    font-size: .78rem;
    line-height: 1.6;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.admin-book-meta,
.admin-book-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin: 0;
}

.admin-book-meta span,
.admin-book-stats span,
.admin-book-stats strong {
    max-width: 100%;
    overflow: hidden;
    border-radius: 999px;
    padding: 5px 7px;
    color: var(--ab-ink);
    background: var(--ab-cream);
    font-size: .67rem;
    font-weight: 900;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-book-stats strong {
    color: var(--ab-gold);
    background: var(--ab-ink);
}

.admin-book-order-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 30px 30px;
    align-items: center;
    gap: 5px;
    min-width: 0;
    padding: 7px;
    border-radius: 12px;
    background: #faf8f3;
}

.admin-book-order-actions > span {
    min-width: 0;
    overflow: hidden;
    color: var(--ab-muted);
    font-size: .7rem;
    font-weight: 900;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-book-order-actions button {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    color: #fff;
    background: var(--ab-ink);
    font-weight: 950;
}

.admin-book-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
}

.admin-book-actions button {
    min-width: 0;
    min-height: 34px;
    border-radius: 10px;
    padding: 6px 4px;
    color: var(--ab-ink);
    background: #f5f1e8;
    font-size: .69rem;
    font-weight: 950;
    white-space: nowrap;
}

.admin-book-actions .admin-book-action-edit {
    color: #fff;
    background: var(--ab-ink);
}

.admin-book-actions .admin-book-action-status {
    color: #765412;
    background: #fff5d8;
}

.admin-book-actions .admin-book-action-visibility {
    color: #7b2f2f;
    background: #fff0ec;
}

.admin-books-empty,
.admin-books-loading,
.admin-books-error {
    padding: 28px;
    border: 1px solid var(--ab-line);
    border-radius: 22px;
    color: var(--ab-ink);
    background: #fff;
    text-align: center;
}

.admin-books-error,
.admin-book-notice.error {
    color: #b22222;
    background: #fff0ec;
}

.admin-book-notice {
    position: sticky;
    top: 78px;
    z-index: 15;
    padding: 12px 15px;
    border-radius: 15px;
    color: #1f7a45;
    background: #e8f8ee;
    box-shadow: 0 10px 22px rgba(31, 58, 46, .11);
    font-weight: 950;
}

/* Stock management preserved and visually normalized */
.admin-books-stock-panel[hidden] {
    display: none !important;
}

.admin-books-stock-panel {
    display: grid;
    gap: 14px;
    min-width: 0;
    padding: 16px;
    border: 1px solid var(--ab-line);
    border-radius: 24px;
    background: #fff;
    box-shadow: 0 14px 34px rgba(31, 58, 46, .07);
}

.stock-panel-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    padding: 18px;
    border-radius: 20px;
    color: #fff;
    background:
        radial-gradient(circle at top left, rgba(212, 169, 90, .16), transparent 34%),
        linear-gradient(135deg, #1f3a2e, #2d5043);
}

.stock-panel-head span {
    color: var(--ab-gold);
    font-weight: 950;
}

.stock-panel-head h3 {
    margin: 5px 0;
    color: #fff;
}

.stock-panel-head p {
    margin: 0;
    color: rgba(255, 255, 255, .8);
    line-height: 1.7;
}

.stock-warning-inline {
    margin-top: 8px !important;
    color: #ffe7a3 !important;
    font-weight: 950;
}

.stock-panel-head button,
.smart-stock-filters button {
    min-height: 38px;
    border: 0;
    border-radius: 11px;
    padding: 8px 11px;
    color: var(--ab-ink);
    background: var(--ab-gold);
    cursor: pointer;
    font: inherit;
    font-weight: 950;
}

.smart-stock-head-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.stock-summary-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 9px;
}

.stock-summary-grid div {
    min-width: 0;
    padding: 11px;
    border: 1px solid rgba(31, 58, 46, .06);
    border-radius: 14px;
    background: #faf6ec;
}

.stock-summary-grid span {
    display: block;
    margin-bottom: 4px;
    color: var(--ab-muted);
    font-size: .73rem;
    font-weight: 950;
}

.stock-summary-grid strong {
    color: var(--ab-ink);
    font-size: 1.15rem;
}

.smart-stock-filters {
    display: grid;
    grid-template-columns: repeat(3, minmax(140px, 1fr)) auto auto auto;
    gap: 8px;
    align-items: center;
}

.smart-stock-filters select {
    width: 100%;
    min-width: 0;
    min-height: 40px;
    border: 1px solid rgba(31, 58, 46, .13);
    border-radius: 11px;
    padding: 0 10px;
    background: #fff;
}

.smart-stock-filters label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--ab-ink);
    font-size: .78rem;
    font-weight: 900;
    white-space: nowrap;
}

.smart-stock-print-note {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 13px;
    border-radius: 13px;
    color: var(--ab-ink);
    background: #faf6ec;
    font-size: .78rem;
}

.stock-table-wrap {
    max-width: 100%;
    overflow-x: auto;
    border-radius: 16px;
}

.stock-table {
    width: 100%;
    min-width: 850px;
    border-collapse: collapse;
    background: #fff;
}

.stock-table th {
    padding: 11px;
    color: #fff;
    background: var(--ab-ink);
    text-align: right;
    white-space: nowrap;
}

.stock-table td {
    padding: 11px;
    border-bottom: 1px solid rgba(31, 58, 46, .08);
    color: var(--ab-ink);
    vertical-align: middle;
}

.stock-table tr.has-shortage td {
    background: #fff8e6;
}

.stock-table td small {
    display: block;
    margin-top: 4px;
    color: var(--ab-muted);
}

.stock-edit-cell {
    display: grid;
    grid-template-columns: 85px auto;
    gap: 6px;
    align-items: center;
}

.stock-edit-cell input {
    min-width: 0;
    border: 1px solid rgba(31, 58, 46, .13);
    border-radius: 9px;
    padding: 7px;
}

.stock-edit-cell button {
    border: 0;
    border-radius: 9px;
    padding: 7px 9px;
    color: #fff;
    background: var(--ab-ink);
    cursor: pointer;
    font-weight: 950;
}

.stock-badge {
    display: inline-flex;
    border-radius: 999px;
    padding: 5px 8px;
    font-size: .73rem;
    font-weight: 950;
}

.stock-badge.ok {
    color: #1f7a45;
    background: #e8f8ee;
}

.stock-badge.danger {
    color: #b22222;
    background: #fff0ec;
}

.stock-badge.idle {
    color: var(--ab-muted);
    background: #f4f1ea;
}

.stock-danger-number {
    color: #b22222;
}

.stock-print-number {
    color: #9b6d13;
}

.stock-empty-row {
    padding: 28px !important;
    text-align: center;
}

/* Tablet */
@media (max-width: 1180px) {
    .admin-books-filters {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .stock-summary-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .smart-stock-filters {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* Mobile: sections stacked, each section keeps two cards per row like book-store */
@media (max-width: 760px) {
    .admin-books-page {
        gap: 12px;
    }

    .admin-books-hero {
        align-items: stretch;
        flex-direction: column;
        padding: 18px;
        border-radius: 21px;
    }

    .admin-books-hero p {
        font-size: .82rem;
        line-height: 1.65;
    }

    .admin-books-hero-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .admin-books-primary,
    .admin-books-secondary {
        min-width: 0;
        width: 100%;
        padding-inline: 8px;
        font-size: .78rem;
    }

    .admin-books-filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 7px;
        padding: 10px;
        border-radius: 18px;
    }

    .admin-books-filters input {
        grid-column: 1 / -1;
    }

    .admin-books-filters input,
    .admin-books-filters select,
    .admin-books-filters button {
        min-width: 0;
        min-height: 40px;
        padding-inline: 8px;
        font-size: .72rem;
    }

    .admin-books-top-columns {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .admin-book-group-block.explanation,
    .admin-book-group-block.exercises {
        grid-column: 1;
    }

    .admin-book-group-block {
        gap: 9px;
        padding: 9px;
        border-radius: 18px;
    }

    .admin-book-group-title {
        min-height: 50px;
        padding: 9px 10px;
        border-radius: 14px;
    }

    .admin-book-group-title h3 {
        font-size: .9rem;
    }

    .admin-book-group-title > strong {
        width: 30px;
        height: 30px;
        flex-basis: 30px;
        font-size: .72rem;
    }

    .admin-book-group-list,
    .admin-book-group-block.final-review .admin-book-group-list,
    .admin-book-group-block.other .admin-book-group-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 7px;
    }

    .admin-book-card {
        border-radius: 14px;
    }

    .admin-book-cover > span {
        top: 6px;
        right: 6px;
        padding: 4px 6px;
        font-size: .57rem;
    }

    .admin-book-body {
        gap: 6px;
        padding: 8px 7px;
    }

    .admin-book-body h3 {
        min-height: 2.6em;
        font-size: .77rem;
        line-height: 1.3;
    }

    .admin-book-body > p {
        min-height: 2.8em;
        font-size: .63rem;
        line-height: 1.45;
    }

    .admin-book-meta,
    .admin-book-stats {
        gap: 3px;
    }

    .admin-book-meta span,
    .admin-book-stats span,
    .admin-book-stats strong {
        max-width: 100%;
        padding: 4px 5px;
        font-size: .55rem;
    }

    .admin-book-order-actions {
        grid-template-columns: minmax(0, 1fr) 26px 26px;
        gap: 3px;
        padding: 5px;
    }

    .admin-book-order-actions > span {
        font-size: .59rem;
    }

    .admin-book-order-actions button {
        width: 26px;
        height: 26px;
        border-radius: 7px;
        font-size: .68rem;
    }

    .admin-book-actions {
        gap: 3px;
    }

    .admin-book-actions button {
        min-height: 29px;
        border-radius: 8px;
        padding: 4px 2px;
        font-size: .56rem;
    }

    .admin-books-stock-panel {
        padding: 9px;
        border-radius: 18px;
    }

    .stock-panel-head {
        align-items: stretch;
        flex-direction: column;
        padding: 13px;
        border-radius: 15px;
    }

    .smart-stock-head-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .stock-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
    }

    .stock-summary-grid div {
        padding: 8px;
    }

    .smart-stock-filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .smart-stock-filters label,
    .smart-stock-filters button {
        min-width: 0;
        font-size: .68rem;
    }

    .smart-stock-print-note {
        align-items: flex-start;
        flex-direction: column;
    }
}

/* Very narrow phones: retain two cards, reduce spacing instead of collapsing */
@media (max-width: 390px) {
    .admin-book-group-list,
    .admin-book-group-block.final-review .admin-book-group-list,
    .admin-book-group-block.other .admin-book-group-list {
        gap: 5px;
    }

    .admin-book-group-block {
        padding: 7px;
    }

    .admin-book-body {
        padding: 7px 5px;
    }

    .admin-book-meta span:nth-child(n + 3) {
        display: none;
    }

    .admin-book-stats span:last-child {
        width: 100%;
    }
}
