/* ============================================
   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;
}

/* Cell focus - light blue background matching hover state */
.excel-table input:focus {
    background: #f0f9ff !important;
    box-shadow: inset 0 0 0 2px #93c5fd !important;
    position: relative;
    z-index: 2;
}

.excel-table td.selected-cell {
    box-shadow: inset 0 0 0 2px #93c5fd !important;
    background: #f0f9ff !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 focused cell */
[data-theme="light"] .excel-table input:focus {
    background: #f0f9ff !important;
    box-shadow: inset 0 0 0 2px #93c5fd !important;
}

[data-theme="light"] .excel-table td.selected-cell {
    background: #f0f9ff !important;
    box-shadow: inset 0 0 0 2px #93c5fd !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)
   ============================================ */

.color-picker-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
}

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

.color-picker-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    width: 440px;
    max-width: 95vw;
    animation: fadeIn 0.2s ease;
}

.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;
}

.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 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.7rem;
    color: var(--text-muted);
    padding: 0.35rem 0.6rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.live-sync-indicator .sync-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-green);
    animation: pulse 2s infinite;
}

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

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

.live-sync-indicator .sync-status {
    font-weight: 500;
}

/* 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;
}

/* 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;
}
