/*
 * columns.css
 * Styles for the column picker sidebar panel.
 * Light/dark via body.dark-mode — matches the existing theme system.
 */

/* =========================================================================
   Overlay
   ========================================================================= */

#cp-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 1100;
    opacity: 0;
    transition: opacity 0.25s ease;
}

#cp-overlay.cp-open {
    display: block;
    opacity: 1;
}

/* =========================================================================
   Sidebar panel
   ========================================================================= */

#cp-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 320px;
    height: 100vh;
    z-index: 1101;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);

    /* Light mode defaults */
    background: #ffffff;
    border-left: 1px solid #d0d0d0;
    box-shadow: none;
    color: #1a1a1a;
}

#cp-sidebar.cp-open {
    transform: translateX(0);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.12);
}

/* =========================================================================
   Header
   ========================================================================= */

.cp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 12px;
    border-bottom: 1px solid #e0e0e0;
    flex-shrink: 0;
}

.cp-title {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.cp-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 4px 6px;
    border-radius: 4px;
    color: #555;
    transition: background 0.15s, color 0.15s;
}

.cp-close-btn:hover {
    background: #f0f0f0;
    color: #111;
}

/* =========================================================================
   Search / filter input
   ========================================================================= */

.cp-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid #e8e8e8;
    flex-shrink: 0;
}

.cp-search-input {
    width: 100%;
    padding: 6px 28px 6px 10px;
    font-size: 12px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    outline: none;
    background: #f9f9f9;
    color: #1a1a1a;
    transition: border-color 0.15s, background 0.15s;
}

.cp-search-input:focus {
    border-color: #3b82f6;
    background: #fff;
}

.cp-search-input::placeholder {
    color: #bbb;
}

.cp-search-clear {
    position: absolute;
    right: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    color: #aaa;
    padding: 2px 4px;
    border-radius: 3px;
    transition: color 0.15s;
}

.cp-search-clear:hover {
    color: #555;
}

/* =========================================================================
   Drag disabled state (filter active)
   ========================================================================= */

.cp-item.cp-no-drag {
    cursor: default;
}

.cp-item.cp-no-drag .cp-drag-handle {
    cursor: default;
    opacity: 0.3;
}

/* =========================================================================
   Subheader hint
   ========================================================================= */

.cp-subheader {
    padding: 7px 16px;
    font-size: 11px;
    color: #888;
    border-bottom: 1px solid #e8e8e8;
    flex-shrink: 0;
}

/* =========================================================================
   Scrollable list area
   ========================================================================= */

.cp-list-wrap {
    flex: 1;
    overflow-y: auto;
    padding: 6px 0;
    /* Thin custom scrollbar */
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
}

.cp-list-wrap::-webkit-scrollbar       { width: 5px; }
.cp-list-wrap::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }

.cp-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* =========================================================================
   List item
   ========================================================================= */

.cp-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    cursor: grab;
    border-bottom: 1px solid transparent;
    transition: background 0.12s;
    user-select: none;
}

.cp-item:hover {
    background: #f5f5f5;
}

.cp-item.cp-drag-over {
    border-bottom: 2px solid #3b82f6;
    background: #eff6ff;
}

.cp-item.cp-dragging {
    opacity: 0.45;
    cursor: grabbing;
}

/* Dim hidden columns slightly */
.cp-item:not(.cp-visible) {
    opacity: 0.55;
}

/* =========================================================================
   Drag handle
   ========================================================================= */

.cp-drag-handle {
    font-size: 16px;
    color: #bbb;
    cursor: grab;
    flex-shrink: 0;
    line-height: 1;
    padding: 2px;
}

.cp-item:hover .cp-drag-handle {
    color: #888;
}

/* =========================================================================
   Checkbox + label
   ========================================================================= */

.cp-item-label {
    display: flex;
    align-items: center;
    gap: 9px;
    cursor: pointer;
    flex: 1;
    min-width: 0;
}

.cp-checkbox {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: #3b82f6;
}

.cp-col-names {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.cp-col-label {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #1a1a1a;
}

.cp-col-key {
    font-size: 10px;
    color: #999;
    font-family: monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}

/* =========================================================================
   Footer (Apply / Cancel)
   ========================================================================= */

.cp-footer {
    display: flex;
    gap: 10px;
    padding: 12px 16px;
    border-top: 1px solid #e0e0e0;
    flex-shrink: 0;
}

.cp-btn {
    flex: 1;
    padding: 8px 0;
    font-size: 13px;
    font-weight: 500;
    border-radius: 5px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.cp-btn-cancel {
    background: #f3f3f3;
    color: #444;
    border-color: #d8d8d8;
}

.cp-btn-cancel:hover {
    background: #e8e8e8;
}

.cp-btn-apply {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

.cp-btn-apply:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

/* =========================================================================
   Trigger button in footer
   ========================================================================= */

#cp-open-btn {
    margin-left: auto; /* push to the right end of the footer row */
}

/* =========================================================================
   DARK MODE  (body.dark-mode)
   ========================================================================= */

body.dark-mode #cp-sidebar {
    background: #1e1e2e;
    border-left-color: #2e2e3e;
    box-shadow: none;
    color: #e0e0e0;
}

body.dark-mode #cp-sidebar.cp-open {
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.45);
}

body.dark-mode .cp-header {
    border-bottom-color: #2e2e3e;
}

body.dark-mode .cp-title {
    color: #f0f0f0;
}

body.dark-mode .cp-close-btn {
    color: #aaa;
}

body.dark-mode .cp-close-btn:hover {
    background: #2c2c3e;
    color: #fff;
}

body.dark-mode .cp-subheader {
    color: #666;
    border-bottom-color: #2a2a3a;
}

body.dark-mode .cp-list-wrap {
    scrollbar-color: #3a3a4a transparent;
}

body.dark-mode .cp-list-wrap::-webkit-scrollbar-thumb {
    background: #3a3a4a;
}

body.dark-mode .cp-item:hover {
    background: #26263a;
}

body.dark-mode .cp-item.cp-drag-over {
    border-bottom-color: #60a5fa;
    background: #1e2a40;
}

body.dark-mode .cp-drag-handle {
    color: #444;
}

body.dark-mode .cp-item:hover .cp-drag-handle {
    color: #777;
}

body.dark-mode .cp-checkbox {
    accent-color: #60a5fa;
}

body.dark-mode .cp-col-label {
    color: #e0e0e0;
}

body.dark-mode .cp-col-key {
    color: #555;
}

body.dark-mode .cp-footer {
    border-top-color: #2e2e3e;
}

body.dark-mode .cp-btn-cancel {
    background: #2a2a3a;
    color: #bbb;
    border-color: #3a3a4a;
}

body.dark-mode .cp-btn-cancel:hover {
    background: #32324a;
}

body.dark-mode .cp-btn-apply {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

body.dark-mode .cp-btn-apply:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

body.dark-mode #cp-overlay {
    background: rgba(0, 0, 0, 0.55);
}

body.dark-mode .cp-search-wrap {
    border-bottom-color: #2a2a3a;
}

body.dark-mode .cp-search-input {
    background: #16161e;
    border-color: #3a3a4a;
    color: #e0e0e0;
}

body.dark-mode .cp-search-input:focus {
    border-color: #60a5fa;
    background: #1a1a2a;
}

body.dark-mode .cp-search-input::placeholder {
    color: #444;
}

body.dark-mode .cp-search-clear {
    color: #555;
}

body.dark-mode .cp-search-clear:hover {
    color: #aaa;
}

/* =========================================================================
   Add To Group — domain summary block
   ========================================================================= */

.atg-domain-summary {
    padding: 10px 16px;
    border-bottom: 1px solid #e8e8e8;
    flex-shrink: 0;
    background: #f7f9ff;
}

.atg-summary-count {
    font-size: 12px;
    color: #555;
    margin-bottom: 4px;
}

.atg-summary-count strong {
    color: #1a1a1a;
    font-weight: 600;
}

.atg-summary-names {
    font-size: 12px;
    color: #333;
    font-style: italic;
    word-break: break-all;
    line-height: 1.5;
}

body.dark-mode .atg-domain-summary {
    background: #16161e;
    border-bottom-color: #2a2a3a;
}

body.dark-mode .atg-summary-count {
    color: #888;
}

body.dark-mode .atg-summary-count strong {
    color: #e0e0e0;
}

body.dark-mode .atg-summary-names {
    color: #aaa;
}

/* =========================================================================
   Add To Group sidebar panel
   Inherits all cp-* styles. Only additions needed:
   ========================================================================= */

#atg-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 320px;
    height: 100vh;
    z-index: 1101;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    background: #ffffff;
    border-left: 1px solid #d0d0d0;
    box-shadow: none;
    color: #1a1a1a;
}

#atg-sidebar.cp-open {
    transform: translateX(0);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.12);
}

#atg-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 1100;
    opacity: 0;
    transition: opacity 0.25s ease;
}

#atg-overlay.cp-open {
    display: block;
    opacity: 1;
}

/* Category icon in Add To Group list */
.atg-cat-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    object-fit: contain;
}

.atg-cat-icon-placeholder {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    display: inline-block;
}

/* Empty state message */
.atg-empty {
    padding: 16px;
    font-size: 13px;
    color: #888;
    text-align: center;
    list-style: none;
}

/* =========================================================================
   Dark mode for atg panel
   ========================================================================= */

body.dark-mode #atg-sidebar {
    background: #1e1e2e;
    border-left-color: #2e2e3e;
    box-shadow: none;
    color: #e0e0e0;
}

body.dark-mode #atg-sidebar.cp-open {
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.45);
}

body.dark-mode #atg-overlay {
    background: rgba(0, 0, 0, 0.55);
}

body.dark-mode .atg-empty {
    color: #555;
}

#atg-sidebar .cp-col-label {
    color: #262626;
}

body.dark-mode #atg-sidebar .cp-col-label {
    color: #e0e0e0;
}

#atg-sidebar .cp-item:not(.cp-visible) {
    opacity: 1;
}