/* ===== SMP CRM — Customer & Order Styles ===== */

/* ── CRM sidebar panel ── */
.smp-crm-panel {
    width: 380px;
    flex-shrink: 0;
    border-left: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    background: #fff;
    overflow-y: auto;
}
.smp-crm-tabs {
    display: flex;
    border-bottom: 2px solid #e2e8f0;
    background: #f8fafc;
    flex-shrink: 0;
}
.smp-crm-tab {
    flex: 1;
    padding: 10px 6px;
    text-align: center;
    font-size: .75rem;
    font-weight: 600;
    cursor: pointer;
    color: #64748b;
    border: none;
    background: transparent;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all .15s;
}
.smp-crm-tab.is-active {
    color: var(--smp-primary, #2563eb);
    border-bottom-color: var(--smp-primary, #2563eb);
    background: #fff;
}
.smp-crm-tab-content { display: none; padding: 12px; }
.smp-crm-tab-content.is-active { display: block; }

/* ── Customer fields ── */
.smp-crm-fields { display: flex; flex-direction: column; gap: 8px; }
.smp-cf-row { display: flex; flex-direction: column; gap: 3px; }
.smp-cf-label { font-size: .75rem; font-weight: 600; color: #475569; }
.smp-req { color: #dc2626; margin-left: 2px; }
.smp-cf-actions {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid #e2e8f0;
}
.smp-cf-msg { font-size: .8rem; }
.smp-btn-sm { padding: 6px 14px !important; font-size: .8rem !important; }

/* ── Order table ── */
.smp-order-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.smp-order-search { position: relative; margin-bottom: 8px; }
.smp-order-search .smp-input { width: 100%; box-sizing: border-box; font-size: .85rem; }
.smp-product-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,.1);
    z-index: 100;
    max-height: 240px;
    overflow-y: auto;
}
.smp-product-option:hover { background: #f1f5f9; }
.smp-order-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .8rem;
}
.smp-order-table th {
    background: #f8fafc;
    padding: 8px 6px;
    text-align: left;
    font-size: .72rem;
    color: #64748b;
    border-bottom: 1px solid #e2e8f0;
    white-space: nowrap;
}
.smp-order-table td {
    padding: 6px 5px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}
.smp-order-table tfoot td {
    padding: 5px 5px;
    font-size: .82rem;
}
.smp-order-table .smp-input {
    padding: 4px 7px;
    font-size: .8rem;
    border-radius: 5px;
}

/* ── Add customer button in inbox ── */
.smp-add-customer-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: .75rem;
    background: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: background .15s;
}
.smp-add-customer-btn:hover { background: #dbeafe; }

/* ── Inbox layout with CRM panel ── */
.smp-inbox-layout-3col {
    display: grid;
    grid-template-columns: 280px 1fr 380px;
    gap: 0;
    height: calc(100vh - 120px);
    min-height: 500px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,.1);
}
.smp-inbox-layout-3col .smp-chat-main {
    border-left: 1px solid #e2e8f0;
    border-right: 1px solid #e2e8f0;
}

/* Hide CRM panel khi chưa có conv */
#smpCrmPanel { border-left: 1px solid #e2e8f0; }
#smpCrmPanel .smp-crm-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: #94a3b8;
    font-size: .85rem;
    text-align: center;
}

/* ── Product page form discount codes ── */
.smp-dc-row input, .smp-dc-row select {
    font-size: .8rem !important;
    padding: 5px 8px !important;
}

/* ── Responsive ── */
@media (max-width: 1500px) {
    .smp-inbox-layout-3col {
        grid-template-columns: 250px 1fr 350px;
    }
    .smp-crm-panel { width: 350px; }
}
@media (max-width: 1200px) {
    .smp-inbox-layout-3col {
        grid-template-columns: 240px 1fr;
    }
    .smp-crm-panel { display: none; }
    .smp-crm-panel.is-mobile-open {
        display: flex;
        position: fixed;
        right: 0; top: 32px; bottom: 0;
        z-index: 9999;
        box-shadow: -4px 0 20px rgba(0,0,0,.15);
        width: 380px;
        max-width: 90vw;
    }
}
