/* =========================================================
   LITERATURE MATRIX — PAGE-SPECIFIC STYLES
========================================================= */

/* Matrix page uses slightly different header spacing */
.page-header {
    margin-bottom: 0;
}


/* =========================
   SUMMARY
========================= */

.summary-grid {
    display: flex;
    gap: 16px;
    margin-bottom: 28px;
}

.summary-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 17px 20px;

    display: flex;
    align-items: center;
    gap: 13px;
    min-width: 190px;
}

.summary-icon {
    width: 37px;
    height: 37px;
    background: #eff6ff;
    border-radius: 8px;

    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
}

.summary-label {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 2px;
}

.summary-card strong {
    font-size: 21px;
}

/* =========================
   TOOLBAR
========================= */

.matrix-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
}

.toolbar-actions {
    display: flex;
    gap: 10px;
}


/* =========================
   MATRIX SECTION
========================= */

.matrix-section {
    margin-top: 10px;
}


.matrix-container {
    background: white;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    overflow-x: auto;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}


/* =========================
   TABLE
========================= */

.matrix-table {
    width: 100%;
    min-width: 1250px;
    border-collapse: collapse;
}

.matrix-table th {
    background: #f8fafc;
    border-bottom: 1px solid var(--border-light);
    border-right: 1px solid var(--border-light);
    padding: 14px 13px;
    text-align: left;
    font-size: 14px;
    color: #475569;
    font-weight: 700;
    white-space: nowrap;
}

.matrix-table th:last-child {
    border-right: none;
}

.matrix-table td {
    border-bottom: 1px solid var(--border-light);
    border-right: 1px solid var(--border-light);
    padding: 0;
    vertical-align: top;
}

.matrix-table tr:last-child td {
    border-bottom: none;
}

.fullscreen-table-wrapper .matrix-table {
    border-bottom: 1px solid var(--border-light);
}

.matrix-table td:last-child {
    border-right: none;
}

.matrix-cell {
    min-height: 72px;
    width: 100%;
    border: none;
    outline: none;
    background: transparent;
    padding: 12px;
    font-family: inherit;
    font-size: 13px;
    line-height: 1.5;
    color: #334155;
    resize: none;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
}

.matrix-cell::-webkit-scrollbar {
    width: 6px;
}

.matrix-cell::-webkit-scrollbar-track {
    background: transparent;
}

.matrix-cell::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 10px;
}

.matrix-cell:hover {
    scrollbar-color: #cbd5e1 transparent;
}

.matrix-cell:hover::-webkit-scrollbar-thumb {
    background: #cbd5e1;
}

.matrix-cell:focus {
    background: #eff6ff;
    box-shadow: inset 0 0 0 2px #93c5fd;
}

.paper-cell {
    min-width: 240px;
    left: 0;
    background: #ffffff;
    z-index: 5;
    box-shadow: 6px 0 10px -8px rgba(15, 23, 42, 0.35);
}

.year-cell {
    min-width: 80px;
}

.standard-cell {
    min-width: 210px;
}

.actions-cell {
    min-width: 105px;
    width: 105px;
}

.paper-title-cell {
    font-weight: 600;
    color: var(--text-heading);
}

.delete-row-button {
    margin: 12px;
    border: 1px solid #fecaca;
    background: #fef2f2;
    color: #dc2626;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: 0.2s;
}

.delete-row-button:hover {
    background: #fee2e2;
}


/* =========================
   MATRIX MODALS
========================= */

#columnsModal,
#paperModal {
    z-index: 6000;
}

.modal {
    width: min(760px, 100%);
    max-height: 92vh;
}

.modal-header {
    padding: 25px 30px 20px;
}

.modal-header h2 {
    font-size: 22px;
    margin: 7px 0;
}

.modal-header p {
    font-size: 13px;
}

#paperForm {
    padding: 25px 30px;
}

.matrix-toolbar .form-group label {
    font-size: 13px;
    margin-bottom: 8px;
}

.matrix-toolbar .form-group input,
.matrix-toolbar .form-group textarea {
    padding: 11px 12px;
    font-size: 13px;
}

.form-group textarea {
    min-height: 100px;
}


/* =========================
   FULLSCREEN MATRIX
========================= */

.matrix-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 5000;
    background: #f5f7fa;
    display: none;
    flex-direction: column;
}

.matrix-fullscreen.active {
    display: flex;
}

.fullscreen-header {
    flex-shrink: 0;
    min-height: 82px;
    background: white;
    border-bottom: 1px solid var(--border-light);
    padding: 16px 24px;

    display: flex;
    align-items: center;
    justify-content: space-between;
}

.fullscreen-header h2 {
    font-size: 21px;
    margin: 3px 0;
}

.fullscreen-header span:not(.modal-label) {
    color: var(--muted);
    font-size: 12px;
}

.fullscreen-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.fullscreen-close {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    background: white;
    color: #475569;
    font-size: 25px;
    cursor: pointer;
    transition: 0.2s;
}

.fullscreen-close:hover {
    background: #f1f5f9;
    color: var(--text-heading);
    border-color: #cbd5e1;
}

.fullscreen-table-wrapper {
    flex: 1;
    overflow: auto;
    padding: 20px;
    padding-left: 0;
}

.fullscreen-table-wrapper .matrix-table {
    min-width: 1500px;
}

.fullscreen-table-wrapper .matrix-table th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #f8fafc;
}

.fullscreen-table-wrapper .matrix-table th:first-child {
    position: sticky;
    left: 0;
    z-index: 30;
    background: #f8fafc;
    padding-left: 30px;
    min-width: 280px;
    box-shadow: 6px 0 10px -8px rgba(15, 23, 42, 0.35);
}

.fullscreen-table-wrapper .matrix-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 15;
    background: white;
    padding-left: 18px;
    min-width: 280px;
    box-shadow: 6px 0 10px -8px rgba(15, 23, 42, 0.35);
}

.fullscreen-table-wrapper .matrix-cell {
    min-height: 90px;
    font-size: 14px;
    padding: 14px;
}

.fullscreen-table-wrapper .matrix-table th {
    font-size: 15px;
    padding: 16px 14px;
}

.fullscreen-manage-columns {
    height: 42px;
    padding: 0 15px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: white;
    color: #334155;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 7px;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.fullscreen-manage-columns:hover {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #2563eb;
}

.fullscreen-add-paper {
    height: 42px;
    padding: 0 17px;
    border: 1px solid #2563eb;
    border-radius: var(--radius-sm);
    background: #2563eb;
    color: white;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.2s, border-color 0.2s, transform 0.15s;
}

.fullscreen-add-paper:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

.fullscreen-add-paper:active {
    transform: translateY(1px);
}


/* =========================
   MANAGE COLUMNS
========================= */

.columns-modal {
    width: min(620px, calc(100vw - 40px));
    max-height: 85vh;
    background: white;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.22);
    display: flex;
    flex-direction: column;
}

.columns-content {
    padding: 24px 30px;
    overflow-y: auto;
}

.columns-section {
    margin-bottom: 24px;
}

.columns-section-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.columns-list {
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.column-item {
    min-height: 52px;
    padding: 9px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid #e5e7eb;
    background: white;
}

.column-item:last-child {
    border-bottom: none;
}

.column-drag {
    color: #94a3b8;
    font-size: 17px;
    cursor: grab;
}

.column-name {
    flex: 1;
    font-size: 14px;
    color: #334155;
}

.column-edit-button,
.column-delete-button {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.column-edit-button {
    border: 1px solid var(--border-light);
    background: white;
    color: #475569;
}

.column-edit-button:hover {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #2563eb;
}

.column-delete-button {
    border: 1px solid #fecaca;
    background: #fef2f2;
    color: #dc2626;
}

.column-delete-button:hover {
    background: #fee2e2;
}

.column-lock {
    width: 34px;
    text-align: center;
    color: #94a3b8;
    font-size: 15px;
}

.add-column-large-button {
    width: 100%;
    padding: 12px;
    border: 1px dashed #93c5fd;
    border-radius: var(--radius-sm);
    background: #eff6ff;
    color: #2563eb;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
}

.add-column-large-button:hover {
    background: #dbeafe;
    border-color: #60a5fa;
}

.no-custom-columns {
    padding: 18px;
    text-align: center;
    color: #94a3b8;
    font-size: 13px;
    border: 1px dashed var(--border-light);
    border-radius: var(--radius-sm);
}

.matrix-paper-highlight td {
    background: #eff6ff !important;
    transition: background 0.3s ease;
}

.open-library-button {
    width: 34px;
    height: 34px;
    border: 1px solid #bfdbfe;
    background: #eff6ff;
    color: #2563eb;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.open-library-button:hover {
    background: #dbeafe;
    border-color: #93c5fd;
    transform: translateY(-1px);
}


/* =========================
   RESPONSIVE
========================= */

@media (max-width: 900px) {
    .matrix-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-actions {
        justify-content: flex-end;
    }
}

@media (max-width: 650px) {
    .summary-grid {
        flex-direction: column;
    }

    .summary-card {
        width: 100%;
    }
}

@media (max-width: 700px) {
    .fullscreen-table-wrapper {
        padding: 10px;
    }

    .fullscreen-header {
        padding: 14px 16px;
        flex-wrap: wrap;
        gap: 12px;
    }
}
