body {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    font-family: Tahoma, sans-serif;
    background-color: #f0f0f0;
}

body.theme-transition {
    transition: background-color 0.5s ease, color 0.5s ease;
}

.container {
    background: white;
    padding: 30px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
    border-radius: 5px;
    width: 1010px;
    margin: auto;
}

textarea {
    width: 100%;
    padding: 5px;
    line-height: 1.5;
    font-size: 15px;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-sizing: border-box;
    resize: vertical;
    font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", Arial, sans-serif;
    white-space: pre-wrap; /* 保持空白字符和换行符，同时在内容超出容器宽度时换行 */
    word-break: break-all; /* 允许单词内断行 */
}

.table-container::-webkit-resizer, 
textarea::-webkit-resizer {
    background: url('data:image/svg+xml;utf8,\
    <svg fill="gray" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">\
      <polygon points="12,2 6,10 18,10" />\
      <polygon points="12,22 6,14 18,14" />\
    </svg>') no-repeat center center;
}

textarea:disabled {
    opacity: 0.8;
}

textarea[id="xml_urls"] {
    min-height: 152px;
}

textarea[id="channel_mappings"] {
    min-height: 155px;
}

textarea[id="gen_list_text"] {
    min-height: 110px;
}

textarea[id="sourceUrlTextarea"] {
    min-height: 102px;
}

.form-grid-item select,
.form-grid-item input,
.modal-content select {
    font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", Arial, sans-serif;
    font-size: 15px;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-sizing: border-box;
    width: 85px;
    height: 32px;
    text-align: center;
}

.modal-content select[id="live_source_config"] {
    height: 26px;
    font-size: 14px;
    margin-right: 12px;
}

.form-grid-container-single-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr); 
    gap: 10px; 
    align-items: center; 
    width: 100%;
    justify-items: end;
}

.form-grid-item {
    display: flex;
    align-items: center;
    gap: 5px; 
    flex-wrap: nowrap;
}

#interval-task-label {
    margin-right: -10px;
}

.interval-controls {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-grow: 1;
    white-space: nowrap;
    flex-wrap: nowrap;
}

.interval-controls select {
    width: 55px;
}

.form-grid-item label {
    white-space: nowrap; 
    flex-shrink: 0;
}

a, .blue-span {
    color: blue;
    cursor: pointer;
    text-decoration: none;
}

a:hover, .blue-span:hover {
    color: #0056b3;
}

.footer a {
    color: #333;
}

.button-container {
    display: flex;
    gap: 15px;
    margin: 0 auto;
    align-items: center;
    text-align: center;
    justify-content: space-between;
}

.button-container a, .button-container button,
.modal-content button, input[type="submit"] {
    padding: 10px;
    background-color: #2196F3;
    color: white;
    border: none;
    border-radius: 10px;
    text-align: center;
    cursor: pointer;
    box-sizing: border-box;
    align-items: center;
    width: 100%;
    font-size: 16px;
    font-weight: bold;
}

.button-container a:hover, .button-container button:hover,
input[type="submit"]:hover, #accessStatsTable th:hover {
    background-color: #0b7dda;
}

input[type="submit"],
.button-container button[name="logoutbtn"],
.modal-content button {
    background-color: #FF9800;
    border-radius: 5px;
}

input[type="submit"]:hover,
.button-container button[name="logoutbtn"]:hover,
.modal-content button:hover {
    background-color: #e68900;
}

button[id="deleteUnusedIcons"], button[id="uploadAllIcons"], 
button[id="showAllIcons"] {
    display: flex;
    height: 36px;
}

.button-container button[name="logoutbtn"] {
    border-radius: 10px;
    width: 500px;
}

input[type="text"],
input[type="tel"] {
    width: calc(100% - 22px);
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
}

input[type="tel"] {
    padding: 0px;
    height: 32px;
    font-size: 15px;
    margin-bottom: 0px;
}

.flex-container {
    display: flex;
    justify-content: space-between;
    gap: 20px;
}

.flex-item {
    width: 48%;
}

.footer {
    position: fixed !important;
    bottom: 0;
    left: 0;
    width: 100% !important;
    padding: 12px 0;
    text-align: center;
    background-color: rgba(243, 243, 243, 0.8);
    z-index: 999;
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1);
    margin-top: 0 !important;

    -webkit-backdrop-filter: blur(30px);
    backdrop-filter: blur(30px);
}

.modal {
    display: none; /* 默认隐藏 */
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.4);
    text-align: center;
}

.modal-content {
    background-color: #fefefe;
    display: inline-block;
    padding: 20px;
    border: 1px solid #888;
    text-align: left;
    border-radius: 10px;
    position: relative;
    box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
    top: 50%;
    transform: translateY(-50%);
    width: 750px;
    height: auto;
}

.version-update-modal-content,
.help-modal-content {
    padding-left: 25px;
}

.cron-log-modal-content,
.more-live-setting-modal-content,
.check-speed-modal-content {
    width: 500px;
}

.update-log-modal-content, 
.live-source-modal-content,
.access-log-modal-content,
.access-stat-modal-content {
    width: 1000px;
}

.message-modal-content {
    min-width: 150px;
    width: auto;
    height: auto;
    line-height: 1.6;
}

.icon-modal-content {
    width: 700px;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.close:hover,
.close:focus {
    color: black;
    cursor: pointer;
}

.table-container {
    height: 460px; /* 固定高度 */
    overflow-y: scroll; /* 启用垂直滚动条 */
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 15px;
}

.table-container[id="channel-table-container"],
.table-container[id="icon-table-container"] {
    height: 359px;
}

.table-container[id="channel-bind-epg-table-container"] {
    height: 399px;
}

.table-container[id="channel-match-table-container"] {
    height: 470px;
}

.table-container[id="live-source-table-container"] {
    height: 340px;
    min-height: 340px;
    margin-bottom: 0px;
    resize: vertical;
}

.table-container[id="access-stats-table-container"] {
    height: 471px;
}

#logTable, #channelMatchTable, #channelTable, 
#iconTable, #channelBindEPGTable, #liveSourceTable {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 0px; /* 调整行之间的垂直间距 */
    table-layout: fixed; /* 固定表格布局，防止内容超出 */
}

#logTable, #liveSourceTable {
    border-spacing: 0 5px; /* 调整行之间的垂直间距 */
}

#logTable th, #logTable td,
#channelTable th, #channelTable td,
#iconTable th, #iconTable td,
#channelBindEPGTable th, #channelBindEPGTable td,
#channelMatchTable th, #channelMatchTable td,
#liveSourceTable th, #liveSourceTable td {
    border: 1px solid #ccc;
    padding: 5px;
    word-break: break-all; /* 允许单词内断行 */
}

#channelTable th, #channelTable td,
#iconTable th, #iconTable td,
#channelMatchTable th, #channelMatchTable td,
#channelBindEPGTable th,
#liveSourceTable th, #liveSourceTable td {
    text-align: center;
}

#logTable th:nth-child(1), 
#logTable td:nth-child(1) {
    width: 10%; /* 第一列宽度 */
    text-align: center;
}

#logTable th:nth-child(2) {
    text-align: center; /* 第二列表头居中 */
}

#channelTable th:nth-child(1),
#channelTable td:nth-child(1) {
    width: 30%; /* 第一列宽度 */
}

#iconTable th:nth-child(1),
#iconTable td:nth-child(1) {
    width: 17%; /* 第一列宽度 */
}

#iconTable th:nth-child(2),
#iconTable td:nth-child(2) {
    width: 55%; /* 第二列宽度 */
}

#iconTable th:nth-child(3),
#iconTable td:nth-child(3) {
    width: 13%; /* 第三列宽度 */
}

#channelMatchTable th:nth-child(4),
#channelMatchTable td:nth-child(4) {
    width: 15%; /* 第四列宽度 */
}

#accessStatsTableWrapper {
    overflow: auto;
    max-width: 100%;
}

#accessStatsTable {
    border-collapse: collapse;
    width: max-content;
    min-width: 100%;
}

#accessStatsTable th,
#accessStatsTable td {
    border: 1px solid #ccc;
    padding: 6px;
    text-align: center;
    white-space: nowrap;
}

#accessStatsTable th {
    background-color: #2196F3;
    color: white;
    cursor: pointer;
    user-select: none;
    position: sticky;
    top: 0;
    z-index: 1;
}

#accessStatsTable td:first-child,
#accessStatsTable th:first-child {
    position: sticky;
}

.row {
    display: flex;
    flex-wrap: nowrap; /* 禁止换行 */
    gap: 45px;
    margin-bottom: 12px;
}

.column {
    display: flex;
    align-items: center;
    flex: 1; /* 每个列占据同等宽度 */
}

h2, span, label {
    user-select: none;
}

.row label {
    white-space: nowrap; /* 确保label不会换行 */
    margin-right: 0px;
    width: 100%;
}

.row select,
.row textarea {
    width: 100%;
    margin-right: 0px;
}

.row textarea {
    height: 32px;
    line-height: 1.3;
    white-space: nowrap; /* 禁止换行 */
    scrollbar-width: none; /* 隐藏滚动条 */
    resize: none;
}

.limited-row {
    max-height: 6em;  /* 限制约4行 */
    overflow: hidden;
    white-space: pre-wrap;
    word-break: break-all;
    transition: max-height 0.3s ease;
}
.limited-row.expanded {
    max-height: none !important;
}

/* 分页控件样式 */
#paginationContainer button {
    width: 25px;
    height: 20px;
    margin: 0 2px;
    padding: 0 0;
    color: #aaaaaa;
    background-color: #ffffff00;
    cursor: pointer;
    font-size: 15px;
}
#paginationContainer button.active, 
#paginationContainer button:hover {
    color: rgb(0, 0, 0);
}
#paginationContainer button[disabled] {
    color: #bbb;
    cursor: not-allowed;
}

/* 自定义滚动条样式 */
::-webkit-scrollbar {
    height: 10px;
    width: 10px;
}
::-webkit-scrollbar-thumb {
    background-color: #ddd;
    border-radius: 4px;
    cursor: default;
}
::-webkit-scrollbar-thumb:hover {
    background-color: #ccc;
}
::-webkit-scrollbar-track,
::-webkit-scrollbar-corner {
    background-color: #f5f5f5;
    cursor: default;
}

.table-cell-disable {
    font-weight: bold;
    color: red;
    background-color: #FFFFE0;
}

.table-cell-modified {
    font-weight: bold;
    color: red;
    background-color: #DEFAFF;
}

.table-cell-clickable {
    cursor: pointer;
    user-select: none;
}

.sticky-header {
    position: sticky;
    top: 0;
    background-color: white;
}

input[type="checkbox"] {
    vertical-align: middle;
}

/* 主题切换按钮 */
.checkbox {
    opacity: 0;
    position: absolute;
}

.checkbox-label {
    float: right;
    margin-right: 5px;
    margin-top: 20px;
    background-color: #444;
    width: 40px;
    height: 16px;
    border-radius: 50px;
    position: relative;
    padding: 5px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.5s ease;
}

.checkbox-label i {
    font-size: 18px;
    color: #f39c12;
    user-select: none;
    transition: opacity 0.5s ease;
}

.checkbox-label .ball {
    background-color: #fff;
    width: 22px;
    height: 22px;
    position: absolute;
    right: 2px; /* 小球保持在右边 */
    top: 2px;
    border-radius: 50%;
    transition: transform 0.5s ease;
}

.checkbox-label .label-text {
    font-size: 7px;
    color: #444;
    font-weight: bold;
    position: absolute;
    top: 48%;
    left: 75%;
    transform: translateX(-50%) translateY(-50%);
    z-index: 1; /* 文字位于小球上面 */
    user-select: none;
    transition: opacity 0.5s ease;
}

/* 默认隐藏 */
.mobile-br {
    display: none;
}

/* 暗色模式 */
body.dark {
    background-color: #121212;
    color: #e0e0e0;
}

body.dark .footer {
    background-color: rgba(31, 31, 31, 0.8);
    box-shadow: 0 -2px 5px rgba(255, 255, 255, 0.05);

    -webkit-backdrop-filter: blur(30px);
    backdrop-filter: blur(30px);
}
  
body.dark .container,
body.dark .modal-content {
    background-color: #1e1e1e;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
}

body.dark textarea,
body.dark select,
body.dark input[type="text"],
body.dark input[type="time"],
body.dark input[type="tel"] {
    background-color: #333;
    color: #e0e0e0;
    border: 1px solid #555;
}

body.dark textarea:disabled {
    background-color: #222;
    color: #888;
}

body.dark a,
body.dark .blue-span {
    color: #80bfff;
}

body.dark a:hover,
body.dark .blue-span:hover {
    color: #3399ff;
}

body.dark .footer a {
    color: #ddd;
}

body.dark .button-container a,
body.dark .button-container button,
body.dark #accessStatsTable th {
    background-color: #2d78b9;
    color: #e0e0e0;
}

body.dark .button-container a:hover,
body.dark .button-container button:hover,
body.dark #accessStatsTable th:hover {
    background-color: #1565c0;
}

body.dark input[type="submit"],
body.dark .button-container button[name="logoutbtn"],
body.dark .modal-content button {
    background-color: #ce7c00;
    color: #e0e0e0;
}

body.dark input[type="submit"]:hover,
body.dark .button-container button[name="logoutbtn"]:hover,
body.dark .modal-content button:hover {
    background-color: #ba7000;
}

body.dark #paginationContainer button {
    background-color: #1e1e1e;
    color: #aaa;
}

body.dark #paginationContainer button.active,
body.dark #paginationContainer button:hover {
    background-color: #333;
    color: #fff;
}

body.dark #logTable th, body.dark #logTable td,
body.dark #channelTable th,
body.dark #iconTable th, body.dark #iconTable td,
body.dark #channelBindEPGTable th, body.dark #channelBindEPGTable td,
body.dark #channelMatchTable th, body.dark #channelMatchTable td,
body.dark #liveSourceTable th {
    background-color: #2c2c2c;
    color: #e0e0e0;
}

body.dark .close:hover,
body.dark .close:focus {
    color: #e0e0e0;
}

body.dark img{
    filter: brightness(0.9);
}

body.dark ::-webkit-scrollbar-thumb {
    background-color: #555;
}

body.dark ::-webkit-scrollbar-thumb:hover {
    background-color: #666;
}

body.dark ::-webkit-scrollbar-track,
body.dark ::-webkit-scrollbar-corner {
    background-color: #2a2a2a;
}

body.dark .table-cell-disable {
    color: #ff7f7f;
    background-color: #4a4a32;
}

body.dark .table-cell-modified {
    color: #ff7f7f;
    background-color: #3b616b;
}

body.dark .checkbox-label i,
body.dark .checkbox-label .label-text {
    color: #eee;
}

body.dark .checkbox-label .ball {
    background-color: #222;
}

/* 移动端布局 */
@media screen and (max-width: 1100px) {

    body {
        overflow-x: hidden !important;
        max-width: 100% !important;
        display: block !important;
        padding: 10px 10px 80px;
        height: auto;
    }

    .container {
        width: 100% !important;
        max-width: 100% !important;
        padding: 15px;
        margin: 0 !important;
        box-sizing: border-box;
    }

    .form-row,
    .row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    #filteredLog,
    #execLog {
        font-size: 13px;
        width: 100% !important;
    }

    .form-row label,
    .row label {
        display: block !important;
        width: 80% !important;
        margin-bottom: 5px;
    }

    .form-row,
    .row,
    .column {
        width: 100% !important;
    }

    textarea {
        font-size: 14px !important;
        min-height: 200px !important;
    }

    input {
        font-size: 15px !important;
    }

    .button-container {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }

    .button-container-check-speed,
    .button-container-source-setting,
    .button-container-access-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .button-container button,
    .button-container a {
        width: 100% !important;
        font-size: 15px !important;
    }

    .live-source-modal-content .button-container {
        width: 100% !important;
    }

    .modal-content {
        position: fixed !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        top: calc((100dvh - 70px) / 2) !important;
        width: 95% !important;
        max-width: 95% !important;
        max-height: calc(90dvh - 50px) !important; 
        padding: 15px !important;
        box-sizing: border-box;
        overflow: auto;
    }

    .modal-inner {
        width: calc(100vw - 50px) !important;
        max-width: 100%;
    }

    .message-modal-content {
        width: auto !important;
    }

    .message-modal-content.fullsize-modal {
        width: 1000px !important;
    }

    .modal-content::-webkit-scrollbar {
        display: none;
    }

    .modal-content .table-container {
        overflow-x: auto !important;
        box-sizing: border-box;
        font-size: 13px;
    }

    .icon-modal-content table {
        min-width: 650px;
    }

    .live-source-modal-content table,
    .update-log-modal-content table {
        min-width: 900px;
    }

    #paginationContainer button {
        width: 18px;
        height: 16px;
        font-size: 13px;
    }

    h2 {
        margin-top: 5px;
    }

    .checkbox-label {
        margin-top: 5px;
        transform: scale(0.9);
    }

    .checkbox-label .label-text {
        font-size: 6px;
    }

    .form-grid-container-single-row {
        grid-template-columns: 1fr;
        justify-items: start;
    }

    .form-grid-item select,
    .modal-content select {
        height: 26px;
    }

    .form-grid-item .start-time-label {
        display: block;
    }

    .mobile-br {
        display: block;
        margin-top: 5px;
    }

    #sourceUrlTextarea {
        margin-top: 10px;
    }

    #url {
        display: block;
    }

    #interval-task-label {
        margin-left: 0px;
    }
    
    #logTable,
    #cronLogContent,
    #accessLogContent {
        font-family: monospace !important;
        font-size: 13px !important;
    }

    #cronLogContent {
        white-space: nowrap;
    }

    #donationImg {
        width: 85vw;
    }
}