/* ===== Theme ===== */
:root {
    --primary-color: #005fae;
    --secondary-color: #f0f0f0;
    --background-color: #fff;
    --border-color: #d0d7de;
    --hover-color: #003a6b;
    --text-color: #000;
}

/* ===== Base ===== */
* {
    box-sizing: border-box
}

body {
    margin: 0;
    font-family: Helvetica Neue, Arial, sans-serif;
    background: var(--background-color);
    color: var(--text-color);
    line-height: 1.4;
}

.container {
    max-width: 90%;
    margin: 0 auto;
    padding: 1rem
}

/* ===== Header ===== */
.header {
    background: var(--primary-color);
    color: #fff;
    padding: 1rem 0;
    text-align: center;
    font-size: 2rem;
    font-weight: 600;
    border-radius: 8px;
}

.header h1 {
    margin: 0;
}

/* ===== Table ===== */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5rem;
    background: #fff;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .05);
}

table caption {
    caption-side: top;
    padding: .5rem;
    font-weight: 600
}

table th, table td {
    padding: .5rem;
    border: 1px solid var(--border-color)
}

table th {
    background: var(--secondary-color);
    color: var(--primary-color);
    font-weight: 600
}

/* ===== Fieldset / Form ===== */
fieldset {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .05);
}

legend {
    font-weight: 600;
    color: var(--primary-color)
}

.checkbox_images_legend {
    margin-right: .5rem;
    font-weight: 500;
    font-size: 1.05rem
}

.form-row label:not(.checkbox_codecs_legend,.checkbox_images_legend),
#label_codecs, #label_images {
    margin-right: .5rem;
    margin-left: .5rem;
    font-weight: 550;
    font-size: 1.2rem
}

select {
    padding: .4rem .6rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    min-width: 120px;
    font-size: .95rem;
}

.checkbox-group {
    flex-wrap: wrap;
    gap: .5rem
}

#select_images > span {
    margin-right: .5rem;
    white-space: nowrap;
}

.checkbox_images {
    margin: .5rem .5rem 0 0
}

.checkbox_codecs_legend {
    display: inline-block
}

/* Modern button style */
.modern-button {
    padding: .5rem 1rem;
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
}

.modern-button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* ===== Codecs: layout (2 columns via JS) ===== */
#select_codecs {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.codec-col {
    flex: 1 1 0;
    min-width: 0
}

.codec-group-card {
    width: 100%;
    border: 1px solid #e5e5e5;
    border-radius: 10px;
    padding: .6rem .8rem .75rem;
    background: #fff;
    margin-bottom: 16px;
}


/* group / subgroup labels */
.group-label {
    font-weight: 600;
    cursor: pointer
}

.subgroup-label {
    font-weight: 500;
    white-space: nowrap;
    border-right: 1px solid #000000;
    cursor: pointer;
    margin-left: 1rem;
    min-width: 6.5rem;
}


/* one row = [subgroup label | list of checkboxes] */
.subgroup-row {
    display: grid;
    grid-template-columns:auto 1fr; /* left: label, right: items */
    gap: .35rem .9rem;
    align-items: start;
    margin-bottom: .25rem;
}


/* checkbox list: horizontal, wraps when needed */
.subgroup-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0 .75rem;
    align-items: center;
    /*min-height: 28px;*/
}

.subgroup-list > span {
    display: inline-flex;
    align-items: center;
}

.checkbox_codecs_legend {
    line-height: 1.2;
    white-space: normal; /* allow wrapping for long names */
}

/* ===== Buttons ===== */
#apply {
    padding: .6rem 1.2rem;
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color .2s ease;
}

#apply:hover {
    background: var(--hover-color)
}

.resetBtn {
    padding: .35rem .75rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
}

.resetBtn:hover {
    background: #f6f6f6
}

/* ===== Chart ===== */


.chart-container {
    position: relative;
    width: 100%;
    margin-top: 1rem;
    display: flex;
}

.chart-area {
    width: 80%;
    max-width: 80%;
    flex: 0 0 80%;
}

.chart-area canvas {
    width: 100%;
    height: 100%;
}


.chart-legend {
    overflow-x: auto;
    overflow-y: hidden;
    width: 20%;
    flex: 0 0 20%;
    margin: 1.5rem;
}


.chart-legend ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    height: 100%;
    width: max-content;
}

.chart-legend li {
    display: flex;
    align-items: center;
    cursor: pointer;
    margin-right: .5rem;
    margin-bottom: .5rem;
    white-space: nowrap;
    font-size: 12px;
}

.chart-legend li.hidden span:last-child {
    text-decoration: line-through;
}

.chart-legend .legend-box {
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-right: .5rem;
    border: 2px solid transparent;
}

/* ===== Modal ===== */
.modal {
    display: none;
    position: fixed;
    z-index: 9999;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    font-size: 2em;
    justify-content: center;
    align-items: center;
}

/* image preview */
.image-preview {
    position: fixed;
    top: 0;
    left: 0;
    max-width: 320px;
    max-height: 240px;
    display: none;
    border: 1px solid rgba(0, 0, 0, .15);
    background: #fff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
    padding: 4px;
    border-radius: 8px;
    z-index: 9999;
    pointer-events: none;
}


/* ===== Responsive ===== */
@media (max-width: 768px) {
    #select_codecs {
        flex-direction: column;
    }

    .form-row {
        display: block !important;
        margin-right: 0 !important;
    }
}
