:root {
    --primary: #1a56db;
    --primary-dark: #1340b5;
    --accent: #f97316;
    --dark: #1e293b;
    --light-bg: #f8fafc;
    --success: #16a34a;
    --border: #e2e8f0;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--light-bg);
    color: var(--dark);
}

/* Navbar */
.main-nav {
    background: linear-gradient(135deg, var(--dark) 0%, #334155 100%);
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}
.navbar-brand {
    font-weight: 700;
    font-size: 1.3rem;
    color: #fff !important;
}
.navbar-brand i {
    color: var(--accent);
    font-size: 1.5rem;
}
.nav-link {
    color: rgba(255,255,255,0.85) !important;
    font-weight: 500;
    transition: color 0.2s;
}
.nav-link:hover {
    color: var(--accent) !important;
}

/* Hero Section */
.hero {
    background: linear-gradient(135deg, #1e293b 0%, #1a56db 50%, #1340b5 100%);
    color: #fff;
    padding: 4rem 0 5rem;
    position: relative;
    overflow: hidden;
}
.hero::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(249,115,22,0.15) 0%, transparent 70%);
    border-radius: 50%;
}
.hero h1 {
    font-weight: 800;
    font-size: 2.5rem;
    margin-bottom: 1rem;
}
.hero p {
    font-size: 1.15rem;
    opacity: 0.9;
    margin-bottom: 2rem;
}
.search-box {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 20px 50px rgba(0,0,0,0.25);
    position: relative;
    z-index: 1;
}
.search-box input {
    font-size: 1.1rem;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
}
.search-box input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,86,219,0.1);
}
.search-box .btn-search {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    padding: 0.75rem 2rem;
    border-radius: 8px;
    border: none;
    transition: background 0.2s;
}
.search-box .btn-search:hover {
    background: var(--primary-dark);
}

/* Stats */
.stats-section {
    background: #fff;
    padding: 2rem 0;
    margin-top: -2rem;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -10px 30px rgba(0,0,0,0.08);
    position: relative;
    z-index: 2;
}
.stat-card {
    text-align: center;
    padding: 1rem;
}
.stat-card .stat-number {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
}
.stat-card .stat-label {
    color: #64748b;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Section titles */
.section-title {
    text-align: center;
    margin-bottom: 2.5rem;
}
.section-title h2 {
    font-weight: 700;
    font-size: 1.8rem;
    color: var(--dark);
}
.section-title p {
    color: #64748b;
    margin-top: 0.5rem;
}

/* How it works */
.how-card {
    background: #fff;
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    height: 100%;
    border: 1px solid var(--border);
    transition: all 0.3s;
}
.how-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    border-color: var(--primary);
}
.how-card .icon {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    margin: 0 auto 1.5rem;
}
.how-card h5 {
    font-weight: 600;
    margin-bottom: 0.75rem;
}
.how-card p {
    color: #64748b;
    font-size: 0.95rem;
}

/* Supplier cards */
.supplier-card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
    transition: all 0.3s;
    height: 100%;
}
.supplier-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}
.supplier-card .card-body {
    padding: 1.5rem;
}
.supplier-card h5 {
    font-weight: 600;
    color: var(--dark);
}
.supplier-logo {
    width: 100%;
    height: 140px;
    object-fit: cover;
    background: var(--light-bg);
}
.supplier-initial {
    width: 100%;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}

/* Search results */
.result-card {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
    transition: box-shadow 0.2s;
}
.result-card:hover {
    box-shadow: 0 5px 20px rgba(0,0,0,0.08);
}
.oe-badge {
    background: var(--accent);
    color: #fff;
    padding: 0.3rem 0.8rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85rem;
    display: inline-block;
}
.contact-btn {
    border-radius: 8px;
    font-weight: 500;
    padding: 0.5rem 1.2rem;
    transition: all 0.2s;
}
.btn-whatsapp {
    background: #25D366;
    color: #fff;
    border: none;
}
.btn-whatsapp:hover {
    background: #1da851;
    color: #fff;
}

/* Footer */
.footer {
    background: var(--dark);
    color: #ffffff;
}
.footer h5,
.footer h6 {
    color: #ffffff !important;
}
.footer-desc {
    color: rgba(255, 255, 255, 0.85) !important;
    font-size: 0.875rem;
    line-height: 1.6;
    margin-bottom: 0;
}
.footer-links li {
    margin-bottom: 0.4rem;
}
.footer-links a {
    color: rgba(255, 255, 255, 0.75) !important;
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.2s;
}
.footer-links a:hover {
    color: var(--accent) !important;
}
.footer-line {
    color: rgba(255, 255, 255, 0.85) !important;
    font-size: 0.875rem;
    margin-bottom: 0.4rem;
}
.footer-copy {
    color: rgba(255, 255, 255, 0.75) !important;
    font-size: 0.875rem;
}
.footer-hr {
    border-color: rgba(255, 255, 255, 0.15);
    margin: 1rem 0;
}
.footer a {
    text-decoration: none;
    transition: color 0.2s;
}
.footer a:hover {
    color: var(--accent);
}
.footer hr {
    border-color: #334155;
}

/* Supplier Portal Layout */
.supplier-topbar {
    background: linear-gradient(135deg, #1e40af, #1e3a8a);
    padding: 0.6rem 0;
}
.supplier-topbar .navbar-brand {
    font-weight: 600;
}
.supplier-layout {
    display: flex;
    min-height: calc(100vh - 60px);
    background: #f1f5f9;
}
.supplier-sidebar {
    width: 240px;
    background: var(--dark);
    color: #cbd5e1;
    padding: 1rem 0;
    display: flex;
    flex-direction: column;
}
.supplier-sidebar .nav-link {
    color: #cbd5e1;
    padding: 0.7rem 1.5rem;
    border-left: 3px solid transparent;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.95rem;
    transition: all 0.2s;
}
.supplier-sidebar .nav-link i {
    width: 18px;
    text-align: center;
}
.supplier-sidebar .nav-link:hover {
    background: rgba(255,255,255,0.05);
    color: #fff;
}
.supplier-sidebar .nav-link.active {
    background: rgba(59,130,246,0.15);
    color: #fff;
    border-left-color: #3b82f6;
}
.supplier-sidebar-footer {
    margin-top: auto;
    padding: 1rem 1.5rem;
}
.supplier-main {
    flex: 1;
    padding: 1.5rem 2rem;
    overflow-x: auto;
}
.supplier-footer {
    background: var(--dark);
    color: rgba(255,255,255,0.7);
}
.stat-card {
    background: #fff;
    border-radius: 0.75rem;
    padding: 1.25rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    border: 1px solid #e2e8f0;
}
.stat-card .stat-label {
    color: #64748b;
    font-size: 0.85rem;
    margin-bottom: 0.4rem;
}
.stat-card .stat-value {
    font-size: 1.85rem;
    font-weight: 700;
    color: var(--dark);
}
.stat-card .stat-icon {
    width: 48px; height: 48px;
    border-radius: 0.6rem;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
}

/* RTL support for supplier layout */
[dir="rtl"] .supplier-sidebar .nav-link.active {
    border-left-color: transparent;
    border-right-color: #3b82f6;
}
[dir="rtl"] .supplier-sidebar {
    order: 1;
}

/* Admin */
.admin-body {
    background: #f1f5f9;
}
.admin-sidebar {
    background: var(--dark);
    min-height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    width: 240px;
    z-index: 1000;
}
.admin-sidebar .brand {
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid #334155;
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
}
.admin-sidebar .nav-link {
    color: #cbd5e1 !important;
    padding: 0.75rem 1.5rem;
    border-radius: 0;
    font-weight: 500;
    transition: all 0.2s;
}
.admin-sidebar .nav-link:hover {
    background: #334155;
    color: #fff !important;
}
.admin-sidebar .nav-link.active {
    background: var(--primary);
    color: #fff !important;
}
.admin-sidebar .nav-link i {
    width: 24px;
}
.admin-content {
    margin-left: 240px;
    padding: 1.5rem 2rem;
}
.admin-topbar {
    background: #fff;
    border-radius: 10px;
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.admin-card {
    background: #fff;
    border-radius: 10px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    margin-bottom: 1.5rem;
}
.admin-card h5 {
    font-weight: 600;
    margin-bottom: 1.2rem;
}
.stat-box {
    background: #fff;
    border-radius: 10px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    gap: 1rem;
}
.stat-box .stat-icon {
    width: 55px;
    height: 55px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #fff;
}
.stat-box .stat-info h3 {
    font-weight: 700;
    margin: 0;
    color: var(--dark);
}
.stat-box .stat-info span {
    color: #64748b;
    font-size: 0.85rem;
}

/* Login */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--dark) 0%, var(--primary) 100%);
}
.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 2.5rem;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 400px;
}
.login-card h3 {
    font-weight: 700;
    text-align: center;
    margin-bottom: 0.5rem;
}
.login-card .login-subtitle {
    text-align: center;
    color: #64748b;
    margin-bottom: 2rem;
}

/* Tables */
.table-card {
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.table-card .table {
    margin: 0;
}
.table-card .table th {
    background: var(--light-bg);
    font-weight: 600;
    color: #475569;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none;
    padding: 1rem;
}
.table-card .table td {
    padding: 1rem;
    vertical-align: middle;
    border-color: var(--border);
}
.badge-active {
    background: #dcfce7;
    color: #15803d;
}
.badge-inactive {
    background: #fee2e2;
    color: #b91c1c;
}

/* Price masking on customer-facing search results */
.price-masked {
    display: inline-block;
    padding: 2px 10px;
    background: #e2e8f0;
    color: #64748b;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    user-select: none;
    -webkit-user-select: none;
}

/* Forms */
.form-card {
    background: #fff;
    border-radius: 10px;
    padding: 2rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.form-label {
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.4rem;
}
.form-control, .form-select {
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 0.6rem 0.9rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,86,219,0.1);
}
.btn-primary {
    background: var(--primary);
    border: none;
    font-weight: 600;
    padding: 0.6rem 1.5rem;
    border-radius: 8px;
}
.btn-primary:hover {
    background: var(--primary-dark);
}
.btn-danger {
    border: none;
    border-radius: 8px;
}

/* Flash messages */
.flash-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    min-width: 300px;
}

/* Responsive */
@media (max-width: 768px) {
    .hero h1 { font-size: 1.8rem; }
    .hero { padding: 2rem 0 3rem; }
    .admin-sidebar { transform: translateX(-100%); transition: transform 0.3s; }
    .admin-sidebar.show { transform: translateX(0); }
    .admin-content { margin-left: 0; padding: 1rem; }
    .search-box .btn-search { width: 100%; margin-top: 0.5rem; }
}

/* Inquiry Modal Preview Card (mimics the chat screenshot reference) */
.inquiry-preview {
    border: 1px solid #fed7aa;
    border-radius: 8px;
    background: #fffbeb;
    overflow: hidden;
}
.inquiry-preview-header {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    color: #92400e;
    padding: 8px 12px;
    font-size: 0.875rem;
    border-bottom: 1px solid #fed7aa;
}
.inquiry-preview-body {
    padding: 12px 14px;
    font-size: 0.875rem;
}
.inquiry-preview-body .row > div {
    padding: 2px 0;
}
.inquiry-preview-footer {
    padding: 6px 12px;
    background: #fef3c7;
    border-top: 1px solid #fed7aa;
}

/* Inquiry number tag (used in admin lists) */
.inquiry-no-tag {
    font-family: 'Courier New', Courier, monospace;
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
    color: #1e293b;
    font-size: 0.875rem;
}

/* Inquiry button (red themed) */
.inquiry-btn {
    background: linear-gradient(135deg, #dc2626, #991b1b) !important;
    border: none !important;
    color: #fff !important;
    font-weight: 500;
    transition: all 0.2s;
}
.inquiry-btn:hover {
    background: linear-gradient(135deg, #b91c1c, #7f1d1d) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
    color: #fff !important;
}
.inquiry-btn:active {
    transform: translateY(0);
}

/* ==========================================================================
   Chat-style Inquiry Modal
   ========================================================================== */

/* Slim product summary strip at top of chat modal */
.chat-product-strip {
    background: linear-gradient(135deg, #fffbeb, #fef3c7);
    border-bottom: 1px solid #fcd34d;
    padding: 10px 16px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.chat-product-strip .strip-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}
.chat-product-strip .strip-main { min-width: 0; flex: 1; }
.chat-product-strip .strip-oe {
    font-family: 'Courier New', Courier, monospace;
    font-weight: 700;
    color: #92400e;
    word-break: break-all;
}
.chat-product-strip .strip-meta {
    font-size: 0.78rem;
    color: #78350f;
}
.chat-product-strip .strip-no {
    background: #fff;
    border: 1px dashed #f59e0b;
    color: #92400e;
    padding: 3px 8px;
    border-radius: 6px;
    font-family: 'Courier New', Courier, monospace;
    font-weight: 700;
    font-size: 0.78rem;
    white-space: nowrap;
}

/* Chat thread container */
.chat-thread {
    background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
    padding: 18px 16px 12px;
    min-height: 280px;
    max-height: 380px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.chat-thread::-webkit-scrollbar { width: 6px; }
.chat-thread::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* Day separator / system notice row */
.chat-system {
    text-align: center;
    margin: 4px auto 6px;
}
.chat-system span {
    display: inline-block;
    background: rgba(15, 23, 42, 0.06);
    color: #475569;
    font-size: 0.72rem;
    padding: 3px 12px;
    border-radius: 999px;
}

/* One chat row (avatar + bubble) */
.chat-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 100%;
}
.chat-row.supplier { justify-content: flex-start; }
.chat-row.buyer    { justify-content: flex-end; }

.chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    color: #fff;
}
.chat-avatar.supplier-avatar {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
}
.chat-avatar.buyer-avatar {
    background: linear-gradient(135deg, #dc2626, #991b1b);
}
.chat-avatar.bot-avatar {
    background: linear-gradient(135deg, #64748b, #334155);
}

/* The actual bubble */
.chat-bubble {
    max-width: 78%;
    padding: 9px 14px;
    border-radius: 16px;
    font-size: 0.9rem;
    line-height: 1.45;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
    position: relative;
}
.chat-row.supplier .chat-bubble {
    background: #ffffff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}
.chat-row.buyer .chat-bubble {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-row.bot .chat-bubble {
    background: #fff;
    color: #334155;
    border: 1px dashed #cbd5e1;
}
.chat-bubble .bubble-meta {
    display: block;
    font-size: 0.7rem;
    margin-top: 4px;
    opacity: 0.7;
}
.chat-row.supplier .bubble-meta { color: #64748b; }
.chat-row.buyer .bubble-meta { color: rgba(255,255,255,0.85); text-align: right; }

/* Inline product card bubble */
.chat-bubble.product-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    padding: 10px 12px;
}
.chat-bubble.product-card .pc-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.82rem;
    padding: 2px 0;
    gap: 8px;
}
.chat-bubble.product-card .pc-row .pc-key { color: #64748b; flex-shrink: 0; }
.chat-bubble.product-card .pc-row .pc-val { color: #0f172a; font-weight: 500; text-align: right; word-break: break-word; }
.chat-bubble.product-card .pc-row .pc-val.danger { color: #dc2626; }

/* Quick-reply chips inside chat */
.chat-quick {
    padding: 8px 16px 4px;
    background: #f1f5f9;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    border-top: 1px solid #e2e8f0;
}
.chat-quick .quick-chip {
    background: #fff;
    border: 1px solid #cbd5e1;
    color: #334155;
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.15s;
}
.chat-quick .quick-chip:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #b91c1c;
}

/* Composer (message input area) */
.chat-composer {
    background: #fff;
    border-top: 1px solid #e2e8f0;
    padding: 12px 14px 14px;
}
.chat-composer .composer-fields {
    display: grid;
    grid-template-columns: 1fr 1fr 80px;
    gap: 8px;
    margin-bottom: 8px;
}
.chat-composer .composer-fields input {
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    padding: 6px 10px;
    font-size: 0.82rem;
    background: #f8fafc;
    transition: all 0.15s;
}
.chat-composer .composer-fields input:focus {
    outline: none;
    border-color: #ef4444;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}
.chat-composer .composer-fields input::placeholder { color: #94a3b8; }
.chat-composer .composer-fields input.required { border-color: #fca5a5; }

.chat-composer .composer-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}
.chat-composer .composer-row textarea {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 9px 12px;
    font-size: 0.9rem;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    background: #f8fafc;
    transition: all 0.15s;
}
.chat-composer .composer-row textarea:focus {
    outline: none;
    border-color: #ef4444;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}
.chat-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #dc2626, #991b1b);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
}
.chat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 14px rgba(220, 38, 38, 0.4);
}
.chat-send-btn:active { transform: scale(0.97); }

/* Mini info row inside composer (WhatsApp + Email + Country, hidden by default) */
.chat-composer .composer-extras {
    display: none;
    margin-top: 8px;
    padding: 8px 10px;
    background: #f8fafc;
    border-radius: 10px;
    font-size: 0.8rem;
    color: #475569;
}
.chat-composer .composer-extras.show { display: block; }
.chat-composer .composer-extras .extras-title {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #94a3b8;
    margin-bottom: 4px;
}
.chat-composer .composer-extras input {
    width: 100%;
    border: 1px solid #e2e8f0;
    background: #fff;
    border-radius: 6px;
    padding: 5px 9px;
    font-size: 0.8rem;
    margin-bottom: 4px;
}
.chat-composer .composer-extras input:focus {
    outline: none;
    border-color: #ef4444;
}
.chat-toggle-extras {
    background: none;
    border: none;
    color: #64748b;
    font-size: 0.78rem;
    cursor: pointer;
    padding: 0;
    margin-bottom: 6px;
}
.chat-toggle-extras:hover { color: #dc2626; text-decoration: underline; }

/* On modal close animation tweak */
#inquiryModal .modal-content {
    border-radius: 14px;
    overflow: hidden;
    border: none;
    box-shadow: 0 25px 60px rgba(15, 23, 42, 0.25);
}
#inquiryModal .modal-header {
    border-bottom: none;
}

/* Responsive tweaks for the chat modal */
@media (max-width: 575.98px) {
    .chat-composer .composer-fields {
        grid-template-columns: 1fr 1fr;
    }
    .chat-composer .composer-fields input:nth-child(3) {
        grid-column: 1 / -1;
    }
    .chat-bubble { max-width: 84%; }
    .chat-product-strip { padding: 8px 12px; font-size: 0.8rem; }
}

/* Customer (buyer) bubble - right side, white background */
.chat-row.buyer {
    flex-direction: row-reverse;
    align-items: flex-start;
    /* IMPORTANT: when flex-direction is row-reverse, the main axis flips,
       so flex-start (not flex-end) anchors the row to the RIGHT edge. */
    justify-content: flex-start;
}
.chat-row.buyer .chat-avatar {
    margin-right: 0;
    margin-left: 8px;
}
.chat-bubble.customer-bubble {
    background: #ffffff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-radius: 14px 14px 4px 14px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.chat-bubble.customer-bubble .bubble-meta {
    color: #94a3b8;
    display: block;
    margin-top: 4px;
    font-size: 0.7rem;
    text-align: right;
}

/* Supplier quote bubble - special style with green accent */
.chat-bubble.supplier-quote {
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    color: #064e3b;
    border: 1px solid #6ee7b7;
    border-radius: 14px 14px 14px 4px;
    box-shadow: 0 1px 3px rgba(16, 185, 129, 0.15);
}
.chat-bubble.supplier-quote .bubble-meta {
    color: #047857;
    display: block;
    margin-top: 6px;
    font-size: 0.7rem;
    font-weight: 500;
}
.chat-bubble.supplier-quote .quote-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #059669;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Product card quote line - success variant */
.chat-bubble.product-card .pc-val.success {
    color: #047857;
    font-weight: 700;
}

/* History bar (shown when returning customer loads thread) */
.chat-history-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: linear-gradient(90deg, #eff6ff 0%, #f0f9ff 100%);
    border-top: 1px solid #dbeafe;
    border-bottom: 1px solid #dbeafe;
    font-size: 0.78rem;
    color: #1e40af;
    font-weight: 500;
}
.chat-history-bar .history-meta {
    color: #6b7280;
    font-weight: 400;
    font-size: 0.7rem;
}

/* Composer history-lookup row (text + load button) */
.composer-history-lookup {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px dashed #e2e8f0;
}
.composer-history-lookup .lookup-divider {
    color: #cbd5e1;
    font-size: 0.7rem;
}
.chat-lookup-btn {
    background: none;
    border: 0;
    color: #6b7280;
    font-size: 0.78rem;
    padding: 2px 6px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}
.chat-lookup-btn:hover {
    background: #f1f5f9;
    color: #1e40af;
}
.composer-lookup-row {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    align-items: center;
}
.composer-lookup-row input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.85rem;
}

/* Dynamic message rows (loaded from server) should not double-apply bubble styles */
.chat-row.dynamic .chat-bubble { animation: bubbleFadeIn 0.3s ease-out; }
@keyframes bubbleFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Quote bubble - price + note inside */
.chat-bubble.supplier-quote .quote-price {
    font-size: 1.4rem;
    font-weight: 700;
    color: #047857;
    line-height: 1.2;
    margin: 4px 0 6px 0;
    letter-spacing: 0.3px;
}
.chat-bubble.supplier-quote .quote-note {
    font-size: 0.85rem;
    color: #064e3b;
    background: rgba(255, 255, 255, 0.55);
    padding: 6px 10px;
    border-radius: 6px;
    margin-top: 4px;
    line-height: 1.45;
}

/* ============================================================
   Supplier Portal — Conversation Modal Chat
   Perspective: supplier = self (right), customer = other (left)
   ============================================================ */
.sp-chat-thread {
    height: 420px;
    overflow-y: auto;
    padding: 16px;
    background: #f8fafc;
    border-radius: 0.5rem;
    border: 1px solid #e2e8f0;
}
.sp-chat-thread::-webkit-scrollbar { width: 6px; }
.sp-chat-thread::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

.sp-chat-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 100%;
    margin-bottom: 10px;
}
.sp-chat-row.self { justify-content: flex-end; }
.sp-chat-row.other { justify-content: flex-start; }

.sp-chat-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1rem; flex-shrink: 0; color: #fff;
}
.sp-chat-avatar.self-avatar {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
}
.sp-chat-avatar.other-avatar {
    background: linear-gradient(135deg, #dc2626, #991b1b);
}

.sp-chat-bubble {
    max-width: 78%;
    padding: 9px 14px;
    border-radius: 16px;
    font-size: 0.9rem;
    line-height: 1.45;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(15,23,42,0.06);
    position: relative;
}
.sp-chat-row.self .sp-chat-bubble {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.sp-chat-row.other .sp-chat-bubble {
    background: #fff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}
.sp-chat-bubble .bubble-meta {
    display: block;
    font-size: 0.7rem;
    margin-top: 4px;
    opacity: 0.7;
}
.sp-chat-row.self .bubble-meta { color: rgba(255,255,255,0.8); text-align: right; }
.sp-chat-row.other .bubble-meta { color: #64748b; }

/* Quote bubble (green gradient, both perspectives) */
.sp-chat-bubble.sp-quote {
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%) !important;
    color: #064e3b !important;
    border: 1px solid #6ee7b7 !important;
    border-radius: 14px 14px 14px 4px !important;
    box-shadow: 0 1px 3px rgba(16,185,129,0.15);
}
.sp-chat-row.self .sp-chat-bubble.sp-quote {
    border-radius: 14px 14px 4px 14px !important;
}
.sp-chat-bubble.sp-quote .bubble-meta { color: #047857; }
.sp-chat-bubble.sp-quote .quote-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #059669;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.sp-chat-bubble.sp-quote .quote-price {
    font-size: 1.25rem;
    font-weight: 700;
    color: #064e3b;
    margin: 4px 0;
}
.sp-chat-bubble.sp-quote .quote-note {
    font-size: 0.85rem;
    color: #047857;
    white-space: pre-wrap;
}

/* System divider */
.sp-chat-system {
    text-align: center;
    margin: 8px 0;
}
.sp-chat-system span {
    background: #e2e8f0;
    color: #64748b;
    font-size: 0.72rem;
    padding: 3px 12px;
    border-radius: 999px;
}

/* Composer */
.sp-chat-composer {
    background: #fff;
    border-top: 1px solid #e2e8f0;
    padding: 12px 0 0;
}
.sp-chat-composer textarea {
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    padding: 8px 12px;
    font-size: 0.88rem;
    resize: none;
    transition: all 0.15s;
}
.sp-chat-composer textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.sp-chat-quote-form {
    background: #f0fdf4;
    border: 1px solid #6ee7b7;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
}
.sp-chat-quote-form input {
    border-radius: 6px;
    border: 1px solid #d1fae5;
    padding: 6px 10px;
    font-size: 0.85rem;
}

/* Live indicator */
.sp-live-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.72rem;
    color: #059669;
    font-weight: 600;
}
.sp-live-badge .live-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #10b981;
    animation: sp-pulse 1.5s infinite;
}
@keyframes sp-pulse {
    0%,100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Fade-in animation for new messages */
.sp-chat-row.sp-new { animation: spFadeIn 0.3s ease-out; }
@keyframes spFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
