
/* =====================================
   CATEGORIES PAGE
===================================== */

.categories-page {
    min-width: 0;
    padding: 28px;
}

.categories-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 26px;
}

.categories-page-header h2 {
    margin: 0 0 8px;
    color: #172b24;
    font-size: 28px;
    font-weight: 750;
}

.categories-page-header p {
    margin: 0;
    color: #718078;
    font-size: 14px;
}

.add-category-button {
    flex-shrink: 0;
    padding: 12px 18px;
    border: none;
    border-radius: 9px;
    background: #176b4d;
    color: #ffffff;
    font-size: 13px;
    font-weight: 650;
    cursor: pointer;
    transition: background 0.2s ease;
}

.add-category-button:hover {
    background: #10563d;
}

.add-category-button:focus-visible,
.category-card:focus-visible,
.category-detail-actions button:focus-visible {
    outline: 3px solid #94d7b8;
    outline-offset: 3px;
}

/* Overview */

.categories-overview {
    display: grid;
    grid-template-columns: minmax(180px, 260px);
    gap: 16px;
    margin-bottom: 26px;
}

.category-stat-card {
    padding: 22px;
    border: 1px solid #e5ece7;
    border-radius: 14px;
    background: #ffffff;
    box-shadow: 0 4px 16px rgba(20, 50, 35, 0.04);
}

.category-stat-card p {
    margin: 0 0 12px;
    color: #6c7c73;
    font-size: 13px;
}

.category-stat-card h3 {
    margin: 0;
    color: #176b4d;
    font-size: 29px;
    font-weight: 750;
}

/* Category list */

.categories-list-section {
    overflow: hidden;
    border: 1px solid #e5ece7;
    border-radius: 14px;
    background: #ffffff;
    box-shadow: 0 4px 16px rgba(20, 50, 35, 0.04);
}

.categories-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 22px;
    border-bottom: 1px solid #edf1ee;
}

.categories-list-header h3 {
    margin: 0 0 7px;
    color: #20352a;
    font-size: 18px;
}

.categories-list-header p {
    margin: 0;
    color: #78877f;
    font-size: 12px;
}

#category-search {
    width: min(100%, 320px);
    min-height: 42px;
    box-sizing: border-box;
    padding: 10px 13px;
    border: 1px solid #dce5df;
    border-radius: 9px;
    background: #fbfdfb;
    color: #263b30;
    font: inherit;
    font-size: 13px;
    outline: none;
}

#category-search:focus {
    border-color: #26845f;
    box-shadow: 0 0 0 3px rgba(38, 132, 95, 0.12);
}

.categories-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    padding: 22px;
}

.category-card {
    display: flex;
    align-items: center;
    gap: 13px;
    width: 100%;
    min-width: 0;
    padding: 17px;
    border: 1px solid #e3ebe5;
    border-radius: 12px;
    background: #ffffff;
    color: #263b30;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.category-card:hover {
    border-color: #a7cdb7;
    background: #f8fbf9;
}

.category-card.selected {
    border-color: #26845f;
    background: #edf7f0;
}

.category-card-icon {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: #e8f4ec;
    color: #176b4d;
    font-size: 23px;
}

.category-card-name {
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
    font-size: 15px;
    font-weight: 650;
}

.category-card-arrow {
    flex-shrink: 0;
    color: #7c8b82;
    font-size: 26px;
}

.categories-empty {
    grid-column: 1 / -1;
    padding: 30px 15px;
    color: #7b8981;
    text-align: center;
    font-size: 14px;
}

/* Selected category details */

.category-details-panel {
    margin-top: 22px;
    padding: 24px;
    border: 1px solid #dfe9e2;
    border-radius: 14px;
    background: #ffffff;
    box-shadow: 0 4px 16px rgba(20, 50, 35, 0.04);
}

.category-details-panel[hidden] {
    display: none;
}

.category-details-header {
    margin-bottom: 22px;
}

.category-details-header h3,
.category-details-panel > h3 {
    margin: 0 0 8px;
    color: #0a4225;
    font-size: 21px;
}

.category-details-header p {
    margin: 0;
    color: #78877f;
    font-size: 13px;
}

.category-detail-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.category-detail-actions button,
.category-rename-form button {
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 650;
    cursor: pointer;
}

.category-rename-button {
    background: #e5f1ff;
    color: #205a9a;
}

.category-rename-button:hover {
    background: #d4e7ff;
}

.category-delete-button {
    background: #fde8e8;
    color: #b42323;
}

.category-delete-button:hover {
    background: #fbd5d5;
}

.category-cancel-button {
    background: #eef1ef;
    color: #405148;
}

/* Rename form */

.category-rename-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    margin-top: 18px;
}

.category-rename-form label {
    color: #405148;
    font-size: 13px;
    font-weight: 650;
}

.category-rename-form input {
    width: 100%;
    box-sizing: border-box;
    min-height: 43px;
    padding: 10px 12px;
    border: 1px solid #dce5df;
    border-radius: 8px;
    font: inherit;
}

.category-rename-form input:focus {
    border-color: #26845f;
    outline: 2px solid #d7eee0;
}

.category-rename-form button {
    justify-self: start;
}

.categories-message {
    margin-top: 16px;
    color: #044931;
    font-size: 13px;
}

.categories-message.error {
    color: #b42323;
}

/* Responsive layout */

@media (max-width: 900px) {
    .categories-page {
        padding: 22px;
    }

    .categories-list {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .categories-page {
        padding: 16px;
    }

    .categories-page-header {
        align-items: stretch;
        flex-direction: column;
    }

    .categories-page-header h2 {
        font-size: 23px;
    }

    .add-category-button {
        width: 100%;
    }

    .categories-list-header {
        align-items: stretch;
        flex-direction: column;
        padding: 17px;
    }

    #category-search {
        width: 100%;
    }

    .categories-list {
        padding: 15px;
        gap: 10px;
    }

    .category-details-panel {
        padding: 18px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .category-card,
    .add-category-button {
        transition: none;
    }
}
/* Category cards: 6 per row, compact */
.categories-list {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 12px;
    padding: 18px;
}

.category-card {
    flex-direction: column;
    justify-content: center;
    text-align: center;
    gap: 8px;
    min-height: 110px;
    padding: 12px 8px;
}

.category-card-icon {
    width: 36px;
    height: 36px;
    font-size: 20px;
}

.category-card-name {
    flex: none;
    font-size: 13px;
}

.category-card-arrow {
    display: none;
}

/* Choti screens par kam boxes */
@media (max-width: 900px) {
    .categories-list {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 600px) {
    .categories-list {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
        padding: 12px;
    }
}
.category-card[data-color="1"] { --c: #176b4d; --bg: #e8f4ec; }
.category-card[data-color="2"] { --c: #205a9a; --bg: #e5f1ff; }
.category-card[data-color="3"] { --c: #b45309; --bg: #fef3e2; }
.category-card[data-color="4"] { --c: #7c3aed; --bg: #f1eafe; }
.category-card[data-color="5"] { --c: #be185d; --bg: #fde8f1; }
.category-card[data-color="6"] { --c: #0e7490; --bg: #e0f4f8; }
/* Har category ka alag pakka rang: solid box, white text */
.category-card[data-color="1"] { --c: #176b4d; --c-dark: #10563d; }
.category-card[data-color="2"] { --c: #205a9a; --c-dark: #174578; }
.category-card[data-color="3"] { --c: #d97706; --c-dark: #b45309; }
.category-card[data-color="4"] { --c: #7c3aed; --c-dark: #6228c4; }
.category-card[data-color="5"] { --c: #be185d; --c-dark: #96114a; }
.category-card[data-color="6"] { --c: #0e7490; --c-dark: #0a5870; }

.category-card {
    background: var(--c);
    border-color: var(--c);
    color: #ffffff;
}

.category-card-icon {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.category-card-name {
    color: #ffffff;
}

.category-card:hover {
    background: var(--c-dark);
    border-color: var(--c-dark);
}

.category-card.selected {
    background: var(--c-dark);
    border-color: #ffffff;
    box-shadow: 0 0 0 3px var(--c);
}
/* Card ke kone mein edit/delete buttons */
.category-card-wrap {
    position: relative;
    min-width: 0;
}

.category-card-wrap .category-card {
    width: 100%;
    height: 100%;
}

.category-card-tools {
    position: absolute;
    top: 6px;
    right: 6px;
    display: flex;
    gap: 4px;
}

.category-tool-button {
    width: 26px;
    height: 26px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
}

.category-tool-button:hover {
    background: rgba(255, 255, 255, 0.5);
}

.category-tool-delete:hover {
    background: #dc2626;
}

/* Books ki table */
.category-books-wrapper {
    overflow-x: auto;
    border: 1px solid #e5ece7;
    border-radius: 10px;
}

.category-books-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.category-books-table th,
.category-books-table td {
    padding: 11px 14px;
    text-align: left;
    border-bottom: 1px solid #edf1ee;
}

.category-books-table th {
    background: #f4f8f5;
    color: #405148;
    font-weight: 650;
}

.category-books-table tr:last-child td {
    border-bottom: none;
}
/* Cards ke kone ke buttons chhupa do */
.category-card-tools {
    display: none !important;
}

/* Manage Categories button */
.manage-category-button {
    flex-shrink: 0;
    padding: 12px 18px;
    border: 1px solid #176b4d;
    border-radius: 9px;
    background: #ffffff;
    color: #176b4d;
    font-size: 13px;
    font-weight: 650;
    cursor: pointer;
}

.manage-category-button:hover {
    background: #e8f4ec;
}

/* Manage panel */
.category-manage-panel {
    margin-top: 22px;
    padding: 24px;
    border: 1px solid #dfe9e2;
    border-radius: 14px;
    background: #ffffff;
    box-shadow: 0 4px 16px rgba(20, 50, 35, 0.04);
}

.category-manage-panel[hidden] {
    display: none;
}

.category-manage-panel h3 {
    margin: 0 0 8px;
    color: #20352a;
    font-size: 21px;
}

.category-manage-panel > p {
    margin: 0 0 18px;
    color: #78877f;
    font-size: 13px;
}

.category-manage-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.category-manage-table th,
.category-manage-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid #edf1ee;
}

.category-manage-table th {
    background: #f4f8f5;
    color: #405148;
    font-weight: 650;
}

.category-manage-actions {
    display: flex;
    gap: 8px;
}

.category-manage-actions button {
    padding: 8px 14px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 650;
    cursor: pointer;
}

.category-manage-actions button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
/* ===== Books ki table (card click par) ===== */
.category-books-wrapper {
    overflow-x: auto;
    border: 1px solid #e5ece7;
    border-radius: 10px;
}

.category-books-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.category-books-table th,
.category-books-table td {
    padding: 11px 14px;
    text-align: left;
    border-bottom: 1px solid #edf1ee;
}

.category-books-table th {
    background: #f4f8f5;
    color: #405148;
    font-weight: 650;
}

.category-books-table tr:last-child td {
    border-bottom: none;
}

/* ===== Manage Categories button ===== */
.manage-category-button {
    flex-shrink: 0;
    padding: 12px 18px;
    border: 1px solid #176b4d;
    border-radius: 9px;
    background: #ffffff;
    color: #176b4d;
    font-size: 13px;
    font-weight: 650;
    cursor: pointer;
}

.manage-category-button:hover {
    background: #e8f4ec;
}

/* ===== Manage panel ===== */
.category-manage-panel {
    margin-top: 22px;
    padding: 24px;
    border: 1px solid #dfe9e2;
    border-radius: 14px;
    background: #ffffff;
    box-shadow: 0 4px 16px rgba(20, 50, 35, 0.04);
}

.category-manage-panel[hidden] {
    display: none;
}

.category-manage-panel h3 {
    margin: 0 0 8px;
    color: #20352a;
    font-size: 21px;
}

.category-manage-panel > p {
    margin: 0 0 18px;
    color: #78877f;
    font-size: 13px;
}

.category-manage-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.category-manage-table th,
.category-manage-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid #edf1ee;
}

.category-manage-table th {
    background: #f4f8f5;
    color: #405148;
    font-weight: 650;
}

.category-manage-actions {
    display: flex;
    gap: 8px;
}

.category-manage-actions button {
    padding: 8px 14px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 650;
    cursor: pointer;
}

.category-manage-actions button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Header mein buttons ek line mein */
.categories-page-header {
    flex-wrap: wrap;
}
/* ===== Mobile fix: page screen se bahar na nikle ===== */
html, body {
    max-width: 100%;
    overflow-x: hidden;
}

.categories-page,
.category-manage-panel,
.category-details-panel,
.categories-list-section {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

/* Table ko apne andar scroll karne do, page ko nahi */
.category-manage-panel,
.category-details-panel {
    overflow-x: auto;
}

@media (max-width: 700px) {
    .categories-page {
        padding: 14px;
    }

    .category-manage-panel,
    .category-details-panel {
        padding: 14px;
    }

    .category-manage-table th,
    .category-manage-table td {
        padding: 10px 8px;
        font-size: 13px;
    }

    .category-manage-actions {
        flex-wrap: wrap;
        gap: 6px;
    }

    .category-manage-actions button {
        padding: 7px 10px;
        font-size: 12px;
    }

    .manage-category-button,
    .add-category-button {
        width: 100%;
    }
}
/* ===== Header buttons: ek line, laptop par right side ===== */
.categories-page-header {
    flex-wrap: wrap;
}

.categories-page-header .add-category-button,
.categories-page-header .manage-category-button {
    width: auto;
}

/* Laptop: dono buttons right side mein */
@media (min-width: 601px) {
    .categories-page-header {
        flex-wrap: nowrap;
    }

    .categories-page-header .add-category-button {
        margin-left: auto;
    }

    .categories-page-header .manage-category-button {
        margin-left: 10px;
    }
}

/* Mobile: dono buttons ek line mein */
@media (max-width: 600px) {
    .categories-page-header {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .categories-page-header > div:first-child {
        grid-column: 1 / -1;
    }

    .categories-page-header .add-category-button,
    .categories-page-header .manage-category-button {
        width: 100%;
        padding: 12px 8px;
        font-size: 13px;
        white-space: nowrap;
    }
}

/* Total Categories card ki zaroorat nahi */
.categories-overview {
    display: none !important;
}