/**
 * Table Column Widths - CSS Clamp
 * Fluid scaling between 390px and 1440px viewport
 *
 * HARD-CODED min/max values from screenshots - DO NOT CHANGE
 * Formula: clamp(min, calc(min + (max - min) * (100vw - 390px) / 1050), max)
 */

/* ===========================================
   SERIES-RESULTS TABLE
   Columns: Checkbox, Cover, Series Title, Publisher, Year, Type, Vol, #
   390px values: 26, 42, 80, 0, 38, 67, 28, 29
   1440px values: 32, 60, 400, 229, 75, 136, 83, 85
   =========================================== */
[data-table-id="series-results"] th:nth-child(1),
[data-table-id="series-results"] td:nth-child(1) {
    /* Checkbox: 26px (min) → 32px (max) */
    width: clamp(26px, calc(26px + 6 * (100vw - 390px) / 1050), 32px) !important;
    min-width: 26px !important;
    max-width: 32px !important;
}

[data-table-id="series-results"] th:nth-child(2),
[data-table-id="series-results"] td:nth-child(2) {
    /* Cover: 42px (min) → 60px (max) — tighter since refresh buttons hidden */
    width: clamp(42px, calc(42px + 18 * (100vw - 390px) / 1050), 60px) !important;
    min-width: 42px !important;
    max-width: 60px !important;
}

[data-table-id="series-results"] th:nth-child(3),
[data-table-id="series-results"] td:nth-child(3) {
    /* Series Title: 80px (min) → 400px (max) — freed space for right columns */
    width: clamp(80px, calc(80px + 320 * (100vw - 390px) / 1050), 400px) !important;
    min-width: 80px !important;
    max-width: 400px !important;
}

[data-table-id="series-results"] th:nth-child(4),
[data-table-id="series-results"] td:nth-child(4) {
    /* Publisher: 0px (min) → 229px (max) - hidden on mobile */
    width: clamp(0px, calc(229 * (100vw - 390px) / 1050), 229px) !important;
    min-width: 0px !important;
    max-width: 229px !important;
}

[data-table-id="series-results"] th:nth-child(5),
[data-table-id="series-results"] td:nth-child(5) {
    /* Year: 38px (min) → 75px (max) */
    width: clamp(38px, calc(38px + 37 * (100vw - 390px) / 1050), 75px) !important;
    min-width: 38px !important;
    max-width: 75px !important;
}

[data-table-id="series-results"] th:nth-child(6),
[data-table-id="series-results"] td:nth-child(6) {
    /* Type: 67px (min) → 136px (max) */
    width: clamp(67px, calc(67px + 69 * (100vw - 390px) / 1050), 136px) !important;
    min-width: 67px !important;
    max-width: 136px !important;
}

[data-table-id="series-results"] th:nth-child(7),
[data-table-id="series-results"] td:nth-child(7) {
    /* Vol: 28px (min) → 83px (max) */
    width: clamp(28px, calc(28px + 55 * (100vw - 390px) / 1050), 83px) !important;
    min-width: 28px !important;
    max-width: 83px !important;
}

[data-table-id="series-results"] th:nth-child(8),
[data-table-id="series-results"] td:nth-child(8) {
    /* #: 29px (at 390px) → 85px (at 1440px) */
    width: clamp(29px, calc(29px + 56 * (100vw - 390px) / 1050), 85px) !important;
    min-width: 29px !important;
    max-width: 85px !important;
}

/* Hide Publisher column on small screens */
@media (max-width: 600px) {
    [data-table-id="series-results"] th:nth-child(4),
    [data-table-id="series-results"] td:nth-child(4) {
        display: none !important;
    }
}


/* ===========================================
   ISSUES-RESULTS TABLE
   Columns: Checkbox, Cover, #, Story, Month, Year
   390px values: 30, 50, 50, 90, 50, 40
   1440px values: 40, 75, 216, 594, 101, 94
   =========================================== */
[data-table-id="issues-results"] th:nth-child(1),
[data-table-id="issues-results"] td:nth-child(1) {
    /* Checkbox: 30px (min) → 40px (max) */
    width: clamp(30px, calc(30px + 10 * (100vw - 390px) / 1050), 40px) !important;
    min-width: 30px !important;
    max-width: 40px !important;
}

[data-table-id="issues-results"] th:nth-child(2),
[data-table-id="issues-results"] td:nth-child(2) {
    /* Cover: 50px (min) → 75px (max) */
    width: clamp(50px, calc(50px + 25 * (100vw - 390px) / 1050), 75px) !important;
    min-width: 50px !important;
    max-width: 75px !important;
}

[data-table-id="issues-results"] th:nth-child(3),
[data-table-id="issues-results"] td:nth-child(3) {
    /* #: 50px (min) → 216px (max) */
    width: clamp(50px, calc(50px + 166 * (100vw - 390px) / 1050), 216px) !important;
    min-width: 50px !important;
    max-width: 216px !important;
}

[data-table-id="issues-results"] th:nth-child(4),
[data-table-id="issues-results"] td:nth-child(4) {
    /* Story: 90px (min) → 594px (max) */
    width: clamp(90px, calc(90px + 504 * (100vw - 390px) / 1050), 594px) !important;
    min-width: 90px !important;
    max-width: 594px !important;
}

[data-table-id="issues-results"] th:nth-child(5),
[data-table-id="issues-results"] td:nth-child(5) {
    /* Month: 50px (min) → 101px (max) */
    width: clamp(50px, calc(50px + 51 * (100vw - 390px) / 1050), 101px) !important;
    min-width: 50px !important;
    max-width: 101px !important;
}

[data-table-id="issues-results"] th:nth-child(6),
[data-table-id="issues-results"] td:nth-child(6) {
    /* Year: 40px (min) → 94px (max) */
    width: clamp(40px, calc(40px + 54 * (100vw - 390px) / 1050), 94px) !important;
    min-width: 40px !important;
    max-width: 94px !important;
}


/* ===========================================
   VARIANTS TABLE
   Columns: Checkbox, Cover, Edition, Type, Raw, 8.0, 9.4
   390px values: 30, 36, 70, 45, 43, 43, 43
   1440px values: 40, 80, 340, 120, 180, 180, 180
   =========================================== */
[data-table-id="variants"] th:nth-child(1),
[data-table-id="variants"] td:nth-child(1),
.variants-table th:nth-child(1),
.variants-table td:nth-child(1) {
    /* Checkbox: 30px (min) → 40px (max) */
    width: clamp(30px, calc(30px + 10 * (100vw - 390px) / 1050), 40px) !important;
    min-width: 30px !important;
    max-width: 40px !important;
}

[data-table-id="variants"] th:nth-child(2),
[data-table-id="variants"] td:nth-child(2),
.variants-table th:nth-child(2),
.variants-table td:nth-child(2) {
    /* Cover: 36px (min) → 80px (max) */
    width: clamp(36px, calc(36px + 44 * (100vw - 390px) / 1050), 80px) !important;
    min-width: 36px !important;
    max-width: 80px !important;
}

[data-table-id="variants"] th:nth-child(3),
[data-table-id="variants"] td:nth-child(3),
.variants-table th:nth-child(3),
.variants-table td:nth-child(3) {
    /* Edition: 70px (min) → 340px (max) */
    width: clamp(70px, calc(70px + 270 * (100vw - 390px) / 1050), 340px) !important;
    min-width: 70px !important;
    max-width: 340px !important;
}

[data-table-id="variants"] th:nth-child(4),
[data-table-id="variants"] td:nth-child(4),
.variants-table th:nth-child(4),
.variants-table td:nth-child(4) {
    /* Type: 45px (min) → 120px (max) */
    width: clamp(45px, calc(45px + 75 * (100vw - 390px) / 1050), 120px) !important;
    min-width: 45px !important;
    max-width: 120px !important;
}

[data-table-id="variants"] th:nth-child(5),
[data-table-id="variants"] td:nth-child(5),
.variants-table th:nth-child(5),
.variants-table td:nth-child(5) {
    /* Raw: 43px (min) → 180px (max) */
    width: clamp(43px, calc(43px + 137 * (100vw - 390px) / 1050), 180px) !important;
    min-width: 43px !important;
    max-width: 180px !important;
}

[data-table-id="variants"] th:nth-child(6),
[data-table-id="variants"] td:nth-child(6),
.variants-table th:nth-child(6),
.variants-table td:nth-child(6) {
    /* 8.0: 43px (min) → 180px (max) */
    width: clamp(43px, calc(43px + 137 * (100vw - 390px) / 1050), 180px) !important;
    min-width: 43px !important;
    max-width: 180px !important;
}

[data-table-id="variants"] th:nth-child(7),
[data-table-id="variants"] td:nth-child(7),
.variants-table th:nth-child(7),
.variants-table td:nth-child(7) {
    /* 9.4: 43px (min) → 180px (max) */
    width: clamp(43px, calc(43px + 137 * (100vw - 390px) / 1050), 180px) !important;
    min-width: 43px !important;
    max-width: 180px !important;
}


/* ===========================================
   COLLECTION TABLE
   Columns: Checkbox, Cover, Title, Variant, Grade, Value, Change, Costs, Current ROI, Potential ROI, Status
   390px values: 18, 28, 56, 40, 29, 27, 28, 28, 28, 25, 28
   1440px values: 35, 90, 165, 140, 79, 115, 101, 108, 101, 108, 124
   =========================================== */
[data-table-id="collection"] th:nth-child(1),
[data-table-id="collection"] td:nth-child(1),
.collection-table:not(.totals-table) th:nth-child(1),
.collection-table:not(.totals-table) td:nth-child(1) {
    /* Checkbox: 18px (min) → 55px (max) — wider at desktop to push columns right */
    width: clamp(18px, calc(18px + 37 * (100vw - 390px) / 1050), 55px) !important;
    min-width: 18px !important;
    max-width: 55px !important;
}

[data-table-id="collection"] th:nth-child(2),
[data-table-id="collection"] td:nth-child(2),
.collection-table:not(.totals-table) th:nth-child(2),
.collection-table:not(.totals-table) td:nth-child(2) {
    /* Cover: 28px (min) → 90px (max) */
    width: clamp(28px, calc(28px + 62 * (100vw - 390px) / 1050), 90px) !important;
    min-width: 28px !important;
    max-width: 90px !important;
}

[data-table-id="collection"] th:nth-child(3),
[data-table-id="collection"] td:nth-child(3),
.collection-table:not(.totals-table) th:nth-child(3),
.collection-table:not(.totals-table) td:nth-child(3) {
    /* Title: 56px (min) → 165px (max) */
    width: clamp(56px, calc(56px + 109 * (100vw - 390px) / 1050), 165px) !important;
    min-width: 56px !important;
    max-width: 165px !important;
}

[data-table-id="collection"] th:nth-child(4),
[data-table-id="collection"] td:nth-child(4),
.collection-table:not(.totals-table) th:nth-child(4),
.collection-table:not(.totals-table) td:nth-child(4) {
    /* Variant: 40px (min) → 140px (max) */
    width: clamp(40px, calc(40px + 100 * (100vw - 390px) / 1050), 140px) !important;
    min-width: 40px !important;
    max-width: 140px !important;
}

[data-table-id="collection"] th:nth-child(5),
[data-table-id="collection"] td:nth-child(5),
.collection-table:not(.totals-table) th:nth-child(5),
.collection-table:not(.totals-table) td:nth-child(5) {
    /* Grade: 29px (min) → 79px (max) */
    width: clamp(29px, calc(29px + 50 * (100vw - 390px) / 1050), 79px) !important;
    min-width: 29px !important;
    max-width: 79px !important;
}

[data-table-id="collection"] th:nth-child(6),
[data-table-id="collection"] td:nth-child(6),
.collection-table:not(.totals-table) th:nth-child(6),
.collection-table:not(.totals-table) td:nth-child(6) {
    /* Value: 27px (min) → 115px (max) */
    width: clamp(27px, calc(27px + 88 * (100vw - 390px) / 1050), 115px) !important;
    min-width: 27px !important;
    max-width: 115px !important;
}

[data-table-id="collection"] th:nth-child(7),
[data-table-id="collection"] td:nth-child(7),
.collection-table:not(.totals-table) th:nth-child(7),
.collection-table:not(.totals-table) td:nth-child(7) {
    /* Change: 28px (min) → 101px (max) */
    width: clamp(28px, calc(28px + 73 * (100vw - 390px) / 1050), 101px) !important;
    min-width: 28px !important;
    max-width: 101px !important;
}

[data-table-id="collection"] th:nth-child(8),
[data-table-id="collection"] td:nth-child(8),
.collection-table:not(.totals-table) th:nth-child(8),
.collection-table:not(.totals-table) td:nth-child(8) {
    /* Costs: 28px (min) → 108px (max) */
    width: clamp(28px, calc(28px + 80 * (100vw - 390px) / 1050), 108px) !important;
    min-width: 28px !important;
    max-width: 108px !important;
}

[data-table-id="collection"] th:nth-child(9),
[data-table-id="collection"] td:nth-child(9),
.collection-table:not(.totals-table) th:nth-child(9),
.collection-table:not(.totals-table) td:nth-child(9) {
    /* Current ROI: 28px (min) → 101px (max) */
    width: clamp(28px, calc(28px + 73 * (100vw - 390px) / 1050), 101px) !important;
    min-width: 28px !important;
    max-width: 101px !important;
}

[data-table-id="collection"] th:nth-child(10),
[data-table-id="collection"] td:nth-child(10),
.collection-table:not(.totals-table) th:nth-child(10),
.collection-table:not(.totals-table) td:nth-child(10) {
    /* Potential ROI: 25px (min) → 108px (max) - hidden on mobile */
    width: clamp(25px, calc(25px + 83 * (100vw - 390px) / 1050), 108px) !important;
    min-width: 25px !important;
    max-width: 108px !important;
}

[data-table-id="collection"] th:nth-child(11),
[data-table-id="collection"] td:nth-child(11),
.collection-table:not(.totals-table) th:nth-child(11),
.collection-table:not(.totals-table) td:nth-child(11) {
    /* Status: 28px (min) → 124px (max) */
    width: clamp(28px, calc(28px + 96 * (100vw - 390px) / 1050), 124px) !important;
    min-width: 28px !important;
    max-width: 124px !important;
}

/* Hide Potential ROI column on small screens */
@media (max-width: 500px) {
    [data-table-id="collection"] th:nth-child(10),
    [data-table-id="collection"] td:nth-child(10),
    .collection-table:not(.totals-table) th:nth-child(10),
    .collection-table:not(.totals-table) td:nth-child(10) {
        display: none !important;
    }
}


/* ===========================================
   NEWEST-ISSUES TABLE
   Columns: Checkbox, Cover, Series Title, #, Publisher, Type, Variants, On Sale
   390px values: 26, 44, 76, 28, 50, 46, 30, 60
   1440px values: 40, 75, 350, 60, 150, 120, 70, 100
   =========================================== */
[data-table-id="newest-issues"] th:nth-child(1),
[data-table-id="newest-issues"] td:nth-child(1) {
    /* Checkbox: 26px (min) → 40px (max) */
    width: clamp(26px, calc(26px + 14 * (100vw - 390px) / 1050), 40px) !important;
    min-width: 26px !important;
    max-width: 40px !important;
}

[data-table-id="newest-issues"] th:nth-child(2),
[data-table-id="newest-issues"] td:nth-child(2) {
    /* Cover: 44px (min) → 75px (max) */
    width: clamp(44px, calc(44px + 31 * (100vw - 390px) / 1050), 75px) !important;
    min-width: 44px !important;
    max-width: 75px !important;
}

[data-table-id="newest-issues"] th:nth-child(3),
[data-table-id="newest-issues"] td:nth-child(3) {
    /* Series Title: 76px (min) → 350px (max) */
    width: clamp(76px, calc(76px + 274 * (100vw - 390px) / 1050), 350px) !important;
    min-width: 76px !important;
    max-width: 350px !important;
}

[data-table-id="newest-issues"] th:nth-child(4),
[data-table-id="newest-issues"] td:nth-child(4) {
    /* #: 28px (min) → 60px (max) */
    width: clamp(28px, calc(28px + 32 * (100vw - 390px) / 1050), 60px) !important;
    min-width: 28px !important;
    max-width: 60px !important;
}

[data-table-id="newest-issues"] th:nth-child(5),
[data-table-id="newest-issues"] td:nth-child(5) {
    /* Publisher: 50px (min) → 150px (max) */
    width: clamp(50px, calc(50px + 100 * (100vw - 390px) / 1050), 150px) !important;
    min-width: 50px !important;
    max-width: 150px !important;
}

[data-table-id="newest-issues"] th:nth-child(6),
[data-table-id="newest-issues"] td:nth-child(6) {
    /* Type: 46px (min) → 120px (max) */
    width: clamp(46px, calc(46px + 74 * (100vw - 390px) / 1050), 120px) !important;
    min-width: 46px !important;
    max-width: 120px !important;
}

[data-table-id="newest-issues"] th:nth-child(7),
[data-table-id="newest-issues"] td:nth-child(7) {
    /* Variants: 30px (min) → 70px (max) */
    width: clamp(30px, calc(30px + 40 * (100vw - 390px) / 1050), 70px) !important;
    min-width: 30px !important;
    max-width: 70px !important;
}

[data-table-id="newest-issues"] th:nth-child(8),
[data-table-id="newest-issues"] td:nth-child(8) {
    /* On Sale: 60px (min) → 100px (max) */
    width: clamp(60px, calc(60px + 40 * (100vw - 390px) / 1050), 100px) !important;
    min-width: 60px !important;
    max-width: 100px !important;
}

/* Hide Publisher column on small screens */
@media (max-width: 600px) {
    [data-table-id="newest-issues"] th:nth-child(5),
    [data-table-id="newest-issues"] td:nth-child(5) {
        display: none !important;
    }
}


/* ===========================================
   TOTALS TABLE - Match collection table column widths
   =========================================== */
.totals-table th:nth-child(1),
.totals-table td:nth-child(1) {
    width: clamp(18px, calc(18px + 17 * (100vw - 390px) / 1050), 35px) !important;
    min-width: 18px !important;
    max-width: 35px !important;
}

.totals-table th:nth-child(2),
.totals-table td:nth-child(2) {
    width: clamp(28px, calc(28px + 62 * (100vw - 390px) / 1050), 90px) !important;
    min-width: 28px !important;
    max-width: 90px !important;
}

.totals-table th:nth-child(3),
.totals-table td:nth-child(3) {
    width: clamp(56px, calc(56px + 109 * (100vw - 390px) / 1050), 165px) !important;
    min-width: 56px !important;
    max-width: 165px !important;
}

.totals-table th:nth-child(4),
.totals-table td:nth-child(4) {
    width: clamp(40px, calc(40px + 100 * (100vw - 390px) / 1050), 140px) !important;
    min-width: 40px !important;
    max-width: 140px !important;
}

.totals-table th:nth-child(5),
.totals-table td:nth-child(5) {
    width: clamp(29px, calc(29px + 50 * (100vw - 390px) / 1050), 79px) !important;
    min-width: 29px !important;
    max-width: 79px !important;
}

.totals-table th:nth-child(6),
.totals-table td:nth-child(6) {
    width: clamp(27px, calc(27px + 88 * (100vw - 390px) / 1050), 115px) !important;
    min-width: 27px !important;
    max-width: 115px !important;
}

.totals-table th:nth-child(7),
.totals-table td:nth-child(7) {
    /* Change: 28px (min) → 101px (max) */
    width: clamp(28px, calc(28px + 73 * (100vw - 390px) / 1050), 101px) !important;
    min-width: 28px !important;
    max-width: 101px !important;
}

.totals-table th:nth-child(8),
.totals-table td:nth-child(8) {
    /* Costs: 28px (min) → 108px (max) */
    width: clamp(28px, calc(28px + 80 * (100vw - 390px) / 1050), 108px) !important;
    min-width: 28px !important;
    max-width: 108px !important;
}

.totals-table th:nth-child(9),
.totals-table td:nth-child(9) {
    /* Current ROI: 28px (min) → 101px (max) */
    width: clamp(28px, calc(28px + 73 * (100vw - 390px) / 1050), 101px) !important;
    min-width: 28px !important;
    max-width: 101px !important;
}

.totals-table th:nth-child(10),
.totals-table td:nth-child(10) {
    /* Potential ROI: 25px (min) → 108px (max) */
    width: clamp(25px, calc(25px + 83 * (100vw - 390px) / 1050), 108px) !important;
    min-width: 25px !important;
    max-width: 108px !important;
}

.totals-table th:nth-child(11),
.totals-table td:nth-child(11) {
    /* Status: 28px (min) → 124px (max) */
    width: clamp(28px, calc(28px + 96 * (100vw - 390px) / 1050), 124px) !important;
    min-width: 28px !important;
    max-width: 124px !important;
}


/* ===========================================
   BROWSE PUBLISHERS TABLE - Single column, full width
   =========================================== */
[data-table-id="browse-publishers"] {
    width: 100% !important;
}

[data-table-id="browse-publishers"] th:nth-child(1),
[data-table-id="browse-publishers"] td:nth-child(1) {
    width: 100% !important;
}


/* ===========================================
   LIST ITEMS TABLE - 6 columns: Checkbox, Cover, Series Title, #, Variant, Year
   =========================================== */
[data-table-id="list-items"] {
    width: 100% !important;
}

[data-table-id="list-items"] th:nth-child(1),
[data-table-id="list-items"] td:nth-child(1) {
    /* Checkbox */
    width: 40px !important;
    min-width: 30px !important;
    max-width: 40px !important;
}

[data-table-id="list-items"] th:nth-child(2),
[data-table-id="list-items"] td:nth-child(2) {
    /* Cover */
    width: clamp(40px, calc(40px + 20 * (100vw - 390px) / 1050), 60px) !important;
    min-width: 40px !important;
    max-width: 60px !important;
}

[data-table-id="list-items"] th:nth-child(3),
[data-table-id="list-items"] td:nth-child(3) {
    /* Series Title: flexible */
    width: clamp(120px, calc(120px + 380 * (100vw - 390px) / 1050), 500px) !important;
    min-width: 120px !important;
}

[data-table-id="list-items"] th:nth-child(4),
[data-table-id="list-items"] td:nth-child(4) {
    /* Issue # */
    width: clamp(40px, calc(40px + 20 * (100vw - 390px) / 1050), 60px) !important;
    min-width: 40px !important;
    max-width: 60px !important;
}

[data-table-id="list-items"] th:nth-child(5),
[data-table-id="list-items"] td:nth-child(5) {
    /* Variant */
    width: clamp(60px, calc(60px + 140 * (100vw - 390px) / 1050), 200px) !important;
    min-width: 60px !important;
    max-width: 200px !important;
}

[data-table-id="list-items"] th:nth-child(6),
[data-table-id="list-items"] td:nth-child(6) {
    /* Year */
    width: clamp(40px, calc(40px + 20 * (100vw - 390px) / 1050), 60px) !important;
    min-width: 40px !important;
    max-width: 60px !important;
}

/* Hide Variant column on small screens */
@media (max-width: 480px) {
    [data-table-id="list-items"] th:nth-child(5),
    [data-table-id="list-items"] td:nth-child(5) {
        display: none !important;
    }
}
