.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background-color: darkcyan;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.sidebar {
    position: fixed;
    top: 60px;
    left: 0;
    bottom: 0;
    width: 250px;
    background-color: black;
    color: white;
    padding: 1rem;
    overflow-y: auto;
}

.main-content {
    margin-top: 60px;
    margin-left: 240px;
    padding: 1.5rem;
    background-color: #f4f4f4;
    min-height: calc(100vh - 60px);
}

.container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 400px;
    max-width: 400px;
    margin: 1rem;
    padding: 2rem;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.2);
    border-radius: var(--border-radius);
    background: #ffffff;
}

h1 {
    color: #333;
    text-align: center;
}

form#uploadForm {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
    gap: 10px;
}

input[type="file"] {
    padding: 5px;
}

button {
    background-color: #007bff;
    color: white;
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

    button:hover {
        background-color: #0056b3;
    }

#result {
    margin-top: 20px;
    overflow-x: auto;
}

.csvTable,
.csvFillTable {
    border-collapse: collapse;
    width: max-content;
    table-layout: auto;
    font-family: Arial, sans-serif;
}

    /* Sticky header row 1 (column selectors) */
    .csvTable thead tr.column-selector-row th,
    .csvFillTable thead tr.column-selector-row th {
        position: sticky;
        top: 0;
        z-index: 3;
        background: #f0f0f0;
        border-bottom: 0px;
        height: 38px;
        min-height: 36px;
        box-sizing: border-box;
    }

    /* Sticky header row 2 (CSV header names) */
    .csvTable thead tr.header-row th,
    .csvFillTable thead tr.header-row th {
        position: sticky;
        top: 38px; /* 36px + 2px */
        z-index: 3;
        background: #f0f0f0;
        border-top: 0px;
        height: 38px;
        min-height: 38px;
        box-sizing: border-box;
    }

    /* Sticky leftmost column for headers and body */
    .csvTable th.row-index,
    .csvTable td.row-index,
    .csvFillTable th.row-index,
    .csvFillTable td.row-index {
        position: sticky;
        left: 0;
        z-index: 4;
        background: #f8f8f8;
    }

    /* Sticky intersection: top-left cell(s) */
    .csvTable thead tr.column-selector-row th.row-index,
    .csvFillTable thead tr.column-selector-row th.row-index,
    .csvTable thead tr.header-row th.row-index,
    .csvFillTable thead tr.header-row th.row-index {
        z-index: 5;
    }

    .csvTable thead th,
    .csvFillTable thead th {
        border: 1px solid #ccc;
        padding: 8px;
        text-align: left;
        font-weight: bold;
        cursor: pointer;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        min-width: 120px;
        max-width: 400px;
    }

    .csvTable td,
    .csvFillTable td {
        border: 1px solid #ccc;
        padding: 4px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        min-width: 120px;
        max-width: 400px;
    }

        .csvTable td input,
        .csvFillTable td input {
            width: 100%;
            border: none;
            background-color: transparent;
            padding: 4px;
            font-size: 14px;
        }

            .csvTable td input:focus,
            .csvFillTable td input:focus {
                outline: 2px solid #007bff;
                background-color: #fff;
            }

    .csvTable tbody tr:nth-child(even),
    .csvFillTable tbody tr:nth-child(even) {
        background-color: #f9f9f9;
    }

#saveBtn {
    display: block;
    margin: 20px auto;
    background-color: #28a745;
}

    #saveBtn:hover {
        background-color: #1e7e34;
    }

.custom-file-upload {
    display: inline-block;
    padding: 0px 12px;
    margin-top: 20px;
    margin-right: 10px;
    font-size: 14px;
    font-weight: 500;
    color: white;
    background-color: #007bff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    height: 26px;
    line-height: 24px;
}

    .custom-file-upload:hover {
        background-color: #0056b3;
    }

#csvContainer,
#previewContainer {
    overflow-x: auto;
    overflow-y: auto;
    width: 100%;
    max-height: 70vh;
    border: 1px solid #ccc;
}

#cancelEdit,
#saveCsv,
#createNew {
    margin-right: 10px;
}

/* Drag-fill enhancements now rely on natural sizing */

td.row-index, th.row-index {
    width: 20px;
    min-width: 20px;
    max-width: 20px;
    text-align: center;
    background-color: #f8f8f8;
    font-weight: bold;
    user-select: none;
}

.context-menu {
    position: absolute;
    z-index: 9999;
    background: white;
    border: 1px solid #ccc;
    list-style: none;
    padding: 5px 0;
    margin: 0;
    box-shadow: 2px 2px 6px rgba(0,0,0,0.2);
    width: 120px;
}

    .context-menu li {
        padding: 6px 12px;
        cursor: pointer;
    }

        .context-menu li:hover {
            background-color: #f0f0f0;
        }

.ad-feed {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: white;
    font-size: 0.85rem;
    text-align: right;
    line-height: 1.4;
    width: 250px;
}

.ad-scroll-container {
    overflow: hidden;
    white-space: nowrap;
    width: 20%;
    height: 3em;
    position: absolute;
    right: 15px;
}

.ad-scroll {
    display: inline-block;
    padding-left: 100%;
    animation: scroll-left 15s linear infinite;
}

@keyframes scroll-left {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-100%);
    }
}

.ad-feed a {
    color: yellow;
    text-decoration: underline;
    font-weight: bold;
    display: block;
    margin-top: 4px;
}

@media (max-width: 600px) {
    .ad-feed {
        display: none;
    }
}

.selected-column {
    background-color: #fff5cc !important;
    border: 2px dashed orange;
}

.selected-row {
    background-color: #e6f7ff !important;
    outline: 2px solid #007acc;
}

.flash {
    background-color: yellow !important;
    transition: background-color 0.5s ease;
}

th.flash, td.flash {
    background-color: yellow !important;
}

#colContextMenu .menu-item {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    cursor: pointer;
    gap: 8px;
}

    #colContextMenu .menu-item:hover {
        background-color: #f0f0f0;
    }

    #colContextMenu .menu-item span.icon {
        width: 20px;
        text-align: center;
        font-size: 16px;
    }

    #colContextMenu .menu-item span.label {
        flex-grow: 1;
    }

    #colContextMenu .menu-item span.shortcut {
        color: #888;
        font-size: 12px;
    }

/* Hidden by default */
.dropdown-arrow {
    opacity: 0;
    transition: opacity 0.2s ease;
    margin-left: 4px;
    font-size: 12px;
    color: #555;
}

/* Fade in on hover */
th:hover .dropdown-arrow {
    opacity: 1;
}

.selected-row-index {
    background: #007acc !important;
}

.selected-column-index {
    background: orange !important;
}

td.selected-cell {
    outline: 2px solid darkGreen;
}

td.selected-multicell {
    outline: 2px solid darkGreen;
    background: lightGreen !important;
}

.fill-handle {
    position: absolute;
    width: 8px;
    height: 8px;
    background-color: darkblue;
    right: 0;
    bottom: 0;
    cursor: crosshair;
    z-index: 1000;
    border-radius: 50%;
}

td {
    position: relative; /* so fill-handle positions relative to cell */
}

.fill-preview {
    background: rgba(0, 150, 0, 0.2) !important;
}

.move-hotzone {
    position: absolute;
    width: 7px;
    height: 7px;
    background-color: red; /* test: bright red square */
    cursor: grab;
    z-index: 9999;
}

.move-preview-box {
    position: absolute;
    border: 2px dashed rgba(0, 0, 0, 0.7);
    pointer-events: none;
    z-index: 9999;
}

/* Optional: remove default input border when editing inside selected cell */
td.selected-cell input {
    border: none;
    outline: none;
    background-color: transparent;
}

/* Only highlight cells at intersection of selected row+column */
td.selected-intersection {
    background-color: #73c1c5 !important;
}

.selected-header {
    border: 1px solid #ccc;
}
