/* =========================
   客戶標籤（CRM → 標籤、客戶資料卡的「標籤」欄位、新增／編輯標籤視窗）
========================= */

.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;

    max-width: 100%;
    padding: 3px 10px;

    background: #eef2ff;
    color: #3730a3;

    border: 1px solid #c7d2fe;
    border-radius: 999px;

    font-size: 13px;
    line-height: 1.5;
}

.tag-chip-name {
    overflow-wrap: anywhere;
}

.tag-chip-expiry {
    color: #6b7280;
    font-size: 12px;
}

.tag-chip-remove {
    padding: 0 4px;

    background: none;
    color: #6b7280;

    border: none;
    border-radius: 50%;

    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}

.tag-chip-remove:hover {
    background: #c7d2fe;
    color: #1e1b4b;
}

/* ===== 標籤管理頁 ===== */

.tag-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 12px 0 16px;
}

.tag-filter {
    display: flex;
    flex-direction: column;
    gap: 4px;

    font-size: 13px;
    color: #6b7280;
}

.tag-filter select,
.tag-filter input {
    padding: 8px 10px;

    background: white;
    color: #111827;

    border: 1px solid #d1d5db;
    border-radius: 8px;

    font-size: 14px;
}

.tags-table-wrap {
    overflow-x: auto;

    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
}

.tags-table {
    width: 100%;
    border-collapse: collapse;
}

.tags-table th,
.tags-table td {
    padding: 12px 14px;

    border-bottom: 1px solid #f3f4f6;

    text-align: left;
    white-space: nowrap;
}

.tags-table th {
    background: #f9fafb;
    color: #6b7280;
    font-size: 13px;
    font-weight: 600;
}

.tags-table tbody tr:last-child td {
    border-bottom: none;
}

.tags-table .tags-num {
    text-align: right;
}

.tags-actions {
    display: flex;
    gap: 8px;
}

/* ===== 客戶資料卡上的標籤欄位 ===== */

.lead-tag-field {
    margin-bottom: 8px;
}

.tag-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.tag-add-btn {
    padding: 3px 10px;

    background: white;
    color: var(--primary-color, #2563eb);

    border: 1px dashed var(--primary-color, #2563eb);
    border-radius: 999px;

    font-size: 13px;
    cursor: pointer;
}

.tag-message {
    margin-top: 6px;
    color: #b91c1c;
}

.tag-picker {
    display: flex;
    flex-direction: column;
    gap: 6px;

    margin-top: 8px;
    padding: 10px;

    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.tag-picker-label {
    font-size: 13px;
    color: #6b7280;
}

.tag-picker-options {
    display: flex;
    flex-direction: column;
    gap: 2px;

    max-height: 200px;
    overflow-y: auto;
}

.tag-picker-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;

    width: 100%;
    padding: 8px 10px;

    background: none;
    color: #111827;

    border: none;
    border-radius: 6px;

    text-align: left;
    cursor: pointer;
}

.tag-picker-option:hover {
    background: #f3f4f6;
}

.tag-picker-meta {
    color: #6b7280;
    font-size: 12px;
}

.tag-picker-create {
    color: var(--primary-color, #2563eb);
}

/* ===== 新增／編輯標籤視窗 ===== */

.tag-modal {
    display: flex;
    flex-direction: column;
    gap: 8px;

    min-width: 320px;
}

.tag-field-label {
    margin-top: 4px;
    font-size: 13px;
    color: #6b7280;
}

.tag-validity {
    display: flex;
    flex-direction: column;
    gap: 8px;

    margin: 8px 0 0;
    padding: 10px 12px;

    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.tag-validity legend {
    padding: 0 6px;
    font-size: 13px;
    color: #6b7280;
}

.tag-validity-option {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tag-validity-option input[type="number"] {
    width: 90px;
}

/* ===== 客戶列表的標籤欄 ===== */

.leads-tags-cell {
    min-width: 140px;
}

.leads-tags-cell .tag-chip {
    margin: 2px 4px 2px 0;
}
