/* 使用 Bootstrap 变量以支持深色模式 */
body { 
    background-color: var(--bs-body-bg); 
}

[data-bs-theme="light"] body {
    background-color: #f8f9fa;
}

.login-container { 
    max-width: 400px; 
    margin: 100px auto; 
    padding: 20px; 
    background: var(--bs-tertiary-bg); 
    border-radius: 8px; 
    box-shadow: 0 0 10px rgba(0,0,0,0.1); 
    border: 1px solid var(--bs-border-color);
}

.dashboard-container { 
    max-width: 1100px; 
    margin: 15px auto; 
    display: none; 
}

.toast-container { 
    position: fixed; 
    top: 20px; 
    right: 20px; 
    z-index: 1050; 
}

.api-label-container {
    display: inline-flex;
    align-items: center;
    padding-left: 10px;
    border-left: 5px solid #198754; 
}

.row-deleted {
    background-color: #f8d7da !important;
    opacity: 0.8;
}
.row-deleted td {
    text-decoration: line-through;
    color: #842029;
}

[data-bs-theme="dark"] .row-deleted {
    background-color: #441217 !important;
}
[data-bs-theme="dark"] .row-deleted td {
    color: #ea868f; 
}

.row-deleted .btn-group button {
    text-decoration: none; 
}

.modal-footer .btn {
    min-width: 100px;
}

/* Tooltip 宽度优化 */
.tooltip-inner {
    max-width: 450px !important;
    text-align: left;
    padding: 8px 12px;
}

thead {
    background-color: var(--bs-tertiary-bg);
}
[data-bs-theme="light"] thead {
    background-color: #f1f3f5;
}
/* SVG 图标统一样式 */
.icon {
    width: 1.2em;
    height: 1.2em;
    vertical-align: -0.2em;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* 按钮内图标间距 */
.btn .icon {
    margin-right: 4px;
}

/* 拖拽手柄样式 */
.drag-handle {
    cursor: grab;
    color: var(--bs-secondary-color);
    margin-right: 8px;
}
.drag-handle:active {
    cursor: grabbing;
}

/* PC端源地址列限制 */
.col-url {
    max-width: 250px;
}
.col-url div {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 禁止拉伸源地址输入框 */
/* 标签样式 */
.tag-badge {
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    font-weight: 500;
    padding: 0.4em 0.8em;
    color: white !important; /* 强制白字以适配深色背景 */
    opacity: 0.9;
}
.tag-badge:hover {
    opacity: 1;
    transform: scale(1.05);
}
.tag-badge.active {
    box-shadow: 0 0 0 2px var(--bs-body-color); /* 选中时加个对比色边框 */
}

/* 筛选栏滚动 */
.filter-bar {
    display: flex;
    align-items: center; /* 垂直居中 */
    overflow-x: auto;
    white-space: nowrap;
    gap: 8px;
    padding: 10px 0; /* 增加上下高度 */
    min-height: 50px;
    -webkit-overflow-scrolling: touch;
}
.filter-bar .filter-label {
    flex-shrink: 0;
    font-weight: bold;
    margin-right: 8px;
    display: flex;
    align-items: center;
    color: var(--bs-secondary-color);
}
.filter-bar::-webkit-scrollbar {
    height: 4px;
}
.filter-bar::-webkit-scrollbar-thumb {
    background: var(--bs-border-color);
    border-radius: 4px;
}

/* 弹窗内的标签编辑器 */
.tag-editor {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    min-height: 40px;
    padding: 8px;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    background: var(--bs-tertiary-bg);
}

.tag-capsule {
    display: inline-flex;
    align-items: center;
    background: var(--bs-secondary); /* 默认，会被JS覆盖 */
    color: white;
    border-radius: 50px;
    padding: 3px 10px;
    font-size: 0.85rem;
    transition: transform 0.1s;
}

.tag-remove {
    margin-left: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    opacity: 0.7;
}
.tag-remove:hover {
    opacity: 1;
}

.btn-add-tag {
    width: 28px;
    height: 28px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

/* 行内标签输入框 */
.tag-input {
    width: 80px;
    padding: 2px 8px;
    font-size: 0.85rem;
    border: 1px solid var(--bs-primary);
    border-radius: 50px;
    outline: none;
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    display: none; /* 默认隐藏 */
}

/* 行内标签展示 */
.list-tag {
    font-size: 0.75rem;
    padding: 0.2em 0.6em;
    margin-left: 5px;
    opacity: 0.85;
    cursor: pointer;
    color: white;
    transition: transform 0.1s;
}
.list-tag:hover {
    opacity: 1;
    transform: scale(1.1);
}

#input-url { 
    resize: none; 
}

.app-footer {
    text-align: center;
    padding: 0.5rem 0;
    font-size: 0.8rem;
    color: var(--bs-tertiary-color);
    background-color: transparent;
    margin-top: auto;
}

#btn-back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 45px;
    height: 45px;
    display: none; /* 默认隐藏 */
    z-index: 2000; /* 提高层级 */
    opacity: 0.8;
    transition: opacity 0.3s;
}

#btn-back-to-top:hover {
    opacity: 1;
}

/* 拖拽时的幽灵样式 */
.sortable-ghost {
    background-color: var(--bs-secondary-bg) !important;
    opacity: 0.5;
}

/* 手机端专用图标 */
.mobile-icon {
    display: none;
}

/* 移动端间隙优化 */
@media (max-width: 767.98px) {
    .dashboard-container {
        margin: 20px auto !important;
        padding: 0 15px !important;
    }
}

/* --- 移动端卡片化布局 --- */
@media (max-width: 767.98px) {
    #iptv-list-table thead {
        display: none;
    }
    
    #iptv-list-table, 
    #iptv-list-table tbody, 
    #iptv-list-table tr, 
    #iptv-list-table td {
        display: block;
        width: 100%;
    }

    #iptv-list-table tr {
        background-color: var(--bs-body-bg);
        border: 1px solid var(--bs-border-color);
        border-radius: 8px;
        margin-bottom: 12px;
        padding: 12px 40px 12px 12px;
        position: relative;
        box-shadow: 0 1px 3px rgba(0,0,0,0.05);
        -webkit-user-select: none;
        user-select: none;
        transition: background-color 0.2s;
    }
    
    #iptv-list-table tr:active {
        background-color: var(--bs-tertiary-bg);
    }

    .mobile-icon {
        display: inline;
        margin-right: 4px;
    }

    #iptv-list-table td:nth-child(1) {
        position: absolute;
        top: 0;
        right: 0;
        width: 40px;
        height: 100%;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: none;
    }
    #iptv-list-table td:nth-child(1) .drag-handle {
        font-size: 1.4rem;
        margin: 0;
        color: var(--bs-secondary-color);
        opacity: 0.5;
    }

    #iptv-list-table td:nth-child(2),
    #iptv-list-table td:nth-child(6) {
        display: none;
    }

    #iptv-list-table td:nth-child(3) {
        font-size: 1.1rem;
        font-weight: bold;
        color: var(--bs-emphasis-color);
        padding: 0 0 6px 0;
        border: none;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    #iptv-list-table td:nth-child(4) {
        max-width: 100% !important;
        font-size: 0.9rem;
        color: var(--bs-secondary-color);
        padding: 0 0 6px 0;
        border: none;
        display: flex;
        align-items: center;
    }
    #iptv-list-table td:nth-child(4)::before {
        content: "源地址: ";
        font-weight: bold;
        margin-right: 6px;
        flex-shrink: 0;
        opacity: 0.7;
    }
    #iptv-list-table td:nth-child(4) div {
        flex-grow: 1;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    #iptv-list-table td:nth-child(5) {
        font-size: 0.85rem;
        color: var(--bs-tertiary-color);
        padding: 0;
        border: none;
        display: block;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    #iptv-list-table td:nth-child(5)::before {
        content: "备注: ";
        font-weight: bold;
        margin-right: 6px;
        opacity: 0.7;
    }
}