/* ============================================
   ZOOM CONTROLS
   ============================================ */

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    background: var(--bg-tertiary);
    padding: 0.2rem 0.4rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.zoom-controls .zoom-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: all 0.15s;
}

.zoom-controls .zoom-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.zoom-controls .zoom-input {
    width: 48px;
    height: 22px;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.7rem;
    font-weight: 600;
    text-align: center;
    padding: 0 2px;
    -moz-appearance: textfield;
}

.zoom-controls .zoom-input::-webkit-outer-spin-button,
.zoom-controls .zoom-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.zoom-controls .zoom-input:focus {
    outline: 1px solid var(--accent-orange);
    border-color: var(--accent-orange);
}

.zoom-controls .zoom-pct {
    font-size: 0.65rem;
    color: var(--text-secondary);
    font-weight: 600;
    margin-left: -2px;
}

/* ============================================
   ENHANCED FOCUS COLORS - LIGHTER SELECTION
   ============================================ */

/* Allow text selection in inputs */
.excel-table input {
    user-select: text !important;
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
}

/* Row selection - same light blue as hover for consistency */
.excel-table tbody tr.selected td {
    background: #f0f9ff !important; /* Same very light blue as hover */
}

/* Row number column when selected - same as hover */
.excel-table tbody tr.selected td:first-child {
    background: #bae6fd !important; /* Same light blue as hover */
    color: #1e293b !important;
}

/* Keep focused cell light blue even in selected row */
.excel-table tbody tr.selected td.selected-cell,
.excel-table tbody tr.selected td:has(input:focus) {
    background: #f0f9ff !important;
}

/* Inputs in selected rows keep dark text */
.excel-table tbody tr.selected td input {
    color: #1e293b !important;
}

/* Individual cell selection (Ctrl+Click) - distinct visual indicator */
.excel-table tbody tr td.cell-selected {
    background: #dbeafe !important; /* Slightly darker blue than hover for distinction */
    box-shadow: inset 0 0 0 2px #3b82f6 !important; /* Blue border to clearly indicate selection */
    position: relative;
    z-index: 1;
}

.excel-table tbody tr td.cell-selected input {
    color: #1e293b !important;
    background: transparent !important;
}

/* Hover state for rows - bright background for readability */
.excel-table tbody tr:hover td {
    background: #f0f9ff !important; /* Very light blue - excellent contrast */
}

.excel-table tbody tr:hover td:first-child {
    background: #bae6fd !important; /* Light blue for row numbers */
    color: #1e293b !important;
}

/* Selected row + hover - same light blue as regular hover */
.excel-table tbody tr.selected:hover td {
    background: #f0f9ff !important; /* Same very light blue as hover */
}

.excel-table tbody tr.selected:hover td:first-child {
    background: #bae6fd !important; /* Same light blue as regular row number hover */
    color: #1e293b !important;
}

/* Ensure text remains dark and visible on hover */
.excel-table tbody tr:hover td input {
    color: #1e293b !important; /* Dark text for maximum contrast */
}

/* Column selection highlight - enhanced visibility */
.excel-table th.col-selected {
    background: linear-gradient(180deg, #60a5fa 0%, #3b82f6 100%) !important;
    color: white !important;
    box-shadow: 0 0 0 2px #3b82f6;
    position: relative;
    z-index: 15;
}

.excel-table td.col-selected {
    background: #dbeafe !important; /* Light blue 100 - improved contrast */
    border-left: 2px solid #60a5fa !important;
    border-right: 2px solid #60a5fa !important;
}

/* First and last cell in column selection get top/bottom borders */
.excel-table tbody tr:first-child td.col-selected {
    border-top: 2px solid #60a5fa !important;
}

.excel-table tbody tr:last-child td.col-selected {
    border-bottom: 2px solid #60a5fa !important;
}

/* Column selected cells on hover - brighter highlight */
.excel-table td.col-selected:hover {
    background: #bfdbfe !important; /* Sky blue 200 - brighter on hover */
}

/* Multiple column selection indicator */
.excel-table th.col-selected::after {
    content: '✓';
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 0.7rem;
    background: white;
    color: #3b82f6;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

/* Multi-select drag indicator */
.excel-table tbody tr.multi-drag-source {
    opacity: 0.6;
    outline: 2px dashed #60a5fa;
}

.excel-table tbody tr.drag-target-above {
    border-top: 3px solid #f97316 !important;
}

.excel-table tbody tr.drag-target-below {
    border-bottom: 3px solid #f97316 !important;
}

/* ============================================
   LIGHT THEME - ROW & COLUMN SELECTION OVERRIDES
   ============================================ */

/* Light theme hover state */
[data-theme="light"] .excel-table tbody tr:hover td {
    background: #f0f9ff !important;
}

[data-theme="light"] .excel-table tbody tr:hover td:first-child {
    background: #bae6fd !important;
    color: #1e293b !important;
}

/* Light theme selected row - same light blue as hover */
[data-theme="light"] .excel-table tbody tr.selected td {
    background: #f0f9ff !important; /* Same very light blue as hover */
}

[data-theme="light"] .excel-table tbody tr.selected td:first-child {
    background: #bae6fd !important; /* Same light blue as hover */
    color: #1e3a5f !important;
}

/* Light theme - keep focused cell light blue in selected row */
[data-theme="light"] .excel-table tbody tr.selected td.selected-cell,
[data-theme="light"] .excel-table tbody tr.selected td:has(input:focus) {
    background: #f0f9ff !important;
}

/* Light theme individual cell selection */
[data-theme="light"] .excel-table tbody tr td.cell-selected {
    background: #dbeafe !important;
    box-shadow: inset 0 0 0 2px #3b82f6 !important;
}

[data-theme="light"] .excel-table tbody tr td.cell-selected input {
    color: #1e293b !important;
    background: transparent !important;
}

/* Light theme selected row + hover - same light blue as regular hover */
[data-theme="light"] .excel-table tbody tr.selected:hover td {
    background: #f0f9ff !important;
}

[data-theme="light"] .excel-table tbody tr.selected:hover td:first-child {
    background: #bae6fd !important;
    color: #1e293b !important;
}

/* Light theme column selection */
[data-theme="light"] .excel-table th.col-selected {
    background: linear-gradient(180deg, #475569 0%, #334155 100%) !important;
    color: white !important;
    box-shadow: 0 0 0 2px #475569 !important;
}

[data-theme="light"] .excel-table td.col-selected {
    background: rgba(71, 85, 105, 0.1) !important;
    border-left: 2px solid #475569 !important;
    border-right: 2px solid #475569 !important;
}

[data-theme="light"] .excel-table tbody tr:first-child td.col-selected {
    border-top: 2px solid #475569 !important;
}

[data-theme="light"] .excel-table tbody tr:last-child td.col-selected {
    border-bottom: 2px solid #475569 !important;
}

[data-theme="light"] .excel-table td.col-selected:hover {
    background: rgba(71, 85, 105, 0.15) !important;
}

/* Light theme column selected header checkmark */
[data-theme="light"] .excel-table th.col-selected::after {
    background: white !important;
    color: #475569 !important;
}

/* Light theme inputs in selected rows */
[data-theme="light"] .excel-table tbody tr.selected td input {
    color: #1e293b !important;
}

[data-theme="light"] .excel-table tbody tr:hover td input {
    color: #1e293b !important;
}

/* ============================================
   COLOR PICKER MODAL (Simple - No Gradients)
   ============================================ */

/* Popover behaviour — no full-screen backdrop. The panel is positioned
   in JS underneath the ribbon tool that opened it (see ColorPicker.open).
   The wrapper is a transparent overlay only so click-outside still has a
   sane bubble target; pointer-events pass through everything except the
   panel itself. */
.color-picker-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    z-index: 2000;
    display: none;
    pointer-events: none;
}

.color-picker-modal.visible {
    display: block;
}

.color-picker-panel {
    position: fixed; /* concrete left/top set inline by ColorPicker.open */
    pointer-events: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    width: 360px;
    max-width: 95vw;
    animation: fadeIn 0.15s ease;
}

/* The BG/Text tab switcher is gone — each ribbon tool opens its own
   single-mode popover. Hide the rule defensively in case any cached
   markup renders before the new JS. */
.cp-mode-tabs { display: none !important; }

.color-picker-header {
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.color-picker-header h3 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.9rem;
    white-space: nowrap;
}

.cp-mode-tabs {
    display: flex;
    gap: 2px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    padding: 2px;
}

.cp-tab {
    padding: 0.25rem 0.6rem;
    border: none;
    border-radius: 3px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.cp-tab.active {
    background: var(--accent-orange);
    color: #fff;
}

.color-picker-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    margin-left: auto;
}

.color-picker-close:hover {
    color: var(--text-primary);
}

.color-picker-body {
    padding: 0.75rem 1.25rem;
}

/* Color Sections */
.color-section {
    margin-bottom: 0.75rem;
}

.color-section label {
    display: block;
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.35rem;
}

/* Color Row Grid */
.color-row {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
}

/* Office-style 10-column theme grid: base hue per column, tints/shades
   running down the rows. Tight 2px gaps and small swatches keep the whole
   palette compact enough for a ribbon dropdown. */
.cp-theme-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 2px;
}

.cp-theme-grid .color-swatch {
    width: 100%;
    height: 22px;
    border-radius: 2px;
}

.color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.15s;
    border: 2px solid transparent;
}

.color-swatch:hover {
    transform: scale(1.2);
    border-color: var(--text-primary);
    z-index: 5;
    position: relative;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* Rainbow canvas */
.cp-rainbow {
    width: 100%;
    height: 140px;
    border-radius: 4px;
    cursor: crosshair;
    border: 1px solid var(--border-color);
    display: block;
}

.cp-hue-strip {
    width: 100%;
    height: 16px;
    border-radius: 3px;
    cursor: pointer;
    margin-top: 4px;
    border: 1px solid var(--border-color);
    display: block;
}

/* Preview swatch */
.cp-preview-swatch {
    width: 36px;
    height: 30px;
    border-radius: 4px;
    border: 2px solid var(--border-color);
    flex-shrink: 0;
}

/* Custom Color Section */
.custom-section {
    padding-top: 0.6rem;
    border-top: 1px solid var(--border-color);
    margin-top: 0.5rem;
}

.custom-color-row {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.custom-color-row input[type="text"] {
    width: 80px;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
}

/* Color Picker Footer */
.color-picker-footer {
    padding: 0.5rem 1.25rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.cp-favorites-row {
    display: flex;
    gap: 3px;
    flex: 1;
    justify-content: center;
}

.cp-fav-swatch {
    width: 22px;
    height: 22px;
}

/* Format buttons */
.fmt-btn {
    min-width: 28px;
    justify-content: center;
    font-size: 0.8rem;
}

.fmt-btn strong {
    font-size: 0.85rem;
    font-weight: 800;
}

/* ============================================
   LIVE SYNC INDICATOR & USER AVATARS
   ============================================ */

/* Live Sync Indicator — "Live B" minimal-breath design.
   Chip-less: a small breathing dot + uppercase label sit directly in the
   nav. When connected users are present, a thin divider and an avatar
   stack are rendered beside it via the existing .users-online-container. */
.live-sync-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    /* The top-nav is dark in both themes (gradient in dark, Harbor Blue
       #0a5989 in light), so we use a light text colour regardless of
       theme — same scale as .nav-link's resolved colour. */
    color: rgba(255, 255, 255, 0.78);
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
}

.live-sync-indicator .sync-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-green);
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55);
    animation: liveBreath 1.8s ease-in-out infinite;
}

.live-sync-indicator.syncing .sync-dot {
    background: var(--accent-yellow);
    animation-name: liveBreathYellow;
}

.live-sync-indicator.offline .sync-dot {
    background: var(--accent-red);
    box-shadow: none;
    animation: none;
}

.live-sync-indicator .sync-status {
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

/* Light-theme dot ripple uses the muted Harbor-Blue green so the breath
   reads against the brighter background. */
[data-theme="light"] .live-sync-indicator .sync-dot {
    animation-name: liveBreathLight;
}

@keyframes liveBreath {
    0%, 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55); }
    50%      { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
}
@keyframes liveBreathLight {
    0%, 100% { box-shadow: 0 0 0 0 rgba(44, 140, 98, 0.55); }
    50%      { box-shadow: 0 0 0 6px rgba(44, 140, 98, 0); }
}
@keyframes liveBreathYellow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(234, 179, 8, 0.55); }
    50%      { box-shadow: 0 0 0 6px rgba(234, 179, 8, 0); }
}

/* User Avatars Container */
.users-online-container {
    display: flex;
    align-items: center;
    margin-left: 0.5rem;
    padding-left: 0.75rem;
    border-left: 1px solid var(--border-color);
    position: relative;
}

.users-avatars {
    display: flex;
    align-items: center;
}

.user-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    color: white;
    font-weight: 600;
    margin-left: -8px;
    border: 2px solid var(--bg-secondary);
    cursor: pointer;
    transition: transform 0.15s, z-index 0.15s;
    position: relative;
    text-transform: uppercase;
}

.user-avatar:first-child {
    margin-left: 0;
}

.user-avatar:hover {
    transform: scale(1.15);
    z-index: 10;
}

.user-avatar.you {
    border-color: var(--accent-green);
}

.user-avatar.more-users {
    background: #4b5563 !important;
    font-size: 0.6rem;
    cursor: pointer;
}

/* User Tooltip */
.user-avatar .avatar-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.6rem;
    white-space: nowrap;
    font-size: 0.65rem;
    color: var(--text-primary);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s, visibility 0.15s;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.user-avatar .avatar-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--border-color);
}

.user-avatar:hover .avatar-tooltip {
    opacity: 1;
    visibility: visible;
}

/* More Users Dropdown */
.more-users-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.5rem 0;
    min-width: 180px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s, visibility 0.15s;
    z-index: 100;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.more-users-dropdown.visible {
    opacity: 1;
    visibility: visible;
}

.more-users-dropdown .dropdown-header {
    padding: 0.4rem 0.75rem;
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0.25rem;
}

.more-users-dropdown .user-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    font-size: 0.7rem;
    color: var(--text-primary);
}

.more-users-dropdown .user-item:hover {
    background: var(--bg-hover);
}

.more-users-dropdown .user-item .mini-avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.55rem;
    color: white;
    font-weight: 600;
    text-transform: uppercase;
}

.more-users-dropdown .user-item .user-name {
    flex: 1;
}

.more-users-dropdown .user-item .you-badge {
    font-size: 0.55rem;
    background: var(--accent-green);
    color: white;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
}

/* ============================================
   CELL COMMENTS — Google-Sheets-style corner badge + hover tooltip
   ============================================ */

/* The td needs to be a positioning context for the absolute badge. The
   cells themselves are display:table-cell with no `position` rule, so
   add it here without disturbing other layout.  */
.excel-table td.has-cell-comment {
    position: relative;
}

/* Pure-CSS chat-bubble: rounded square with a small tail in the
   bottom-left, white "!" inside. Background color comes from one of the
   .flag-* modifier classes (or .solved for the green check). No SVG,
   no icon font dependency. */
.cell-comment-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    background: var(--cell-comment-bg, #f97316); /* default = medium */
    color: #ffffff;
    border-radius: 4px 4px 4px 1px;
    pointer-events: auto;
    cursor: help;
    z-index: 3;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: 'Inter', system-ui, sans-serif;
    font-weight: 800;
    font-size: 10.5px;
    line-height: 1;
    text-align: center;
    user-select: none;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.25));
    transition: transform 0.12s ease;
}

.cell-comment-badge:hover {
    transform: scale(1.15);
}

/* Severity flag colors. Single CSS variable drives both the badge fill
   and its tail so they stay in sync. */
.cell-comment-badge.flag-low    { --cell-comment-bg: #3b82f6; background: #3b82f6; }
.cell-comment-badge.flag-medium { --cell-comment-bg: #f97316; background: #f97316; }
.cell-comment-badge.flag-high   { --cell-comment-bg: #dc2626; background: #dc2626; }
/* Solved overrides the flag color with green so a resolved item is
   visibly distinct from an open one of any severity. The check glyph
   is set in JS (textContent = '✓'). */
.cell-comment-badge.solved      { --cell-comment-bg: #22c55e; background: #22c55e; }

/* Tail of the chat bubble — same color as the bubble via the variable. */
.cell-comment-badge::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 1px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 4px 4px 0 0;
    border-color: var(--cell-comment-bg, #f97316) transparent transparent transparent;
}

/* Invisible hover surface so the tooltip stays open while the cursor
   is moving from the badge into the floating tooltip portal. */
.cell-comment-badge::before {
    content: '';
    position: absolute;
    top: -4px;
    right: -4px;
    width: 28px;
    height: 28px;
}

/* The original CSS-only `.cell-comment-tooltip` lived inside the badge
   and was clipped by .excel-scroll's overflow — replaced by the
   body-level singleton `.cell-comment-tooltip-portal`. The shared
   typography rules below apply to both legacy and current markup so
   future single-comment uses still render readable. */

.cell-comment-tooltip-head {
    font-size: 10.5px;
    color: #9ca3af;
    margin-bottom: 4px;
    letter-spacing: 0.2px;
}

.cell-comment-tooltip-body {
    white-space: pre-wrap;
    word-break: break-word;
}

/* Body-level singleton tooltip — escapes the .excel-scroll overflow.
   The original CSS-only tooltip lived inside the badge, but the table
   wrapper has overflow:auto which clipped it. JS positions this one
   `fixed` near the hovered badge, so it always renders on top. */
.cell-comment-tooltip-portal {
    position: fixed;
    top: 0;
    left: 0;
    min-width: 200px;
    max-width: 320px;
    background: #1f2937;
    color: #f9fafb;
    border-radius: 6px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
    padding: 8px 10px;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 12px;
    line-height: 1.4;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-2px);
    transition: opacity 0.12s, visibility 0.12s, transform 0.12s;
    z-index: 2200;
    pointer-events: auto;
}

.cell-comment-tooltip-portal.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.cell-comment-tooltip-portal .cell-comment-tooltip-head {
    font-size: 10.5px;
    color: #9ca3af;
    margin-bottom: 4px;
    letter-spacing: 0.2px;
}

.cell-comment-tooltip-portal .cell-comment-tooltip-body {
    white-space: pre-wrap;
    word-break: break-word;
}

/* Stack of comment cards inside one tooltip. Each card has its own
   header (meta + chips) and body. A thin divider sits between cards. */
.cct-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.cct-card {
    padding: 4px 0;
}

.cct-card.solved {
    opacity: 0.72;
}

.cct-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.10);
    margin: 4px 0;
}

/* Inline chat-bubble icon used in the tooltip card meta line, before
   the author name. Reuses .cce-flag-icon's shape but adds spacing +
   slight vertical alignment tweaks for the dark tooltip context. */
.cct-flag-icon {
    margin-right: 4px;
    vertical-align: -1px;
}

/* Multi-count badge: when a cell has >1 comments the bubble grows to
   fit the count next to the glyph (e.g. "!3" or "✓2"). */
.cell-comment-badge.multi {
    width: auto;
    min-width: 22px;
    padding: 0 4px;
    font-size: 10px;
    letter-spacing: 0.2px;
}

/* Light-theme pin: the badge text (the "!" glyph plus the count digit on
   multi badges) must stay white on every colored background, because the
   table cell sits on a white sheet in light theme and the badge would
   otherwise pick up the cell's dark inherited color through any rule we
   haven't anticipated. !important on every variant keeps it locked. */
[data-theme="light"] .cell-comment-badge,
[data-theme="light"] .cell-comment-badge.flag-low,
[data-theme="light"] .cell-comment-badge.flag-medium,
[data-theme="light"] .cell-comment-badge.flag-high,
[data-theme="light"] .cell-comment-badge.solved,
[data-theme="light"] .cell-comment-badge.multi {
    color: #ffffff !important;
}

/* Tooltip header: meta text on the left, action chips on the right.
   Google-Sheets-style — a thin divider separates the header from the
   body so the buttons read as part of the title strip, not the comment. */
.cell-comment-tooltip-portal .cct-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 5px;
    margin-bottom: 5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.cell-comment-tooltip-portal .cct-header .cell-comment-tooltip-head {
    /* Reset bottom margin since the header row owns the spacing now. */
    margin-bottom: 0;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cct-actions {
    display: inline-flex;
    gap: 3px;
    flex-shrink: 0;
}

/* Compact icon chips — 22×22 with a single glyph each. Buttons hide
   themselves via inline display:none when an action isn't allowed
   (e.g. Clear is hidden for non-author / non-super_admin; Solve for
   already-solved comments). */
.cct-btn {
    background: rgba(255, 255, 255, 0.10);
    color: #f9fafb;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 4px;
    padding: 0;
    width: 22px;
    height: 22px;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s, border-color 0.12s, transform 0.1s;
}

.cct-btn:hover {
    background: rgba(255, 255, 255, 0.20);
    border-color: rgba(255, 255, 255, 0.32);
    transform: translateY(-1px);
}

.cct-solve { color: #86efac; background: rgba(34, 197, 94, 0.16); border-color: rgba(34, 197, 94, 0.34); }
.cct-solve:hover { background: rgba(34, 197, 94, 0.32); border-color: rgba(34, 197, 94, 0.55); }

.cct-clear { color: #fca5a5; background: rgba(239, 68, 68, 0.16); border-color: rgba(239, 68, 68, 0.34); font-size: 16px; }
.cct-clear:hover { background: rgba(239, 68, 68, 0.30); border-color: rgba(239, 68, 68, 0.55); }

.cct-edit { color: #f9fafb; }

/* Inline confirm popover floating above the clicked Solve / Clear chip.
   Lives inside .cct-header so JS can position it relative to the
   tooltip's own bounds (tip and pop share an offset parent). */
.cell-comment-tooltip-portal .cct-confirm-pop {
    position: absolute;
    background: #111827;
    color: #f9fafb;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 6px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
    padding: 5px 6px 5px 9px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    white-space: nowrap;
    z-index: 5;
}

.cct-confirm-pop[hidden] { display: none; }

.cct-confirm-text {
    font-weight: 600;
}

.cct-confirm-yes,
.cct-confirm-no {
    background: rgba(255, 255, 255, 0.12);
    color: #f9fafb;
    border: 1px solid rgba(255, 255, 255, 0.20);
    border-radius: 4px;
    padding: 1px 8px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    line-height: 1.3;
}

.cct-confirm-yes { background: rgba(34, 197, 94, 0.30); border-color: rgba(34, 197, 94, 0.55); color: #ecfdf5; }
.cct-confirm-yes:hover { background: rgba(34, 197, 94, 0.50); }

.cct-confirm-no { background: rgba(239, 68, 68, 0.22); border-color: rgba(239, 68, 68, 0.50); color: #fef2f2; }
.cct-confirm-no:hover { background: rgba(239, 68, 68, 0.42); }

/* ============================================
   CELL COMMENT EDITOR — dropdown popover for add/edit
   ============================================ */

/* The wrapper exists only to scope the panel; it must not paint any
   background of its own. In light theme a stray rule was filling it
   white and creating a full-screen overlay — explicit values + a
   defensive transparent fill keep it click-through and invisible in
   every theme. */
.cell-comment-editor-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2100;
    display: none;
    pointer-events: none;
    background: transparent !important;
    box-shadow: none !important;
    border: 0 !important;
}

.cell-comment-editor-overlay.visible {
    display: block;
}

.cell-comment-editor-panel {
    position: fixed; /* concrete left/top set inline by CellCommentEditor.open */
    pointer-events: auto;
    background: var(--bg-secondary, #fff);
    color: var(--text-primary, #111827);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 10px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.32);
    width: 320px;
    max-width: 95vw;
    padding: 10px 12px;
    animation: fadeIn 0.12s ease;
}

.cce-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.cce-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Flag picker — inline LOW / MED / HIGH radios with chat-bubble icons.
   Three labels side-by-side; clicking the label or its hidden radio
   selects the flag. The native radio carries state for keyboard A11y. */
.cce-flag-radios {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    margin-right: 8px;
}

.cce-flag-radio {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px 2px 4px;
    border: 1px solid var(--border-color, #d1d5db);
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.4px;
    color: var(--text-muted, #6b7280);
    cursor: pointer;
    user-select: none;
    transition: border-color 0.12s, background 0.12s, color 0.12s;
}

.cce-flag-radio:hover {
    border-color: var(--text-muted, #6b7280);
}

.cce-flag-radio.selected {
    color: var(--text-primary, #111827);
}

.cce-flag-radio[data-flag="low"].selected    { border-color: #3b82f6; background: rgba(59, 130, 246, 0.10); }
.cce-flag-radio[data-flag="medium"].selected { border-color: #f97316; background: rgba(249, 115, 22, 0.10); }
.cce-flag-radio[data-flag="high"].selected   { border-color: #dc2626; background: rgba(220, 38, 38, 0.10); }

/* Hide the native radio dot but keep it in the layout for A11y +
   keyboard focus. The label + chat icon are the visible affordance. */
.cce-flag-radio input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    width: 0;
    height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    outline: none;
    pointer-events: none;
    position: absolute;
}

.cce-flag-radio-label {
    line-height: 1;
}

/* Mini chat-bubble preview — the same shape the cell badge will show
   when the comment is saved with this flag. Tail color matches the bg
   of the bubble via per-flag rules below. */
.cce-flag-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 3px 3px 3px 1px;
    color: #fff;
    font-weight: 800;
    font-size: 9.5px;
    line-height: 1;
    flex-shrink: 0;
}

.cce-flag-icon::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 1px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 3px 3px 0 0;
    border-color: currentColor transparent transparent transparent;
}

/* Per-flag fill — tail uses currentColor (set on the icon itself)
   so the bubble and tail always match. */
.cce-flag-icon.flag-low    { background: #3b82f6; color-scheme: light; }
.cce-flag-icon.flag-low::after    { border-top-color: #3b82f6; }
.cce-flag-icon.flag-medium { background: #f97316; }
.cce-flag-icon.flag-medium::after { border-top-color: #f97316; }
.cce-flag-icon.flag-high   { background: #dc2626; }
.cce-flag-icon.flag-high::after   { border-top-color: #dc2626; }

/* The "!" glyph inside the icon needs to render white over the colored
   background, but the bubble's color shorthand on .flag-* sets text
   color implicitly. Force white so the glyph stays readable. */
.cce-flag-icon { color: #fff !important; }

.cce-close {
    background: none;
    border: none;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text-muted, #6b7280);
    padding: 2px 6px;
}

.cce-close:hover {
    color: var(--text-primary, #111827);
}

.cce-text {
    width: 100%;
    min-height: 84px;
    resize: vertical;
    font-family: inherit;
    font-size: 12.5px;
    line-height: 1.4;
    padding: 8px 10px;
    border: 1px solid var(--border-color, #d1d5db);
    border-radius: 6px;
    background: var(--bg-tertiary, #f9fafb);
    color: var(--text-primary, #111827);
    outline: none;
    box-sizing: border-box;
}

.cce-text:focus {
    border-color: var(--accent-orange, #f97316);
    box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.18);
}

.cce-meta {
    margin-top: 6px;
    font-size: 0.65rem;
    color: var(--text-muted, #9ca3af);
    letter-spacing: 0.2px;
}

.cce-footer {
    margin-top: 10px;
    display: flex;
    justify-content: flex-end;
    gap: 6px;
}

/* Brief flash applied by NotificationCenter.viewCellComment so the user
   can spot which cell a pending-comment notification is anchored to. */
@keyframes cellCommentFlash {
    0%   { box-shadow: inset 0 0 0 3px rgba(249,115,22,0.85); }
    100% { box-shadow: inset 0 0 0 3px rgba(249,115,22,0); }
}

.cell-comment-flash {
    animation: cellCommentFlash 1.6s ease-out;
}

/* Cell-comment notification card variant — slightly distinct accent so
   it's visually parsable next to unload / service tasks. */
.notif-item.cell-comment-task {
    border-left: 3px solid var(--accent-orange, #f97316);
}

/* Ribbon Favorites Display - Main display in ribbon */
.ribbon-favorites {
    display: flex;
    gap: 0.25rem;
    margin-left: 0.3rem;
    padding: 0.15rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-sm);
}

.ribbon-favorite-color {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    border: 2px solid rgba(255,255,255,0.2);
    transition: all 0.15s;
    position: relative;
}

.ribbon-favorite-color:hover {
    transform: scale(1.15);
    border-color: white;
    z-index: 5;
}

.ribbon-favorite-color.empty {
    border-style: dashed;
    border-color: rgba(255,255,255,0.3);
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: rgba(255,255,255,0.4);
}

.ribbon-favorite-color.empty:hover {
    border-color: var(--accent-orange);
    color: var(--accent-orange);
}

.ribbon-favorite-color .remove-fav {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 14px;
    height: 14px;
    background: var(--accent-red);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 0.55rem;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.ribbon-favorite-color:hover .remove-fav {
    display: flex;
}

/* ============================================
   ZOOMED TABLE STYLES
   ============================================ */

.excel-table.zoomed {
    transform-origin: top left;
}

/* ============================================
   CONNECTED USERS — green dot + status row
   ============================================
   Augments the existing .user-avatar / .user-item styles with a small
   "currently editing" indicator (Google-Sheets-style green dot in the
   bottom-right of the avatar) and a status string in the dropdown row. */

.user-avatar .user-editing-dot {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    border: 2px solid var(--bg-secondary);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
}

.more-users-dropdown .user-item .user-status {
    margin-left: auto;
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: none;
    letter-spacing: 0;
    white-space: nowrap;
}

.more-users-dropdown .user-item.user-item-empty {
    color: var(--text-muted);
    font-style: italic;
    justify-content: center;
}
