/**
 * 商标分类选择器样式 - 独立版本
 * 不依赖于 tmfl 目录
 */

:root {
    --brand-primary: #1E80FF;
}

/* Reset & Base */
* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    padding-top: 0;
    font-size: 14px;
    background: #f4f6f8;
    line-height: 1.5715;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Microsoft YaHei", Arial, sans-serif;
    font-weight: 400;
    color: #616161;
}

a {
    color: #007bff;
    text-decoration: none;
}

a:hover,
a:focus {
    color: #0056b3;
    text-decoration: underline;
}

/* Container */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

/* Grid System */
.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -10px;
}

.col-md-2 {
    flex: 0 0 16.666667%;
    max-width: 16.666667%;
    padding: 0 10px;
}

.col-md-3 {
    flex: 0 0 25%;
    max-width: 25%;
    padding: 0 10px;
}

.col-md-7 {
    flex: 0 0 58.333333%;
    max-width: 58.333333%;
    padding: 0 10px;
}

.col-md-12 {
    flex: 0 0 100%;
    max-width: 100%;
    padding: 0 10px;
}

@media (max-width: 768px) {

    .col-md-2,
    .col-md-3,
    .col-md-7 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* Form Elements */
.form-control {
    display: block;
    width: 100%;
    padding: 8px 12px;
    font-size: 14px;
    line-height: 1.5;
    color: #495057;
    background-color: #fff;
    border: 1px solid #ced4da;
    border-radius: 4px;
    transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}

.form-control:focus {
    border-color: var(--brand-primary);
    outline: 0;
    box-shadow: 0 0 0 2px rgba(30, 128, 255, 0.25);
}

.input-group {
    display: flex;
    align-items: stretch;
}

.input-group .form-control {
    flex: 1;
    border-radius: 20px 0 0 20px;
}

.input-group-btn {
    display: flex;
}

.input-group-btn .btn {
    border-radius: 0 20px 20px 0;
}

/* Buttons */
.btn {
    display: inline-block;
    font-weight: 400;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    user-select: none;
    border: 1px solid transparent;
    padding: 8px 16px;
    font-size: 14px;
    line-height: 1.5;
    border-radius: 4px;
    transition: all .15s ease-in-out;
    cursor: pointer;
}

.btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.btn-primary {
    color: #fff;
    background-color: var(--brand-primary);
    border-color: var(--brand-primary);
}

.btn-primary:hover {
    background-color: #1a6fd6;
    border-color: #1a6fd6;
}

.btn-warning {
    color: #212529;
    background-color: #ffc107;
    border-color: #ffc107;
}

.btn-warning:hover {
    background-color: #e0a800;
    border-color: #d39e00;
}

.btn-info {
    color: #fff;
    background-color: #17a2b8;
    border-color: #17a2b8;
}

.btn-info:hover {
    background-color: #138496;
    border-color: #117a8b;
}

.btn-outline-primary {
    color: var(--brand-primary);
    border-color: var(--brand-primary);
    background-color: transparent;
}

.btn-outline-primary:hover {
    color: #fff;
    background-color: var(--brand-primary);
}

.btn-outline-danger {
    color: #dc3545;
    border-color: #dc3545;
    background-color: transparent;
}

.btn-outline-danger:hover {
    color: #fff;
    background-color: #dc3545;
}

.btn-sm {
    padding: 4px 8px;
    font-size: 12px;
}

/* Badge */
.badge {
    display: inline-block;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 10px;
}

.badge-primary {
    color: #fff;
    background-color: var(--brand-primary);
}

.badge-light {
    color: #212529;
    background-color: #f8f9fa;
}

/* Selected items modal: scope styles to this page component only.
   Avoid overriding Bootstrap modals used by shared dialogs like logout confirmation. */
#selectedModal.modal {
    display: none;
    position: fixed;
    z-index: 1050;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
}

#selectedModal.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

#selectedModal .modal-dialog {
    width: 100%;
    max-width: 800px;
    margin: 1.75rem auto;
}

#selectedModal .modal-content {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

#selectedModal .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    border-bottom: 1px solid #dee2e6;
}

#selectedModal .modal-title {
    margin: 0;
    font-size: 18px;
    font-weight: 500;
}

#selectedModal .modal-body {
    padding: 20px;
}

.tm-selector-selected-modal-body {
    max-height: 60vh;
    overflow: auto;
}

#selectedModal .modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 15px 20px;
    border-top: 1px solid #dee2e6;
}

.close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    opacity: 0.5;
}

.close:hover {
    opacity: 1;
}

/* Alert */
.alert {
    padding: 12px 20px;
    border-radius: 4px;
    margin-bottom: 15px;
}

.alert-info {
    color: #0c5460;
    background-color: #d1ecf1;
    border: 1px solid #bee5eb;
}

.tm-selector-selection-tip {
    margin-bottom: 15px;
}

.tm-selector-search-close {
    float: right;
}

body.tm-selector-modal-open {
    overflow: hidden;
}

/* ==================== TM Selector Specific Styles ==================== */

/* 已选分类按大类分组样式 */
.selected-group {
    margin-bottom: 20px;
    border: 1px solid #d9e3ef;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.05);
}

.selected-group-header {
    background: linear-gradient(180deg, #f9fbff 0%, #f4f8fc 100%);
    padding: 14px 16px;
    border-bottom: 1px solid #e6edf5;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.selected-group-title {
    font-weight: 700;
    font-size: 15px;
    color: #24324a;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.selected-group-title .main-class-code {
    color: var(--brand-primary);
    margin-right: 0;
}

.selected-group-title .badge-orange {
    background-color: #ff9800;
    color: white;
    margin-left: 0;
    margin-right: 0;
    min-width: 24px;
    line-height: 20px;
    text-align: center;
    border-radius: 999px;
}

.selected-group-title .btn {
    padding: 4px 10px;
    font-size: 12px;
}

.selected-group-actions {
    display: flex;
    gap: 5px;
}

.selected-group-actions .btn {
    padding: 4px 10px;
    font-size: 12px;
}

.copy-group-btn {
    background-color: #8bc34a !important;
    border-color: #8bc34a !important;
    color: white !important;
}

.copy-group-btn:hover {
    background-color: #7cb342 !important;
    border-color: #7cb342 !important;
}

.delete-group-btn {
    background-color: #f44336 !important;
    border-color: #f44336 !important;
    color: white !important;
}

.delete-group-btn:hover {
    background-color: #d32f2f !important;
    border-color: #d32f2f !important;
}

.selected-group-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #fff;
}

.selected-similar-row {
    display: grid;
    grid-template-columns: 54px minmax(0, 1fr);
    align-items: start;
    column-gap: 12px;
    row-gap: 8px;
}

.selected-similar-code {
    flex: 0 0 54px;
    padding-top: 7px;
    font-size: 15px;
    font-weight: 700;
    line-height: 1;
    color: #3d4b63;
    letter-spacing: 0.02em;
}

.selected-similar-items {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.selected-group-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 7px 10px 7px 12px;
    background: #fff;
    color: #1f2937;
    border: 1px solid #d5deea;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.35;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    max-width: 100%;
}

.selected-group-item:hover {
    border-color: #b8c7db;
}

.selected-group-item-remark {
    background: #fff7ed;
    border-color: #fed7aa;
    color: #9a3412;
}

.selected-group-item .item-remove {
    position: static;
    cursor: pointer;
    opacity: 1;
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    font-size: 11px;
    color: #8a97a8;
    background: #f3f6fa;
    flex: 0 0 auto;
    transition: color 0.2s ease, background-color 0.2s ease;
}

.selected-group-item .item-remove:hover {
    color: #dc3545;
    background: #ffe9ec;
}

@media (max-width: 768px) {
    .selected-group-header {
        padding: 12px 14px;
    }

    .selected-group-title {
        gap: 6px;
    }

    .selected-group-body {
        padding: 14px;
        gap: 10px;
    }

    .selected-similar-row {
        grid-template-columns: 48px minmax(0, 1fr);
        column-gap: 10px;
        row-gap: 6px;
    }

    .selected-similar-code {
        flex: none;
        padding-top: 6px;
        font-size: 14px;
    }
}

/* Header */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 0;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header h1 {
    margin: 0;
    font-size: 24px;
    font-weight: bold;
}

.header p {
    margin: 5px 0 0 0;
    opacity: 0.9;
    font-size: 14px;
}

.tm-selector-page .header {
    position: relative;
    margin-top: 0;
    display: none !important;
}

body.tm-selector-page {
    color: var(--text-color);
    background: #f8fafc;
}

body.tm-selector-page > .navbar,
body.tm-selector-page > .footer {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body.tm-selector-page > .navbar .nav-link,
body.tm-selector-page > .navbar #authLinks,
body.tm-selector-page > .navbar #authLinks .nav-link,
body.tm-selector-page > .navbar .dropdown-menu {
    font-size: 16px;
}

body.tm-selector-page > .navbar .container,
body.tm-selector-page > .footer .container {
    width: 100%;
    max-width: 1320px;
    padding-left: calc(var(--bs-gutter-x, 1.5rem) * 0.5);
    padding-right: calc(var(--bs-gutter-x, 1.5rem) * 0.5);
}

body.tm-selector-page > .navbar a,
body.tm-selector-page > .footer a {
    text-decoration: none;
}

body.tm-selector-page > .navbar .nav-link:hover,
body.tm-selector-page > .navbar .nav-link:focus,
body.tm-selector-page > .footer a:hover {
    text-decoration: none;
}

body.tm-selector-page > .footer {
    background-color: #212529;
    color: rgba(255, 255, 255, 0.7);
    padding: 70px 0 30px;
    margin-top: 80px;
}

body.tm-selector-page > .footer .row {
    display: flex;
    flex-wrap: wrap;
    margin-left: calc(var(--bs-gutter-x, 1.5rem) * -0.5);
    margin-right: calc(var(--bs-gutter-x, 1.5rem) * -0.5);
}

body.tm-selector-page > .footer [class*="col-"] {
    padding-left: calc(var(--bs-gutter-x, 1.5rem) * 0.5);
    padding-right: calc(var(--bs-gutter-x, 1.5rem) * 0.5);
}

.tm-selector-page > .container {
    margin-top: 1.5rem;
}

/* Search Box */
.search-box {
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.search-box input {
    border-radius: 20px;
    padding: 10px 20px;
    height: 44px;
}

.search-box .btn {
    border-radius: 20px;
    padding: 10px 30px;
    height: 44px;
}

/* Panel */
.selection-panel {
    position: relative;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.panel-header {
    background: #f8f9fa;
    padding: 15px 20px;
    border-bottom: 1px solid #dee2e6;
    border-radius: 8px 8px 0 0;
    font-weight: bold;
    color: #333;
}

.panel-body {
    padding: 20px;
    max-height: none;
    overflow: visible;
}

/* Class Item */
.class-item {
    display: block;
    margin: 8px 5px;
    padding: 10px 15px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

.class-item:hover {
    background: #e9ecef;
    border-color: #adb5bd;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.class-item.active {
    background: #e8f5e9;
    border-color: var(--brand-primary);
}

.class-item.active .item-header {
    color: var(--brand-primary);
}

.class-item .item-header {
    display: flex;
    align-items: center;
}

.class-item .code {
    display: inline-block;
    min-width: 32px;
    font-weight: bold;
    margin-right: 10px;
    color: #666;
}

.class-item .name {
    flex: 1;
    color: #333;
}

/* 非规范商品项样式 */
.class-item .item-remark {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed #dee2e6;
    font-size: 12px;
    line-height: 1.6;
}

.class-item .remark-label {
    color: #ff6b6b;
    font-weight: bold;
    margin-right: 5px;
}

.class-item .remark-text {
    color: #666;
}

.class-item.active .item-remark {
    border-top-color: var(--brand-primary);
}

/* Selected List */
.selected-list {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 20px;
}

.selected-item {
    padding: 10px 15px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.selected-item:last-child {
    border-bottom: none;
}

.selected-item .remove-btn {
    color: #dc3545;
    cursor: pointer;
    font-size: 18px;
}

.selected-item .remove-btn:hover {
    color: #c82333;
}

/* Action Buttons */
.action-buttons {
    padding: 15px 20px;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
    border-radius: 0 0 8px 8px;
}

.action-buttons .btn {
    margin-right: 10px;
}

/* Empty Tip */
.empty-tip {
    text-align: center;
    padding: 40px 20px;
    color: #999;
}

.empty-tip i {
    font-size: 48px;
    margin-bottom: 15px;
    display: block;
}

/* Search Results */
.search-results {
    display: none;
}

.search-results.show {
    display: block;
}

#searchResultsBody {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

#searchResultsBody .empty-tip {
    grid-column: 1 / -1;
}

.search-result-item {
    padding: 12px 15px;
    border: 1px solid #e7ebf0;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.search-result-item:hover {
    background-color: #f8f9fa;
    border-color: #cfd8e3;
    box-shadow: 0 2px 8px rgba(30, 128, 255, 0.08);
}

.search-result-item.active {
    background-color: #eaf3ff;
    border-left: 3px solid var(--brand-primary);
    padding-left: 12px;
}

.search-result-item.active:hover {
    background-color: #eaf3ff;
}

.search-result-item.active .name {
    color: #0b57d0;
    font-weight: 600;
}

.search-result-item .badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 11px;
    background-color: var(--brand-primary);
    color: white;
    border-radius: 10px;
    margin-right: 8px;
}

.search-result-item .group-code {
    display: inline-block;
    min-width: 40px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 700;
    color: #4f5d75;
    background: #eef2f7;
    border-radius: 10px;
    margin-right: 8px;
    text-align: center;
}

.search-result-item .code {
    font-weight: bold;
    color: var(--brand-primary);
    margin-right: 8px;
}

.search-result-item .name {
    color: #333;
}

/* 搜索结果中的非规范商品项 */
.search-result-item .search-remark {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px dashed #dee2e6;
    font-size: 12px;
    line-height: 1.6;
}

.search-result-item .search-remark .remark-label {
    color: #ff6b6b;
    font-weight: bold;
    margin-right: 5px;
}

.search-result-item .search-remark .remark-text {
    color: #666;
}

/* 非规范商品项样式 */
.class-item.remark-item {
    background-color: #fff9f0;
    border-left: 3px solid #ff9800;
}

.class-item.remark-item:hover {
    background-color: #fff3e0;
}

.class-item.remark-item.active {
    background-color: #ffe0b2;
    border-left-color: #f57c00;
}

.class-item .badge-remark {
    display: inline-block;
    padding: 2px 6px;
    font-size: 11px;
    background-color: #ff9800;
    color: white;
    border-radius: 3px;
    margin-right: 8px;
}

.class-item .remark-name {
    color: #e65100;
    font-weight: 500;
}

/* 搜索结果中的非规范商品项 */
.search-result-item.remark-item {
    background-color: #fff9f0;
    border-left: 3px solid #ff9800;
}

.search-result-item.remark-item:hover {
    background-color: #fff3e0;
}

.search-result-item.remark-item.active {
    background-color: #ffe0b2;
    border-left-color: #f57c00;
}

.search-result-item .badge-remark {
    background-color: #ff9800;
}

.search-result-item .remark-name {
    color: #e65100;
    font-weight: 500;
}

@media (max-width: 1200px) {
    #searchResultsBody {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    #searchResultsBody {
        grid-template-columns: 1fr;
    }
}

.badge-level {
    font-size: 11px;
    padding: 2px 6px;
    margin-left: 5px;
}

/* 顶部大类横排样式 */
.top-class-bar {
    background: #fff;
    padding: 12px 15px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    margin-bottom: 15px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    flex-wrap: wrap;
}

.top-class-title {
    font-weight: bold;
    white-space: nowrap;
}

.top-class-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.top-class-item {
    display: inline-block;
    width: 100px;
    padding: 6px 10px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 16px;
    cursor: pointer;
    transition: all .2s;
    position: relative;
    text-align: center;
    box-sizing: border-box;
}

.top-class-item:hover {
    background: #eef2ff;
}

.top-class-item.active {
    background: var(--brand-primary);
    color: #fff;
    border-color: var(--brand-primary);
}

/* 左侧大类垂直列表样式 */
#sideMainClassList {
    max-height: none;
    overflow: visible;
}

.side-class-item {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    position: relative;
}

.side-class-item .code {
    font-weight: bold;
    margin-right: 6px;
}

/* 类似群每行一项，全部显示 */
#groupList .class-item {
    display: block;
    width: 100%;
    margin: 6px 0;
    position: relative;
}

/* 商品/服务：一行显示 3 个 */
#itemList {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

#itemList .class-item {
    margin: 0;
}

#itemList .empty-tip {
    grid-column: 1 / -1;
}

@media (max-width: 992px) {
    #itemList {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 576px) {
    #itemList {
        grid-template-columns: 1fr;
    }
}

.side-class-item.active {
    background: var(--brand-primary);
    color: #fff;
    font-weight: bold;
}

/* 数字统计徽章样式 */
.count-badge {
    display: inline-block;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    margin-left: 6px;
    background: #ff4444;
    color: white;
    font-size: 11px;
    font-weight: bold;
    line-height: 18px;
    text-align: center;
    border-radius: 9px;
    vertical-align: middle;
}

.top-class-item .count-badge,
.side-class-item .count-badge,
#groupList .class-item .count-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    font-size: 10px;
    border-radius: 8px;
    padding: 0 4px;
    margin-left: 0;
    z-index: 10;
}

/* 响应式 */
@media (max-width: 768px) {
    .header h1 {
        font-size: 20px;
    }

    .selected-list {
        position: static;
        margin-top: 20px;
    }

    .class-item {
        font-size: 13px;
        padding: 6px 12px;
    }
}

/* 悬浮已选按钮 */
.fab {
    position: fixed;
    bottom: 150px;
    z-index: 1050;
}

.fab .btn {
    border-radius: 24px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, .2);
    background-color: var(--brand-primary);
    border-color: var(--brand-primary);
}

.fab .badge {
    margin-left: 8px;
}

/* 底部版权信息 */
.footer {
    background: #2c3e50;
    color: #ecf0f1;
    padding: 30px 0 20px;
    margin-top: 60px;
}

.footer-content {
    text-align: center;
}

.footer-copyright {
    font-size: 14px;
    margin-bottom: 10px;
}

.footer-beian {
    font-size: 13px;
    color: #bdc3c7;
}

.footer-beian a {
    color: #bdc3c7;
    text-decoration: none;
    margin: 0 10px;
}

.footer-beian a:hover {
    color: #ecf0f1;
    text-decoration: underline;
}

/* Layer.js z-index override - ensure layer dialogs appear above our modal */
.layui-layer {
    z-index: 20000000 !important;
}

.layui-layer-shade {
    z-index: 19999999 !important;
}
