/* styles.css */

/* Base page */
body {
    font-family: Arial, sans-serif;
    margin: 16px;
}

.page-title {
    margin: 0 0 12px 0;
}

/* Toolbar */
.toolbar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: end;
    margin-bottom: 12px;
}

.toolbar .group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

label {
    font-size: 12px;
    color: #333;
}

input[type="text"],
select {
    padding: 8px;
    min-width: 260px;
}

button {
    padding: 8px 12px;
    cursor: pointer;
}

/* Legend */
.legend {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin: 10px 0 14px;
}

.legend .item {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    font-size: 12px;
}

.swatch {
    width: 14px;
    height: 14px;
    border: 1px solid #999;
    box-sizing: border-box;
    display: inline-block;
}

/* Global TYPE color classes (usable on any element) */
.type-common-crypt {
    background-color: #d9f7d9 !important;
}

.type-rare-crypt {
    background-color: #d9ecff !important;
}

.type-epic-crypt {
    background-color: #ead9ff !important;
}

.type-citadel {
    background-color: #ffe6cc !important;
}

.type-epic-monster {
    background-color: #ffd9d9 !important;
}

.type-totals {
    background-color: #f3f3f3 !important;
}

/* Tabulator cell coloring */
.tabulator .tabulator-cell.type-common-crypt {
    background-color: #d9f7d9 !important;
}

.tabulator .tabulator-cell.type-rare-crypt {
    background-color: #d9ecff !important;
}

.tabulator .tabulator-cell.type-epic-crypt {
    background-color: #ead9ff !important;
}

.tabulator .tabulator-cell.type-citadel {
    background-color: #ffe6cc !important;
}

.tabulator .tabulator-cell.type-epic-monster {
    background-color: #ffd9d9 !important;
}

.tabulator .tabulator-cell.type-totals {
    background-color: #f3f3f3 !important;
}

/* Tabulator column header coloring */
.tabulator .tabulator-col.type-common-crypt .tabulator-col-content {
    background-color: #d9f7d9 !important;
}

.tabulator .tabulator-col.type-rare-crypt .tabulator-col-content {
    background-color: #d9ecff !important;
}

.tabulator .tabulator-col.type-epic-crypt .tabulator-col-content {
    background-color: #ead9ff !important;
}

.tabulator .tabulator-col.type-citadel .tabulator-col-content {
    background-color: #ffe6cc !important;
}

.tabulator .tabulator-col.type-epic-monster .tabulator-col-content {
    background-color: #ffd9d9 !important;
}

.tabulator .tabulator-col.type-totals .tabulator-col-content {
    background-color: #f3f3f3 !important;
}

/* Tabulator group header coloring */
.tabulator .tabulator-col-group.type-common-crypt .tabulator-col-group-title {
    background-color: #d9f7d9 !important;
}

.tabulator .tabulator-col-group.type-rare-crypt .tabulator-col-group-title {
    background-color: #d9ecff !important;
}

.tabulator .tabulator-col-group.type-epic-crypt .tabulator-col-group-title {
    background-color: #ead9ff !important;
}

.tabulator .tabulator-col-group.type-citadel .tabulator-col-group-title {
    background-color: #ffe6cc !important;
}

.tabulator .tabulator-col-group.type-epic-monster .tabulator-col-group-title {
    background-color: #ffd9d9 !important;
}

.tabulator .tabulator-col-group.type-totals .tabulator-col-group-title {
    background-color: #f3f3f3 !important;
}

/* Keep cells readable */
.tabulator .tabulator-cell {
    white-space: nowrap;
}

/* Dropdown picker (Players + Columns) */
.dropdown-picker {
    position: relative;
    display: inline-block;
    min-width: 320px;
}

.picker-btn {
    display: inline-flex;
    justify-content: space-between;
    align-items: center;
    width: 320px;
    padding: 8px 10px;
}

.picker-caret {
    margin-left: 10px;
    font-size: 12px;
}

/* Updated dark theme picker panel */
.picker-panel {
    position: absolute;
    z-index: 50;
    top: calc(100% + 6px);
    left: 0;
    max-width: 90vw;

    background: #1f344e;
    background: linear-gradient(to bottom,
            rgba(16, 26, 51, 0.92),
            rgba(16, 26, 51, 0.95));

    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    padding: 12px;

    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(6px);

    color: #e6edf7;
    display: none;
}

.picker-panel.open {
    display: block;
}

.picker-top {
    display: flex;
    gap: 8px;
    align-items: center;
}

.picker-top input {
    flex: 1;
    min-width: 0;
}

.picker-close {
    padding: 8px 10px;
}

/* Dark theme input styling inside picker */
.picker-panel input[type="text"] {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

.picker-panel input[type="text"]::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.picker-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    margin-bottom: 8px;
}

.picker-action-row {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    cursor: pointer;
    user-select: none;
    color: #e6edf7;
}

.picker-action-row input {
    width: 14px;
    height: 14px;
}

.picker-action-btn {
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

.picker-action-btn:hover {
    background: rgba(255, 255, 255, 0.14);
}

.picker-list {
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    margin-top: 8px;
    padding-top: 8px;
    max-height: 260px;
    overflow: auto;
}

.picker-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 2px;
    font-size: 12px;
    cursor: pointer;
    user-select: none;
    color: #e6edf7;
}

.picker-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.picker-item input {
    width: 14px;
    height: 14px;
}

/* Make details panel span the full row width inside Tabulator's flex row */
.tabulator .tabulator-row .row-details {
    flex-basis: 100%;
    width: 100%;
    order: 9999;
}

/* Row details panel */
.row-details {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 10px;
    margin: 6px 0 10px 0;
    background: #fff;
}

.row-details-title {
    font-size: 12px;
    font-weight: bold;
    margin-bottom: 8px;
}

.row-details-grid {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.details-card {
    border: 1px solid #eee;
    border-radius: 6px;
    padding: 8px;
    min-width: 240px;
}

.details-card .card-title {
    font-size: 12px;
    font-weight: bold;
    margin-bottom: 6px;
}

/* Updated details table styling */
.details-table {
    border-collapse: collapse;
    font-size: 12px;
    background: #fff;
    border: 1px solid #e6e6e6;
}

.details-table thead {
    background: #f8f8f8;
}

.details-table th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.4px;
    color: #444;
    padding: 6px 8px;
    border-bottom: 1px solid #e6e6e6;
    text-align: right;
}

.details-table td {
    padding: 6px 8px;
    border-bottom: 1px solid #f0f0f0;
    text-align: right;
}

.details-table th:first-child,
.details-table td:first-child {
    text-align: left;
}

.details-table tr:last-child td {
    border-bottom: none;
}

.details-table tr:hover td {
    background: #fafafa;
}

/* Player cell: expander + name */
.cc-player-cell {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.cc-expander {
    width: 16px;
    height: 16px;
    border: 1px solid #cfcfcf;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    cursor: pointer;
    user-select: none;
}

.cc-expander::before {
    content: "v";
    font-size: 12px;
    line-height: 1;
    color: #444;
    position: relative;
    top: -1px;
}

.cc-expander:hover {
    background: #f7f7f7;
}

.cc-player-name {
    cursor: pointer;
}

/* Dark themed modal overlay */
.cc-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 10, 20, 0.65);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 24px;
}

.cc-modal-overlay.open {
    display: flex;
}

/* Dark gradient modal */
.cc-modal {
    width: min(960px, 96vw);
    max-height: 88vh;
    overflow: auto;

    background: #1f344e;
    background: linear-gradient(to bottom,
            rgba(16, 26, 51, 0.95),
            rgba(16, 26, 51, 0.98));

    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);

    color: #e6edf7;
}

/* Sticky header */
.cc-modal-header {
    position: sticky;
    top: 0;

    background: rgba(16, 26, 51, 0.98);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);

    padding: 14px 16px;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.cc-modal-title {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.4px;
    color: #ffffff;
}

/* Close button styled to match theme */
.cc-modal-close {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    color: #ffffff;
}

.cc-modal-close:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Body area */
.cc-modal-body {
    padding: 16px;
}

/* Prevent background scroll when open */
body.cc-modal-open {
    overflow: hidden;
}

/* Dark details table inside modal */
.cc-modal .details-table {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.cc-modal .details-table thead {
    background: rgba(255, 255, 255, 0.05);
}

.cc-modal .details-table th {
    color: #cfd8e6;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.cc-modal .details-table td {
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    color: #e6edf7;
}

.cc-modal .details-table tr:hover td {
    background: rgba(255, 255, 255, 0.05);
}