/* ============================================================
   Groups Panel — Inline list mounted into the Groups tab host
   (Legacy `.groups-panel-overlay` full-viewport overlay removed.)
   ============================================================ */

/* ---- Inline (tab) Mount — used by the Groups tab host ---- */
.groups-tab-host {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: 0;
    background: var(--bg-color, transparent);
    overflow: hidden;
}

/* Ensure the host actually shows when its parent tab is active */
#tab-content-groups {
    display: none;
    flex-direction: column;
    overflow: hidden;
}
#tab-content-groups.active {
    display: flex;
}

/* In inline mode the whole .gp-header is redundant — the tab label already
   says "Groups", and there's no overlay to dismiss. Hide the entire header. */
.groups-tab-host .gp-header {
    display: none;
}

/* Tighten toolbar padding now that the header is gone */
.groups-tab-host .gp-toolbar {
    padding-top: 14px;
}

/* Make the list region flex-fill the remaining tab height */
.groups-tab-host #gpList,
.groups-tab-host .gp-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* ---- Header ---- */
.gp-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 24px 28px 16px;
    border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
    flex-shrink: 0;
}

.gp-header-left h2 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary, #e4e4e7);
    margin: 0;
}

.gp-header-left p {
    font-size: 0.85rem;
    color: var(--text-muted, #71717a);
    margin: 6px 0 0;
}

.gp-close-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-hover, #1a1a1d);
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
    color: var(--text-secondary, #a1a1aa);
    font-size: 1rem;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.gp-close-btn:hover {
    background: var(--surface-active, #27272a);
    color: var(--text-primary, #e4e4e7);
}

/* ---- Toolbar ---- */
.gp-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 28px;
    flex-shrink: 0;
}

.gp-search-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.gp-search-wrapper i {
    position: absolute;
    left: 14px;
    color: var(--text-muted, #71717a);
    font-size: 0.85rem;
    pointer-events: none;
}

.gp-search-input {
    width: 100%;
    padding: 10px 12px 10px 38px;
    background: var(--input-bg, #18181b);
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
    border-radius: var(--radius-md, 8px);
    color: var(--text-primary, #e4e4e7);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
    min-height: 42px;
}

.gp-search-input::placeholder {
    color: var(--text-muted, #71717a);
}

.gp-search-input:focus {
    border-color: var(--accent, #3bf692);
}

.gp-search-clear {
    position: absolute;
    right: 8px;
    width: 28px;
    height: 28px;
    display: none;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-muted, #71717a);
    cursor: pointer;
    border-radius: 50%;
    font-size: 0.8rem;
}

.gp-search-clear.visible {
    display: flex;
}

.gp-search-clear:hover {
    color: var(--text-primary);
    background: var(--surface-hover);
}

.gp-sort-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.gp-sort-label {
    font-size: 0.8rem;
    color: var(--text-muted, #71717a);
    white-space: nowrap;
}

.gp-sort-select {
    padding: 8px 12px;
    background: var(--input-bg, #18181b);
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
    border-radius: var(--radius-md, 8px);
    color: var(--text-primary, #e4e4e7);
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
    min-height: 42px;
}

.gp-new-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: linear-gradient(135deg, var(--accent, #3bf692) 0%, #60a5fa 60%, #2563eb 100%);
    border: 1px solid rgba(59, 246, 146, 0.2);
    border-radius: var(--radius-md, 8px);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    flex-shrink: 0;
    min-height: 42px;
}

.gp-new-btn:hover {
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    border-color: rgba(59, 246, 146, 0.35);
}

.gp-new-btn:active {
    transform: scale(0.98);
}

/* ---- List Container ---- */
.gp-list {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 28px;
}

/* ---- Group Row ---- */
.gp-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
    cursor: pointer;
    transition: background 0.15s;
    border-radius: 0;
    position: relative;
}

.gp-row:hover {
    background: var(--surface-hover, rgba(255, 255, 255, 0.03));
    margin: 0 -12px;
    padding-left: 12px;
    padding-right: 12px;
    border-radius: var(--radius-md, 8px);
}

.gp-row:last-child {
    border-bottom: none;
}

.gp-row-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.gp-row-info {
    flex: 1;
    min-width: 0;
}

.gp-row-name {
    display: block;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary, #e4e4e7);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gp-row-desc {
    display: block;
    font-size: 0.78rem;
    color: var(--text-muted, #71717a);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gp-row-count {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    min-width: 50px;
}

.gp-row-count-num {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary, #e4e4e7);
}

.gp-row-count-label {
    font-size: 0.65rem;
    color: var(--text-muted, #71717a);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.gp-row-time {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    flex-shrink: 0;
    min-width: 80px;
}

.gp-row-time-val {
    font-size: 0.82rem;
    color: var(--text-secondary, #a1a1aa);
}

.gp-row-time-label {
    font-size: 0.65rem;
    color: var(--text-muted, #71717a);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.gp-row-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(124, 58, 237, 0.12);
    border: 1px solid rgba(124, 58, 237, 0.2);
    border-radius: var(--radius-md, 8px);
    color: #a78bfa;
    font-size: 1.15rem;
    flex-shrink: 0;
    cursor: pointer;
    transition: all 0.15s ease;
}

.gp-row-icon:hover {
    background: rgba(124, 58, 237, 0.22);
    border-color: rgba(124, 58, 237, 0.35);
    color: #c4b5fd;
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.2);
}

/* Expand/collapse chevron indicator */
.gp-row-chevron {
    font-size: 0.7rem;
    color: var(--text-muted, #71717a);
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.gp-row.expanded .gp-row-chevron {
    transform: rotate(180deg);
    color: var(--text-secondary, #a1a1aa);
}

/* ---- Expanded Row Actions ---- */
.gp-row-actions {
    display: none;
    width: 100%;
    padding: 10px 0 4px 26px;
    gap: 8px;
    flex-wrap: wrap;
}

.gp-row.expanded .gp-row-actions {
    display: flex;
}

.gp-row.expanded {
    flex-wrap: wrap;
    background: var(--surface-hover, rgba(255, 255, 255, 0.03));
    margin: 0 -12px;
    padding: 16px 12px;
    border-radius: var(--radius-md, 8px);
}

/* Base action button */
.gp-action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-md, 8px);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

/* Purple gradient action buttons */
.gp-action-gradient {
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 50%, #5b21b6 100%);
    border: 1px solid rgba(124, 58, 237, 0.3);
    color: #fff;
    box-shadow: 0 2px 6px rgba(91, 33, 182, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.gp-action-gradient:hover {
    box-shadow: 0 4px 10px rgba(91, 33, 182, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.18);
    border-color: rgba(124, 58, 237, 0.5);
}

.gp-action-gradient:active {
    transform: scale(0.97);
}

/* Danger/delete action button */
.gp-action-danger {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    border: 1px solid rgba(220, 38, 38, 0.3);
    color: #fff;
    box-shadow: 0 2px 6px rgba(185, 28, 28, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.gp-action-danger:hover {
    box-shadow: 0 4px 10px rgba(185, 28, 28, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    border-color: rgba(220, 38, 38, 0.5);
}

.gp-action-danger:active {
    transform: scale(0.97);
}

/* Color picker dots */
.gp-color-picker {
    display: none;
    gap: 6px;
    padding: 8px 0 0 26px;
    flex-wrap: wrap;
    width: 100%;
}

.gp-row.color-picking .gp-color-picker {
    display: flex;
}

.gp-color-dot {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
}

.gp-color-dot:hover {
    transform: scale(1.2);
}

.gp-color-dot.active {
    border-color: #fff;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
}

/* ---- Footer ---- */
.gp-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 28px;
    border-top: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
    flex-shrink: 0;
}

.gp-footer-count {
    font-size: 0.75rem;
    color: var(--text-muted, #71717a);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.gp-pagination {
    display: flex;
    align-items: center;
    gap: 4px;
}

.gp-page-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
    border-radius: var(--radius-sm, 6px);
    color: var(--text-secondary, #a1a1aa);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s;
}

.gp-page-btn:hover:not(:disabled) {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.gp-page-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.gp-page-btn.active {
    background: var(--accent, #3bf692);
    color: #000;
    border-color: var(--accent);
    font-weight: 600;
}

/* ---- Empty State ---- */
.gp-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 60px 28px;
    text-align: center;
}

.gp-empty-icon {
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-hover, rgba(255, 255, 255, 0.04));
    border-radius: 50%;
    margin-bottom: 20px;
    font-size: 2rem;
    color: var(--text-muted, #71717a);
}

.gp-empty h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary, #e4e4e7);
    margin: 0 0 8px;
}

.gp-empty p {
    font-size: 0.9rem;
    color: var(--text-muted, #71717a);
    margin: 0 0 24px;
    max-width: 320px;
}

.gp-empty-cta {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--accent, #3bf692) 0%, #60a5fa 60%, #2563eb 100%);
    border: 1px solid rgba(59, 246, 146, 0.2);
    border-radius: var(--radius-md, 8px);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    transition: all 0.2s;
}

.gp-empty-cta:hover {
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* ---- Mobile ---- */
@media (max-width: 768px) {
    .gp-header {
        padding: 18px 16px 14px;
    }

    .gp-toolbar {
        flex-wrap: wrap;
        padding: 10px 16px;
        gap: 8px;
    }

    .gp-search-wrapper {
        width: 100%;
        order: 1;
    }

    .gp-sort-wrapper {
        order: 2;
        flex: 1;
    }

    .gp-new-btn {
        order: 3;
        padding: 10px 14px;
        font-size: 0.85rem;
    }

    .gp-list {
        padding: 0 16px;
    }

    .gp-row {
        gap: 10px;
        padding: 14px 0;
    }

    .gp-row-time {
        display: none;
    }

    .gp-footer {
        padding: 10px 16px;
    }

    .gp-row-actions {
        padding-left: 22px;
    }
}

/* ============================================================
   LIGHT THEME OVERRIDES
   ============================================================ */
html.light-theme .groups-tab-host {
    background: var(--bg-color, #f8f2ed);
}

html.light-theme .gp-close-btn {
    background: var(--surface-hover, #efe7df);
    border-color: var(--border, rgba(0, 0, 0, 0.08));
}

html.light-theme .gp-search-input {
    background: var(--input-bg, #f3ece5);
    border-color: var(--border, rgba(0, 0, 0, 0.1));
}

html.light-theme .gp-sort-select {
    background: var(--input-bg, #f3ece5);
    border-color: var(--border, rgba(0, 0, 0, 0.1));
}

html.light-theme .gp-row:hover,
html.light-theme .gp-row.expanded {
    background: var(--surface-hover, #efe7df);
}

html.light-theme .gp-row-icon {
    background: rgba(124, 58, 237, 0.08);
    border-color: rgba(124, 58, 237, 0.15);
    color: #7c3aed;
}

html.light-theme .gp-row-icon:hover {
    background: rgba(124, 58, 237, 0.15);
    border-color: rgba(124, 58, 237, 0.3);
}

html.light-theme .gp-color-dot.active {
    border-color: #333;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.15);
}

html.light-theme .gp-page-btn.active {
    background: var(--accent, #1aab8a);
    color: #fff;
    border-color: var(--accent);
}

html.light-theme .gp-empty-icon {
    background: var(--surface-hover, #efe7df);
}
