/* Quick Edit Styles */
.quick-edit-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: white;
    z-index: 10000;
}

.quick-edit-screen {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.quick-edit-header {
    padding: 8px 12px;
    background: #2d3748;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

@media (max-width: 480px) {
    .quick-edit-header {
        padding: 1.5vw 2vw !important;
    }

    .quick-edit-header h2 {
        font-size: 3.5vw !important;
    }

    .quick-edit-title-wrapper {
        gap: 1.5vw !important;
    }

    .quick-edit-subtitle {
        font-size: 2.5vw !important;
        margin-top: 0.5vw !important;
    }

    .quick-edit-header-left {
        gap: 2vw !important;
    }

    .quick-edit-header-right {
        gap: 1.5vw !important;
    }

    .quick-edit-icon-btn {
        width: 7.5vw !important;
        height: 7.5vw !important;
        min-width: 30px !important;
        min-height: 30px !important;
        padding: 1.5vw !important;
    }

    .quick-edit-icon-btn img {
        width: 4.5vw !important;
        height: 4.5vw !important;
        min-width: 18px !important;
        min-height: 18px !important;
    }

    .quick-edit-icon-btn.instruction-btn {
        width: 6vw !important;
        height: 6vw !important;
        min-width: 24px !important;
        min-height: 24px !important;
        padding: 1vw !important;
    }

    .quick-edit-icon-btn.instruction-btn img {
        width: 4vw !important;
        height: 4vw !important;
        min-width: 16px !important;
        min-height: 16px !important;
    }

    .add-columns-btn-header {
        font-size: 3.2vw !important;
    }
}

.quick-edit-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.quick-edit-title-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.quick-edit-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.quick-edit-header h2 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
}

.quick-edit-subtitle {
    display: none;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 400;
    margin-top: 2px;
}

.quick-edit-tabs {
    display: flex;
    gap: 4px;
}

.quick-edit-tab {
    padding: 6px 16px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
    transition: all 0.2s;
}

.quick-edit-tab:hover {
    color: white;
    background: rgba(255, 255, 255, 0.15);
}

.quick-edit-tab.active {
    color: white;
    background: rgba(0, 123, 255, 0.8);
}

.quick-edit-icon-btn {
    width: 36px;
    height: 36px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.quick-edit-icon-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.quick-edit-icon-btn img {
    width: 20px;
    height: 20px;
    filter: brightness(0) invert(1);
}

.quick-edit-icon-btn.instruction-btn {
    width: 24px;
    height: 24px;
    min-width: 24px;
    min-height: 24px;
    padding: 4px;
}

.quick-edit-icon-btn.instruction-btn img {
    width: 16px;
    height: 16px;
}

.quick-edit-find-replace-popup {
    position: fixed;
    top: 80px;
    right: 20px;
    width: 420px;
    max-width: calc(100vw - 40px);
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    z-index: 10001;
    display: none;
}

@media (max-width: 570px) {
    .quick-edit-find-replace-popup {
        width: 70vw;
        max-width: 70vw;
        right: 15vw;
        top: 60px;
    }
}

.find-replace-header {
    cursor: move;
}

@media (max-width: 768px) {
    .quick-edit-find-replace-popup {
        max-width: 400px;
    }
}

@media (max-width: 480px) {
    .quick-edit-find-replace-popup {
        width: 70vw !important;
        max-width: 70vw !important;
        right: calc((100vw - 70vw) / 2) !important;
        left: auto !important;
        top: 60px !important;
        box-sizing: border-box !important;
    }

    .find-replace-header {
        padding: 2vw 2.5vw !important;
        font-size: 3vw !important;
        box-sizing: border-box !important;
    }

    .close-find-btn {
        width: 5vw !important;
        height: 5vw !important;
        min-width: 20px !important;
        min-height: 20px !important;
        font-size: 4vw !important;
    }

    .find-replace-inputs {
        padding: 2.5vw !important;
        box-sizing: border-box !important;
    }

    .find-input-row,
    .replace-input-row {
        margin-bottom: 2vw !important;
        gap: 1.5vw !important;
        display: flex !important;
        align-items: center !important;
    }

    .find-input-row input,
    .replace-input-row input {
        padding: 1.5vw 2vw !important;
        font-size: 3vw !important;
        border: 1px solid #ced4da !important;
        border-radius: 4px !important;
        flex: 1 !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }

    .find-nav-buttons {
        gap: 1vw !important;
        display: flex !important;
        flex-shrink: 0 !important;
    }

    .find-nav-buttons button {
        width: 7vw !important;
        height: 7vw !important;
        min-width: 28px !important;
        min-height: 28px !important;
        padding: 1.2vw !important;
        flex-shrink: 0 !important;
    }

    .find-nav-buttons button img {
        width: 3.5vw !important;
        height: 3.5vw !important;
        min-width: 14px !important;
        min-height: 14px !important;
    }

    .replace-buttons {
        gap: 1vw !important;
        display: flex !important;
        flex-shrink: 0 !important;
    }

    .replace-buttons button {
        padding: 1.5vw 2.5vw !important;
        font-size: 2.8vw !important;
        border: none !important;
        border-radius: 4px !important;
        white-space: nowrap !important;
        flex-shrink: 0 !important;
    }

    .find-replace-footer {
        padding: 2vw 2.5vw !important;
        font-size: 2.8vw !important;
        box-sizing: border-box !important;
    }

    .scope-selector {
        gap: 1.5vw !important;
    }

    .scope-selector label {
        font-size: 2.8vw !important;
        white-space: nowrap !important;
    }

    .scope-selector select {
        padding: 1vw 2vw !important;
        font-size: 2.8vw !important;
        border: 1px solid #ced4da !important;
        border-radius: 4px !important;
        box-sizing: border-box !important;
    }

    #quickEditMatchCount {
        font-size: 2.8vw !important;
    }
}

.find-replace-header {
    padding: 10px 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 0.9rem;
    color: #495057;
}

.close-find-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    font-size: 1.5rem;
    line-height: 1;
    color: #6c757d;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.close-find-btn:hover {
    background: #e9ecef;
    color: #495057;
}

.find-replace-inputs {
    padding: 12px 15px;
}

.find-input-row,
.replace-input-row {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.find-input-row input,
.replace-input-row input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 0.9rem;
    font-family: 'Segoe UI', sans-serif;
}

.find-input-row input:focus,
.replace-input-row input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.1);
}

.find-nav-buttons,
.replace-buttons {
    display: flex;
    gap: 4px;
}

.find-nav-buttons button {
    width: 32px;
    height: 32px;
    padding: 6px;
    background: white;
    border: 1px solid #ced4da;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.find-nav-buttons button:hover {
    background: #f8f9fa;
    border-color: #007bff;
}

.find-nav-buttons button img {
    width: 16px;
    height: 16px;
    filter: brightness(0) saturate(100%) invert(30%) sepia(10%) saturate(500%) hue-rotate(180deg);
}

.replace-buttons button {
    padding: 6px 12px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.2s;
    white-space: nowrap;
}

.replace-buttons button:hover {
    background: #0056b3;
}

.find-replace-footer {
    padding: 10px 15px;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
    border-radius: 0 0 8px 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.scope-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #6c757d;
}

.scope-selector label {
    font-weight: 600;
}

.scope-selector select {
    padding: 4px 8px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 0.85rem;
    background: white;
    cursor: pointer;
}

.scope-selector select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#quickEditMatchCount {
    color: #6c757d;
    font-weight: 500;
}

/* Highlight styles for matches */
.find-match-highlight {
    background: #ffeaa7;
    border-radius: 2px;
}

.find-match-current {
    background: #fdcb6e;
    font-weight: 600;
    box-shadow: 0 0 0 2px #e17055;
}

/* Algorithm table specific styles */
.algorithms-table .alg-cell {
    font-family: 'Courier New', Courier, monospace;
}

.algorithms-table .display-name-col {
    font-family: inherit;
    white-space: nowrap;
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--surface);
}

.alg-header {
    font-family: 'Courier New', Courier, monospace;
    font-weight: 600;
}

.display-name-header {
    font-family: inherit;
    white-space: nowrap;
    position: sticky;
    left: 0;
    z-index: 11;
    background: var(--surface2);
}

.add-columns-btn-header {
    color: white;
    font-weight: 600;
    font-size: 16px;
}

/* Mobile responsive */
@media (max-width: 620px) {
    .find-replace-header {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    .find-replace-inputs {
        padding: 10px 12px;
    }

    .find-input-row input,
    .replace-input-row input {
        padding: 5px 8px;
        font-size: 0.85rem;
    }

    .find-nav-buttons button {
        width: 28px;
        height: 28px;
    }

    .replace-buttons button {
        padding: 5px 10px;
        font-size: 0.8rem;
    }

    .find-replace-footer {
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    .scope-selector select {
        font-size: 0.8rem;
        padding: 3px 6px;
    }
}

.find-replace-content {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.find-replace-content input {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    min-width: 180px;
}

.find-replace-buttons {
    display: flex;
    gap: 6px;
}

.find-replace-buttons button {
    padding: 6px 12px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.find-replace-buttons button:hover {
    background: #0056b3;
}

.find-replace-buttons button:last-child {
    background: #6c757d;
}

.find-replace-buttons button:last-child:hover {
    background: #5a6268;
}

.find-replace-info {
    display: flex;
    gap: 12px;
    font-size: 0.85rem;
    color: #666;
}

.quick-edit-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    padding: 0;
}

.quick-edit-content {
    height: 100%;
    overflow-y: auto;
    overflow-x: auto;
}

.quick-edit-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    table-layout: auto;
}

.quick-edit-table thead {
    position: sticky;
    top: 0;
    background: #f8f9fa;
    z-index: 10;
}

.quick-edit-table th {
    padding: 8px 10px;
    text-align: left;
    font-weight: 600;
    color: #495057;
    border-bottom: 2px solid #dee2e6;
}

.quick-edit-table td {
    padding: 6px 10px;
    border-bottom: 1px solid #e9ecef;
    vertical-align: middle;
}

.quick-edit-table td.uneditable {
    background: #f8f9fa;
    color: #6c757d;
    font-weight: 500;
}

.quick-edit-table td.editable {
    cursor: text;
    min-height: 32px;
    transition: background 0.2s;
}

.quick-edit-table td.editable:hover {
    background: #f8f9fa;
}

.quick-edit-table td.editable:focus {
    outline: 2px solid #007bff;
    outline-offset: -2px;
    background: white;
}

.quick-edit-table tr:hover td {
    background: #f8f9fa;
}

.quick-edit-table tr:hover td.editable:hover {
    background: #e9ecef;
}

.quick-edit-footer {
    padding: 20px 30px;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-shrink: 0;
}

.quick-edit-save-btn,
.quick-edit-cancel-btn {
    padding: 12px 32px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.2s;
}

.quick-edit-save-btn {
    background: #28a745;
    color: white;
}

.quick-edit-save-btn:hover {
    background: #218838;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(40, 167, 69, 0.3);
}

.quick-edit-cancel-btn {
    background: #6c757d;
    color: white;
}

.quick-edit-cancel-btn:hover {
    background: #5a6268;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(108, 117, 125, 0.3);
}

/* Tablet adjustments */
@media (max-width: 630px) {
    .quick-edit-tabs {
        display: none !important;
    }

    .quick-edit-subtitle {
        display: block !important;
    }

    .quick-edit-header-left {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 1vw !important;
    }

    .quick-edit-title-wrapper {
        gap: 1.5vw !important;
    }
}

/* Allow horizontal scrolling on narrow screens */
@media (max-width: 550px) {
    #quickEditGeneralTab {
        overflow-x: auto;
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .quick-edit-screen {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
    }

    .quick-edit-header {
        padding: 15px 20px;
    }

    .quick-edit-header h2 {
        font-size: 1.2rem;
    }

    .quick-edit-tabs {
        padding: 0 20px;
    }

    .quick-edit-body {
        padding: 15px 20px;
    }

    .quick-edit-table {
        font-size: 0.8rem;
    }

    .quick-edit-table th,
    .quick-edit-table td {
        padding: 8px;
    }

    .find-replace-content {
        flex-direction: column;
        align-items: stretch;
    }

    .find-replace-content input {
        min-width: 100%;
    }
}

/* ── Quick-edit header icon images ─────────────────────────── */
/* The header is permanently dark (--header-dark-bg), so icon    */
/* images must be white in both light and dark modes.            */
.quick-edit-icon-btn img {
    filter: brightness(0) invert(1);
}

/* ── Dark mode overrides for quick-edit ── */
.quick-edit-fullscreen {
    background: var(--surface);
    color: var(--text-primary);
}

.quick-edit-table thead {
    background: var(--surface2);
}

.quick-edit-table th {
    color: var(--text-secondary);
    border-bottom-color: var(--surface-border);
    background: var(--surface2);
}

.quick-edit-table td {
    border-bottom-color: var(--surface-border);
    color: var(--text-primary);
}

.quick-edit-table td.uneditable {
    background: var(--surface2);
    color: var(--text-secondary);
}

.algorithms-table td.uneditable {
    background: var(--surface2);
}

.quick-edit-table td.editable:hover {
    background: var(--hover-bg);
}

.quick-edit-table td.editable:focus {
    background: var(--surface);
    outline-color: var(--accent);
}

.quick-edit-table tr:hover td {
    background: var(--hover-bg);
}

.quick-edit-table tr:hover td.editable:hover {
    background: var(--step-highlight-bg);
}

.quick-edit-find-replace-popup {
    background: var(--surface);
    border-color: var(--border-color);
}

.find-replace-header {
    background: var(--modal-header-bg);
    border-bottom-color: var(--surface-border);
    color: var(--text-ui);
}

.close-find-btn {
    color: var(--text-secondary);
}

.close-find-btn:hover {
    background: var(--surface-border);
    color: var(--text-ui);
}

.find-input-row input,
.replace-input-row input {
    background: var(--surface2);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.find-input-row input:focus,
.replace-input-row input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(58, 123, 213, 0.15);
}

.find-nav-buttons button {
    background: var(--surface2);
    border-color: var(--border-color);
    color: var(--text-ui);
}

.find-nav-buttons button:hover {
    background: var(--hover-bg);
    border-color: var(--accent);
}

.find-replace-footer {
    background: var(--modal-header-bg);
    border-top-color: var(--surface-border);
}

.scope-selector {
    color: var(--text-secondary);
}

.scope-selector select {
    background: var(--surface2);
    border-color: var(--border-color);
    color: var(--text-ui);
}

#quickEditMatchCount {
    color: var(--text-secondary);
}

.find-match-highlight {
    background: var(--search-highlight-bg);
    color: var(--search-highlight-color);
}

.find-match-current {
    background: var(--bar-learning);
    color: #000;
    box-shadow: 0 0 0 2px var(--accent);
}

/* General tab column sizing */
#quickEditGeneralTab .quick-edit-table {
    table-layout: auto;
    width: 100%;
}

#quickEditGeneralTab th,
#quickEditGeneralTab td {
    white-space: nowrap;
}

#quickEditGeneralTab th.notes-header,
#quickEditGeneralTab td.notes-cell {
    white-space: normal;
    width: 100%;
    max-width: min(40vw, 600px);
    min-width: 150px;
}