* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    height: 100%;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    background: #f0f2f5;
    color: #1c1e21;
}

h1:focus {
    outline: none;
}

/* ===== Layout inbox 2 cột ===== */
.inbox {
    display: flex;
    height: 100vh;
}

.conversation-list {
    width: 340px;
    min-width: 280px;
    background: #fff;
    border-right: 1px solid #e4e6eb;
    display: flex;
    flex-direction: column;
}

.list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid #e4e6eb;
}

.list-header h1 {
    font-size: 1.3rem;
    margin: 0;
    color: #0068ff;
}

.header-links {
    display: flex;
    gap: 12px;
}

.simulator-link {
    font-size: 0.85rem;
    color: #65676b;
    text-decoration: none;
}

.simulator-link:hover {
    color: #0068ff;
}

/* Bộ lọc kênh */
.channel-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 12px;
    border-bottom: 1px solid #e4e6eb;
}

.filter {
    border: 1px solid #d0d2d7;
    background: #fff;
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 0.82rem;
    cursor: pointer;
    color: #444;
}

.filter.active {
    background: #0068ff;
    border-color: #0068ff;
    color: #fff;
}

.empty-list {
    padding: 24px 16px;
    color: #65676b;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Danh sách hội thoại */
.items {
    overflow-y: auto;
    flex: 1;
}

.item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f0f2f5;
}

.item:hover {
    background: #f5f6f7;
}

.item.selected {
    background: #e7f0ff;
}

.channel-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.item-body {
    flex: 1;
    min-width: 0;
}

.item-top, .item-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.name {
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.time {
    font-size: 0.75rem;
    color: #8a8d91;
    flex-shrink: 0;
}

.preview {
    font-size: 0.85rem;
    color: #65676b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.unread {
    background: #e41e3f;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    border-radius: 999px;
    min-width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    flex-shrink: 0;
}

/* Thẻ trạng thái hội thoại */
.tag {
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 999px;
    padding: 2px 8px;
    white-space: nowrap;
    flex-shrink: 0;
}

.tag-blue { background: #e7f0ff; color: #0053cc; }
.tag-orange { background: #fff3e0; color: #b25e00; }
.tag-green { background: #e6f4ea; color: #1a7f37; }
.tag-gray { background: #f0f2f5; color: #65676b; }

.tag-select {
    border: 1px solid #d0d2d7;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 0.8rem;
    font-family: inherit;
    background: #fff;
    cursor: pointer;
}

.tag-select.tag-blue { background: #e7f0ff; color: #0053cc; border-color: #b3d1ff; }
.tag-select.tag-orange { background: #fff3e0; color: #b25e00; border-color: #ffd699; }
.tag-select.tag-green { background: #e6f4ea; color: #1a7f37; border-color: #b7e1c3; }
.tag-select.tag-gray { background: #f0f2f5; color: #65676b; border-color: #d0d2d7; }

.trello-btn {
    border: 1px solid #0079bf;
    background: #fff;
    color: #0079bf;
    border-radius: 8px;
    padding: 4px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.trello-btn:hover {
    background: #e7f3f9;
}

.trello-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

.trello-note {
    font-size: 0.8rem;
    color: #1a7f37;
}

.trello-note a {
    color: #0079bf;
}

.trello-note.error {
    color: #b3261e;
}

/* Màu nhận diện từng kênh */
.ch-zalo { background: #0068ff; }
.ch-messenger { background: #a334fa; }
.ch-shopee { background: #ee4d2d; }
.ch-tiktok { background: #161823; }

/* ===== Khung chat ===== */
.chat-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.no-selection {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #8a8d91;
    font-size: 1.05rem;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    background: #fff;
    border-bottom: 1px solid #e4e6eb;
}

.channel-badge {
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 4px;
    padding: 3px 8px;
}

.chat-name {
    font-weight: 600;
    font-size: 1.05rem;
}

.not-configured {
    margin-left: auto;
    font-size: 0.78rem;
    color: #b8860b;
    background: #fff8e1;
    border: 1px solid #f0e0a0;
    border-radius: 4px;
    padding: 3px 8px;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bubble-row {
    display: flex;
}

.bubble-row.out {
    justify-content: flex-end;
}

.bubble {
    max-width: 65%;
    background: #fff;
    border-radius: 16px;
    padding: 9px 13px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
}

.bubble-row.out .bubble {
    background: #0068ff;
    color: #fff;
}

.bubble-text {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.94rem;
    line-height: 1.4;
}

.bubble-meta {
    font-size: 0.7rem;
    margin-top: 4px;
    opacity: 0.7;
    display: flex;
    gap: 8px;
}

.status.failed {
    color: #ffd0d0;
    font-weight: 600;
}

.bubble-row.in .status.failed {
    color: #e41e3f;
}

.status.simulated {
    font-style: italic;
}

.bubble-img {
    max-width: 240px;
    max-height: 240px;
    border-radius: 10px;
    display: block;
    margin-bottom: 4px;
}

/* ===== Cột phải: khách hàng + lịch sử đặt hàng ===== */
.customer-panel {
    width: 290px;
    min-width: 250px;
    background: #fff;
    border-left: 1px solid #e4e6eb;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.panel-section {
    padding: 16px 18px;
    border-bottom: 1px solid #f0f2f5;
}

.panel-section h3 {
    margin: 0 0 10px;
    font-size: 0.88rem;
    color: #65676b;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.panel-customer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.panel-name {
    font-weight: 700;
    font-size: 1.02rem;
    width: 100%;
}

.order-count {
    background: #e7f0ff;
    color: #0053cc;
    border-radius: 999px;
    padding: 1px 8px;
    font-size: 0.75rem;
}

.panel-empty {
    color: #8a8d91;
    font-size: 0.84rem;
    line-height: 1.5;
    margin: 0;
}

.orders-section {
    flex: 1;
}

.order-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.order-item {
    background: #f7f8fa;
    border: 1px solid #e4e6eb;
    border-radius: 10px;
    padding: 10px 12px;
}

.order-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}

.order-title {
    font-weight: 600;
    font-size: 0.9rem;
}

.order-amount {
    color: #1a7f37;
    font-weight: 700;
    font-size: 0.88rem;
    white-space: nowrap;
}

.order-meta {
    font-size: 0.76rem;
    color: #8a8d91;
    margin-top: 3px;
    display: flex;
    gap: 10px;
}

.order-meta a {
    color: #0079bf;
    text-decoration: none;
}

.order-note {
    font-size: 0.82rem;
    color: #444;
    margin-top: 4px;
}

.add-order {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.add-order input {
    border: 1px solid #d0d2d7;
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 0.86rem;
    font-family: inherit;
}

.add-order button {
    background: #0068ff;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px;
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
}

.add-order button:disabled {
    background: #a8c6f5;
    cursor: default;
}

/* ===== Popup xem trước thẻ Trello ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal {
    background: #fff;
    border-radius: 14px;
    padding: 22px 26px;
    width: min(560px, 92vw);
    max-height: 88vh;
    overflow-y: auto;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

.modal h2 {
    margin: 0 0 14px;
    font-size: 1.15rem;
}

.modal-label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-weight: 600;
    font-size: 0.86rem;
    margin-bottom: 12px;
}

.modal-label input,
.modal-label textarea {
    border: 1px solid #d0d2d7;
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 0.9rem;
    font-family: inherit;
    font-weight: 400;
    resize: vertical;
}

.modal-error {
    color: #b3261e;
    font-size: 0.86rem;
    background: #fdecea;
    border-radius: 8px;
    padding: 8px 12px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 6px;
}

.modal-cancel {
    background: #e4e6eb;
    color: #1c1e21;
    border: none;
    border-radius: 8px;
    padding: 9px 18px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.modal-create {
    background: #0079bf;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 9px 18px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.modal-create:disabled, .modal-cancel:disabled {
    opacity: 0.6;
    cursor: default;
}

/* Nút đính kèm ảnh */
.attach-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 52px;
    font-size: 1.25rem;
    cursor: pointer;
    border: 1px solid #d0d2d7;
    border-radius: 10px;
    background: #fff;
    flex-shrink: 0;
}

.attach-btn:hover {
    background: #f0f2f5;
}

.attach-btn input[type="file"] {
    display: none;
}

/* Ô soạn tin */
.composer {
    display: flex;
    gap: 10px;
    padding: 12px 18px;
    background: #fff;
    border-top: 1px solid #e4e6eb;
}

.composer textarea {
    flex: 1;
    resize: none;
    height: 52px;
    border: 1px solid #d0d2d7;
    border-radius: 10px;
    padding: 10px 12px;
    font-family: inherit;
    font-size: 0.94rem;
}

.composer textarea:focus {
    outline: 2px solid #0068ff;
    border-color: transparent;
}

.composer button {
    background: #0068ff;
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 0 22px;
    font-weight: 600;
    cursor: pointer;
}

.composer button:disabled {
    background: #a8c6f5;
    cursor: default;
}

/* ===== Trang giả lập ===== */
.simulator {
    max-width: 560px;
    margin: 40px auto;
    background: #fff;
    border-radius: 12px;
    padding: 28px 32px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.simulator h1 {
    margin-top: 0;
    font-size: 1.4rem;
}

.simulator .hint {
    color: #65676b;
    font-size: 0.9rem;
    line-height: 1.5;
}

.sim-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 20px;
}

.sim-form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-weight: 600;
    font-size: 0.9rem;
}

.sim-form input, .sim-form select, .sim-form textarea {
    border: 1px solid #d0d2d7;
    border-radius: 8px;
    padding: 9px 12px;
    font-family: inherit;
    font-size: 0.94rem;
    font-weight: 400;
}

.sim-form textarea {
    min-height: 80px;
    resize: vertical;
}

.sim-form button {
    background: #0068ff;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 11px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
}

.sim-form button:disabled {
    background: #a8c6f5;
    cursor: default;
}

.sent-note {
    color: #1a7f37;
    font-size: 0.9rem;
    margin: 0;
}

/* ===== Trang cấu hình kênh ===== */
.settings {
    max-width: 720px;
    margin: 32px auto;
    padding: 0 16px 48px;
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.settings-header h1 {
    font-size: 1.45rem;
}

.settings-header a {
    color: #0068ff;
    text-decoration: none;
    font-size: 0.92rem;
}

.settings-hint {
    color: #65676b;
    font-size: 0.9rem;
    line-height: 1.55;
}

.banner {
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 0.92rem;
    margin-bottom: 14px;
}

.banner-ok {
    background: #e6f4ea;
    color: #1a7f37;
    border: 1px solid #b7e1c3;
}

.banner-error {
    background: #fdecea;
    color: #b3261e;
    border: 1px solid #f5c6c2;
}

.channel-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px 24px;
    margin-bottom: 18px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.channel-card header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.channel-card h2 {
    font-size: 1.08rem;
    margin: 0;
}

.status-badge {
    font-size: 0.78rem;
    border-radius: 999px;
    padding: 3px 10px;
    margin-left: auto;
}

.status-badge.connected {
    background: #e6f4ea;
    color: #1a7f37;
}

.status-badge.connected em {
    font-style: normal;
    opacity: 0.75;
}

.status-badge.disconnected {
    background: #f0f2f5;
    color: #65676b;
}

.guide {
    background: #f7f8fa;
    border: 1px solid #e4e6eb;
    border-radius: 8px;
    padding: 9px 14px;
    margin-bottom: 14px;
    font-size: 0.86rem;
}

.guide summary {
    cursor: pointer;
    font-weight: 600;
    color: #0068ff;
    user-select: none;
}

.guide ol {
    margin: 10px 0 4px;
    padding-left: 20px;
    line-height: 1.65;
    color: #3a3b3c;
}

.guide li {
    margin-bottom: 4px;
}

.guide a {
    color: #0068ff;
}

.guide code {
    background: #eceef1;
    border-radius: 4px;
    padding: 1px 5px;
}

.channel-card .fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.channel-card .fields label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 0.85rem;
    font-weight: 600;
}

.channel-card .fields input {
    border: 1px solid #d0d2d7;
    border-radius: 8px;
    padding: 8px 11px;
    font-size: 0.9rem;
    font-weight: 400;
    font-family: inherit;
}

.channel-card .urls {
    margin-top: 12px;
    font-size: 0.82rem;
    color: #65676b;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.channel-card .urls code {
    background: #f0f2f5;
    border-radius: 4px;
    padding: 2px 7px;
    user-select: all;
    color: #1c1e21;
}

.channel-card .actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.btn-save, .btn-connect, .btn-disconnect, .btn-sync {
    border: none;
    border-radius: 8px;
    padding: 8px 18px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
}

.btn-save {
    background: #e4e6eb;
    color: #1c1e21;
}

.btn-connect {
    background: #0068ff;
    color: #fff;
    display: inline-flex;
    align-items: center;
}

.btn-disconnect {
    background: #fff;
    color: #b3261e;
    border: 1px solid #f5c6c2;
}

.btn-sync {
    background: #fff;
    color: #0068ff;
    border: 1px solid #0068ff;
}

.btn-sync:disabled {
    opacity: 0.6;
    cursor: default;
}

.settings-note {
    color: #8a6d1a;
    background: #fff8e1;
    border: 1px solid #f0e0a0;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 0.86rem;
    line-height: 1.5;
}

/* ===== Mặc định của template ===== */
.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #b32121;
    color: #fff;
    padding: 0.7rem 1rem;
    z-index: 1000;
}

#blazor-error-ui .reload {
    color: #fff;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    float: right;
}
