/**
 * ParsEDM Industrial AI Chat Interface Styles
 * Version: 2.0.3
 * Industrial High-Tech Theme - RTL Native
 * Fully Responsive (Mobile-First + Desktop Centered)
 * Powered by WordPress React & Standalone 100dvh
 */

/* ==========================================================================
   Web Font: IRANYekanX Variable Font (VF) - Live CDN from parsedm.ir
   ========================================================================== */
@font-face {
    font-family: 'IranYekanXVF';
    src: url('https://parsedm.ir/wp-content/uploads/fonts/VF/IRANYekanXVF.woff2') format('woff2-variations'),
         url('https://parsedm.ir/wp-content/uploads/fonts/VF/IRANYekanXVF.woff2') format('woff2');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'IRANYekanX';
    src: url('https://parsedm.ir/wp-content/uploads/fonts/VF/IRANYekanXVF.woff2') format('woff2-variations'),
         url('https://parsedm.ir/wp-content/uploads/fonts/VF/IRANYekanXVF.woff2') format('woff2');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'IranYekanXVF';
    font-style: normal;
    font-weight: normal;
    font-display: swap;
    src: url('https://parsedm.ir/wp-content/uploads/fonts/VF/IRANYekanXVF.woff2') format('woff2');
}

@font-face {
    font-family: 'IranYekanXVF';
    font-style: normal;
    font-weight: bold;
    font-display: swap;
    src: url('https://parsedm.ir/wp-content/uploads/fonts/VF/IRANYekanXVF.woff2') format('woff2');
}

:root {
    --pedm-primary: #00639c;
    --pedm-primary-hover: #004d7a;
    --pedm-primary-light: rgba(0, 99, 156, 0.12);
    --pedm-accent: #f59e0b;
    --pedm-accent-glow: rgba(245, 158, 11, 0.25);
    --pedm-dark-900: #0b101b;
    --pedm-dark-800: #111827;
    --pedm-dark-700: #1f2937;
    --pedm-dark-600: #374151;
    --pedm-light-bg: #f8fafc;
    --pedm-card-bg: #ffffff;
    --pedm-border: #e2e8f0;
    --pedm-border-dark: #2d3748;
    --pedm-text-main: #0f172a;
    --pedm-text-muted: #64748b;
    --pedm-text-inverse: #f8fafc;
    --pedm-bot-bubble: #ffffff;
    --pedm-user-bubble: #00639c;
    --pedm-success: #10b981;
    --pedm-danger: #ef4444;
    --pedm-font-family: "IranYekanXVF", "IRANYekanX", "IranYekanXFaNumVF", "Vazirmatn", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --pedm-radius-lg: 18px;
    --pedm-radius-md: 10px;
    --pedm-radius-sm: 6px;
    --pedm-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
}

/* Ensure font applies across all elements and buttons */
#parsedm-ai-chat-root,
.pedm-chat-container,
.pedm-chat-window,
.pedm-chat-container button,
.pedm-chat-window button,
.pedm-chat-container input,
.pedm-chat-window input,
.pedm-chat-container textarea,
.pedm-chat-window textarea {
    font-family: var(--pedm-font-family);
}

/* ==========================================================================
   Base Resets & Standalone Centering
   ========================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    box-sizing: border-box;
    width: 100%;
    margin: 0;
    padding: 0;
    -webkit-text-size-adjust: 100%;
}

body.pedm-chat-fullscreen-root {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    background-color: #0b111e;
    background-image: 
        radial-gradient(circle at 50% 0%, rgba(0, 99, 156, 0.28) 0%, transparent 65%),
        radial-gradient(circle at 100% 100%, rgba(15, 23, 42, 0.85) 0%, transparent 55%),
        linear-gradient(180deg, #070d18 0%, #0d1526 100%);
    font-family: var(--pedm-font-family);
    direction: rtl;
    text-align: right;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* React Root Wrapper */
#parsedm-ai-chat-root {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto;
    padding: 0;
}

/* Chat Main Container (Desktop Center Card) */
.pedm-chat-container,
.pedm-chat-window {
    width: 100%;
    max-width: 920px;
    height: 94vh;
    height: 94dvh;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    background: var(--pedm-light-bg);
    border-radius: var(--pedm-radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
    overflow: hidden;
    position: relative;
}

/* ==========================================================================
   Header Section
   ========================================================================== */
.pedm-chat-header {
    background: linear-gradient(135deg, #091a2e 0%, #004d7a 100%);
    color: #ffffff;
    padding: 14px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--pedm-accent);
    z-index: 10;
    flex-shrink: 0;
    gap: 12px;
}

.pedm-brand-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.pedm-brand-logo {
    width: 40px;
    height: 40px;
    border-radius: var(--pedm-radius-md);
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    flex-shrink: 0;
    overflow: hidden;
    padding: 4px;
}

.pedm-logo-img {
    width: auto;
    height: 26px;
    max-width: 100%;
    object-fit: contain;
    display: block;
}

.pedm-brand-details {
    min-width: 0;
}

.pedm-brand-details h1 {
    margin: 0;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: -0.2px;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pedm-brand-details p {
    margin: 2px 0 0;
    font-size: 11.5px;
    color: #93c5fd;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Header Actions */
.pedm-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* Live Status & Cache Probe Badge */
.pedm-probe-badge {
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 7px;
    color: #e2e8f0;
    white-space: nowrap;
    transition: all 0.3s ease;
}

.pedm-probe-badge .probe-label-short {
    display: none;
}

.pedm-probe-badge .probe-label-full {
    display: inline;
}

.pedm-probe-badge.online {
    border-color: rgba(34, 197, 94, 0.45);
    background: rgba(34, 197, 94, 0.16);
    color: #86efac;
}

.pedm-probe-badge.bypass,
.pedm-probe-badge.cache-hit {
    border-color: rgba(56, 189, 248, 0.45);
    background: rgba(2, 132, 199, 0.22);
    color: #7dd3fc;
}

.pedm-probe-badge.not-found {
    border-color: rgba(245, 158, 11, 0.5);
    background: rgba(245, 158, 11, 0.2);
    color: #fde68a;
}

.pedm-probe-badge.error {
    border-color: rgba(239, 68, 68, 0.5);
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

.pedm-probe-badge.loading {
    border-color: rgba(148, 163, 184, 0.35);
    background: rgba(15, 23, 42, 0.7);
    color: #cbd5e1;
}

.pedm-probe-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--pedm-success);
    box-shadow: 0 0 8px var(--pedm-success);
    flex-shrink: 0;
}

.pedm-3d-status-icon {
    width: 14px;
    height: 14px;
    vertical-align: middle;
    object-fit: contain;
    flex-shrink: 0;
    filter: drop-shadow(0 0 5px rgba(34, 197, 94, 0.4));
    transition: transform 0.2s;
}

.pedm-probe-badge.cache-hit .pedm-3d-status-icon {
    filter: drop-shadow(0 0 5px rgba(249, 115, 22, 0.5));
}

.pedm-probe-badge.loading .pedm-probe-dot,
.pedm-probe-badge.loading .pedm-3d-status-icon {
    animation: pedmPulse 1.2s infinite;
}

@keyframes pedmPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.9); }
}

.pedm-btn-reset {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    padding: 6px 12px;
    border-radius: var(--pedm-radius-sm);
    font-size: 11.5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s;
    white-space: nowrap;
    font-family: inherit;
}

.pedm-btn-reset:hover {
    background: rgba(255, 255, 255, 0.25);
}

.pedm-btn-install {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #ffffff;
    padding: 6px 12px;
    border-radius: var(--pedm-radius-sm);
    font-size: 11.5px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-family: inherit;
    box-shadow: 0 2px 6px rgba(14, 165, 233, 0.35);
}

.pedm-btn-install:hover {
    background: linear-gradient(135deg, #38bdf8 0%, #0369a1 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(14, 165, 233, 0.5);
}

.pedm-btn-install-icon {
    font-size: 13px;
    line-height: 1;
}

/* ==========================================================================
   Quick Chips Bar
   ========================================================================== */
.pedm-quick-chips {
    background: #edf2f7;
    padding: 8px 16px;
    display: flex;
    flex-wrap: nowrap;
    white-space: nowrap;
    gap: 8px;
    overflow-x: auto;
    border-bottom: 1px solid var(--pedm-border);
    flex-shrink: 0;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}

.pedm-quick-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #334155;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 11.5px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    font-family: inherit;
    flex-shrink: 0;
}

.pedm-quick-chip:hover {
    background: var(--pedm-primary-light);
    color: var(--pedm-primary);
    border-color: var(--pedm-primary);
    transform: translateY(-1px);
}

.pedm-3d-chip-icon {
    width: 16px;
    height: 16px;
    vertical-align: middle;
    object-fit: contain;
    flex-shrink: 0;
    transition: transform 0.2s;
}

.pedm-quick-chip:hover .pedm-3d-chip-icon {
    transform: scale(1.18);
}

.pedm-3d-btn-icon {
    width: 18px;
    height: 18px;
    vertical-align: middle;
    object-fit: contain;
    flex-shrink: 0;
    display: inline-block;
}

.pedm-3d-inline-icon {
    width: 22px;
    height: 22px;
    vertical-align: -4px;
    object-fit: contain;
    display: inline-block;
    margin: 0 4px;
}

.pedm-wave-icon {
    display: inline-block;
    animation: pedmWaveAnim 2s infinite ease-in-out;
    transform-origin: 70% 70%;
}

@keyframes pedmWaveAnim {
    0%, 100% { transform: rotate(0deg); }
    20% { transform: rotate(14deg); }
    40% { transform: rotate(-8deg); }
    60% { transform: rotate(14deg); }
    80% { transform: rotate(-4deg); }
}

/* ==========================================================================
   Chat Messages Flow
   ========================================================================== */
.pedm-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #f1f5f9;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Message Bubble */
.pedm-msg-wrapper {
    display: flex;
    gap: 10px;
    max-width: 86%;
    animation: pedmFadeIn 0.25s ease-out;
}

@keyframes pedmFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.pedm-msg-wrapper.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.pedm-msg-wrapper.bot {
    align-self: flex-start;
}

.pedm-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11.5px;
    font-weight: 800;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.pedm-msg-wrapper.bot .pedm-avatar {
    background: #ffffff;
    border: 1.5px solid #cbd5e1;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.06);
}

.pedm-avatar-img {
    width: auto;
    height: 20px;
    max-width: 100%;
    object-fit: contain;
    display: block;
}

.pedm-msg-wrapper.user .pedm-avatar {
    background: #cbd5e1;
    color: #334155;
}

.pedm-bubble-body {
    background: #ffffff;
    padding: 13px 18px;
    border-radius: 14px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
    font-size: 13.5px;
    line-height: 1.85;
    color: var(--pedm-text-main);
    word-break: break-word;
    border: 1px solid var(--pedm-border);
}

.pedm-msg-wrapper.user .pedm-bubble-body {
    background: var(--pedm-user-bubble);
    color: #ffffff;
    border-color: transparent;
    border-top-left-radius: 2px;
}

.pedm-msg-wrapper.bot .pedm-bubble-body {
    border-top-right-radius: 2px;
}

.pedm-uploaded-img {
    max-width: 220px;
    max-height: 220px;
    border-radius: var(--pedm-radius-sm);
    object-fit: cover;
    margin-bottom: 8px;
    display: block;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Markdown formatting inside bubbles */
.pedm-bubble-body p {
    margin: 0 0 8px 0;
}
.pedm-bubble-body p:last-child {
    margin-bottom: 0;
}

.pedm-bubble-body strong {
    font-weight: 800;
}

.pedm-bubble-body code {
    background: rgba(0, 99, 156, 0.08);
    color: #0369a1;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12.5px;
    direction: ltr;
    display: inline-block;
}

.pedm-msg-wrapper.user .pedm-bubble-body code {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.pedm-bubble-body ul, .pedm-bubble-body ol {
    margin: 6px 0;
    padding-right: 20px;
}

.pedm-bubble-body li {
    margin-bottom: 4px;
}

.pedm-link {
    color: var(--pedm-primary);
    font-weight: 700;
    text-decoration: underline;
    word-break: break-all;
}

.pedm-msg-wrapper.user .pedm-link {
    color: #ffffff;
}

/* Tables */
.pedm-table-responsive {
    width: 100%;
    overflow-x: auto;
    margin: 8px 0;
    -webkit-overflow-scrolling: touch;
}

.pedm-table {
    width: 100%;
    border-collapse: collapse;
    margin: 4px 0 8px 0;
    font-size: 12.5px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    overflow: hidden;
}

.pedm-table td, .pedm-table th {
    border: 1px solid #e2e8f0;
    padding: 6px 10px;
    text-align: right;
    vertical-align: middle;
}

.pedm-table th {
    background: #f1f5f9;
    color: #0f172a;
    font-weight: 700;
    font-size: 12.5px;
    border-bottom: 2px solid #cbd5e1;
}

.pedm-table tr:first-child td {
    background: #f8fafc;
}

/* Markdown Headings */
.pedm-bubble-body .pedm-md-h2,
.pedm-bubble-body .pedm-md-h3,
.pedm-bubble-body .pedm-md-h4,
.pedm-bubble-body .pedm-md-h5 {
    color: #0369a1;
    font-weight: 700;
    margin: 8px 0 4px 0;
    line-height: 1.45;
}
.pedm-bubble-body .pedm-md-h2 { font-size: 15px; }
.pedm-bubble-body .pedm-md-h3 { font-size: 14px; }
.pedm-bubble-body .pedm-md-h4 { font-size: 13.2px; }
.pedm-bubble-body .pedm-md-h5 { font-size: 12.8px; }

/* Markdown Divider */
.pedm-bubble-body .pedm-hr {
    border: none;
    border-top: 1px dashed rgba(2, 132, 199, 0.25);
    margin: 10px 0;
    height: 0;
    display: block;
}

/* Bullet list */
.pedm-bubble-body .pedm-list {
    margin: 6px 0;
    padding-right: 20px;
    list-style-type: disc;
}
.pedm-bubble-body .pedm-list li {
    margin-bottom: 4px;
    line-height: 1.6;
}

/* Spacing cleanups */
.pedm-bubble-body br.pedm-br-gap {
    display: block;
    content: "";
    margin-top: 6px;
}

/* ==========================================================================
   Product Cards Container & Section
   ========================================================================== */
.pedm-products-section {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px dashed rgba(2, 132, 199, 0.28);
}

.pedm-products-heading {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13.5px;
    font-weight: 700;
    color: #0369a1;
    margin-bottom: 12px;
}

.pedm-products-heading-icon {
    font-size: 15px;
}

.pedm-products-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 6px;
}

.pedm-product-card {
    background: #ffffff;
    border: 1px solid #bae6fd;
    border-radius: var(--pedm-radius-md);
    padding: 12px;
    display: flex;
    gap: 14px;
    align-items: center;
    box-shadow: 0 4px 10px rgba(0, 99, 156, 0.06);
    transition: transform 0.2s, box-shadow 0.2s;
}

.pedm-product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 99, 156, 0.12);
    border-color: var(--pedm-primary);
}

.pedm-product-card-img {
    width: 85px;
    height: 85px;
    border-radius: var(--pedm-radius-sm);
    object-fit: cover;
    background: #f8fafc;
    border: 1px solid var(--pedm-border);
    flex-shrink: 0;
}

.pedm-product-card-body {
    flex: 1;
    min-width: 0;
}

.pedm-product-title {
    font-size: 13.5px;
    font-weight: 800;
    color: #0f172a;
    margin: 0 0 5px;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pedm-product-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}

.pedm-badge {
    font-size: 10.5px;
    padding: 2px 7px;
    border-radius: 4px;
    font-weight: 600;
}

.pedm-badge-sku {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
    direction: ltr;
    font-family: monospace;
}

.pedm-badge-stock {
    background: #dcfce7;
    color: #15803d;
}

.pedm-badge-nostock {
    background: #fef2f2;
    color: #b91c1c;
}

.pedm-product-price {
    font-size: 13px;
    font-weight: 800;
    color: var(--pedm-primary);
    margin-bottom: 6px;
}

.pedm-product-specs-brief {
    font-size: 11px;
    color: #64748b;
    margin-bottom: 8px;
}

.pedm-product-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.pedm-product-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--pedm-primary);
    color: #ffffff !important;
    padding: 6px 12px;
    border-radius: var(--pedm-radius-sm);
    font-size: 11.5px;
    font-weight: 700;
    text-decoration: none;
    transition: background 0.2s, transform 0.15s;
    line-height: 1.4;
}

.pedm-product-cta:hover {
    background: var(--pedm-primary-hover);
    transform: translateY(-1px);
}

.pedm-product-whatsapp-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: linear-gradient(135deg, #128c7e 0%, #075e54 100%);
    color: #ffffff !important;
    padding: 6px 14px;
    border-radius: var(--pedm-radius-sm);
    font-size: 11.5px;
    font-weight: 700;
    text-decoration: none;
    transition: all 0.2s;
    box-shadow: 0 2px 5px rgba(7, 94, 84, 0.35);
    line-height: 1.4;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.pedm-product-whatsapp-cta:hover {
    background: linear-gradient(135deg, #1da896 0%, #0c7569 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(7, 94, 84, 0.45);
}

.pedm-product-whatsapp-cta .pedm-3d-btn-icon {
    width: 20px;
    height: 20px;
}

/* Missing Part WhatsApp Fallback Card */
.pedm-not-found-card {
    margin-top: 12px;
    padding: 13px 15px;
    background: linear-gradient(135deg, rgba(254, 243, 199, 0.7) 0%, rgba(254, 215, 170, 0.55) 100%);
    border: 1px solid rgba(245, 158, 11, 0.4);
    border-radius: var(--pedm-radius-md);
    display: flex;
    flex-direction: column;
    gap: 9px;
    color: #78350f;
    box-shadow: 0 4px 12px rgba(217, 119, 6, 0.08);
}

.pedm-not-found-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 800;
    color: #92400e;
}

.pedm-not-found-text {
    font-size: 11.5px;
    line-height: 1.65;
    color: #78350f;
    margin: 0;
}

.pedm-not-found-whatsapp-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, #128c7e 0%, #075e54 100%);
    color: #ffffff !important;
    text-decoration: none;
    padding: 9px 16px;
    border-radius: var(--pedm-radius-sm);
    font-size: 12px;
    font-weight: 700;
    transition: all 0.2s ease;
    box-shadow: 0 3px 8px rgba(18, 140, 126, 0.25);
    align-self: flex-start;
}

.pedm-not-found-whatsapp-btn:hover {
    background: linear-gradient(135deg, #075e54 0%, #043d37 100%);
    transform: translateY(-1px);
    box-shadow: 0 5px 12px rgba(18, 140, 126, 0.35);
}

.pedm-whatsapp-icon {
    display: inline-block;
    font-size: 13px;
    line-height: 1;
}

/* ==========================================================================
   Image Preview Tray
   ========================================================================== */
.pedm-image-tray {
    background: #f8fafc;
    border-top: 1px solid var(--pedm-border);
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.pedm-tray-thumb-wrap {
    position: relative;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}

.pedm-tray-thumb {
    width: 48px;
    height: 48px;
    border-radius: var(--pedm-radius-sm);
    object-fit: cover;
    border: 1px solid #cbd5e1;
}

.pedm-tray-remove,
.pedm-tray-remove-btn {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #ffffff;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
    padding: 0;
    transition: transform 0.15s ease;
}

.pedm-tray-remove:hover,
.pedm-tray-remove-btn:hover {
    transform: scale(1.1);
}

.pedm-tray-hint {
    font-size: 11px;
    color: var(--pedm-text-muted);
}

/* ==========================================================================
   Footer / Input Area
   ========================================================================== */
.pedm-chat-footer {
    background: #ffffff;
    padding: 12px 16px;
    border-top: 1px solid var(--pedm-border);
    display: flex;
    align-items: center;
    flex-shrink: 0;
    width: 100%;
    box-sizing: border-box;
}

.pedm-footer-form {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    margin: 0;
    padding: 0;
    flex: 1;
}

.pedm-btn-attach {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    width: 42px;
    height: 42px;
    border-radius: var(--pedm-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #475569;
    font-size: 18px;
    transition: all 0.2s;
    flex-shrink: 0;
    margin: 0;
    padding: 0;
}

.pedm-btn-attach:hover {
    background: #e2e8f0;
    color: var(--pedm-primary);
    border-color: var(--pedm-primary);
}

.pedm-input-box {
    flex: 1;
    min-width: 0;
    width: 100%;
    height: 42px;
    border: 1px solid #cbd5e1;
    border-radius: var(--pedm-radius-md);
    padding: 0 14px;
    font-family: inherit;
    font-size: 13.5px;
    outline: none;
    background: #ffffff;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.pedm-input-box:focus {
    border-color: var(--pedm-primary);
    box-shadow: 0 0 0 3px var(--pedm-primary-light);
}

.pedm-btn-submit {
    background: var(--pedm-primary);
    color: #ffffff;
    border: none;
    height: 42px;
    padding: 0 20px;
    border-radius: var(--pedm-radius-md);
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s;
    flex-shrink: 0;
    white-space: nowrap;
}

.pedm-btn-submit:hover {
    background: var(--pedm-primary-hover);
}

.pedm-btn-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Typing / Loading Skeleton Animation */
.pedm-typing-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 0;
}

.pedm-typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #94a3b8;
    animation: pedmBounce 1.4s infinite ease-in-out both;
}

.pedm-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.pedm-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes pedmBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Prevent Google reCAPTCHA floating badge from obscuring mobile chat UI */
.grecaptcha-badge {
    visibility: hidden !important;
    pointer-events: none !important;
    opacity: 0 !important;
}

/* ==========================================================================
   Mobile Responsive Rules (Fluid & Edge-to-Edge)
   ========================================================================== */
@media (max-width: 768px) {
    html, body {
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
        margin: 0 !important;
        padding: 0 !important;
        height: 100% !important;
        background: #091a2e !important;
    }

    body.pedm-chat-fullscreen-root {
        overflow: hidden !important;
        background: #091a2e !important;
    }

    /* Twenty Twenty-Five / Theme layout blocks reset on mobile */
    .wp-site-blocks,
    .pedm-shortcode-wrapper,
    #parsedm-ai-chat-root,
    #parsedm-ai-root {
        width: 100% !important;
        max-width: 100vw !important;
        height: 100% !important;
        height: 100dvh !important;
        margin: 0 !important;
        padding: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
        box-sizing: border-box !important;
        align-items: stretch !important;
    }

    .pedm-chat-container,
    .pedm-chat-window {
        width: 100% !important;
        max-width: 100vw !important;
        height: 100% !important;
        height: 100dvh !important;
        border-radius: 0 !important;
        border: none !important;
        box-shadow: none !important;
        margin: 0 !important;
        flex: 1 1 auto !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
    }

    .pedm-chat-header {
        padding: 8px 10px;
        gap: 6px;
        flex-shrink: 0;
        min-height: 48px;
    }

    .pedm-brand-wrapper {
        gap: 6px;
        min-width: 0;
        flex: 1 1 auto;
        overflow: hidden;
    }

    .pedm-brand-logo {
        width: 32px;
        height: 32px;
        border-radius: 8px;
        flex-shrink: 0;
        padding: 3px;
    }

    .pedm-logo-img {
        height: 20px;
        width: auto;
    }

    .pedm-brand-details {
        min-width: 0;
        overflow: hidden;
        flex: 1;
    }

    .pedm-brand-details h1 {
        font-size: 13px;
        font-weight: 800;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1.25;
        margin: 0;
    }

    .pedm-brand-details p {
        font-size: 9.5px;
        color: rgba(255, 255, 255, 0.8);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        margin: 1px 0 0;
        line-height: 1.2;
        display: block;
    }

    .pedm-header-actions {
        gap: 4px;
        flex-shrink: 0;
        display: flex;
        align-items: center;
    }

    .pedm-probe-badge {
        padding: 3px 6px;
        font-size: 10px;
        gap: 4px;
        border-radius: 12px;
    }

    .pedm-probe-badge .probe-label-full {
        display: none;
    }

    .pedm-probe-badge .probe-label-short {
        display: inline;
    }

    .pedm-btn-reset {
        padding: 4px 8px;
        font-size: 11px;
        gap: 3px;
        border-radius: 6px;
    }

    .pedm-quick-chips {
        padding: 6px 8px;
        gap: 6px;
        overflow-x: auto;
        white-space: nowrap;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        flex-shrink: 0;
    }

    .pedm-quick-chips::-webkit-scrollbar {
        display: none;
    }

    .pedm-quick-chip {
        padding: 4px 10px;
        font-size: 11px;
        border-radius: 16px;
        flex-shrink: 0;
    }

    .pedm-chat-messages {
        padding: 10px 8px;
        gap: 10px;
        flex: 1 1 auto;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }

    .pedm-msg-wrapper {
        max-width: 96%;
        gap: 6px;
    }

    .pedm-avatar {
        width: 26px;
        height: 26px;
        font-size: 10px;
        flex-shrink: 0;
    }

    .pedm-avatar-img {
        height: 16px;
    }

    .pedm-bubble-body {
        padding: 9px 11px;
        font-size: 13px;
        line-height: 1.65;
        border-radius: 14px;
        word-break: break-word;
        overflow-wrap: break-word;
    }

    .pedm-product-card {
        padding: 8px;
        gap: 8px;
        border-radius: 10px;
    }

    .pedm-product-card-img {
        width: 58px;
        height: 58px;
        border-radius: 6px;
        flex-shrink: 0;
    }

    .pedm-product-title {
        font-size: 12px;
        margin-bottom: 3px;
        line-height: 1.35;
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .pedm-product-badges {
        gap: 4px;
        margin-bottom: 4px;
    }

    .pedm-badge {
        font-size: 9.5px;
        padding: 2px 5px;
    }

    .pedm-product-price {
        font-size: 11.5px;
        margin-bottom: 3px;
    }

    .pedm-product-specs-brief {
        font-size: 10.5px;
        margin-bottom: 5px;
    }

    .pedm-product-actions {
        display: flex;
        gap: 6px;
        width: 100%;
        margin-top: 5px;
    }

    .pedm-product-cta,
    .pedm-product-whatsapp-cta {
        flex: 1;
        padding: 6px 4px;
        font-size: 10.5px;
        text-align: center;
        justify-content: center;
        white-space: nowrap;
        border-radius: 6px;
    }

    .pedm-chat-footer {
        padding: 6px 8px;
        padding-bottom: max(6px, env(safe-area-inset-bottom, 6px));
        gap: 6px;
        background: #ffffff;
        border-top: 1px solid var(--pedm-border);
        flex-shrink: 0;
        position: sticky;
        bottom: 0;
        z-index: 20;
    }

    .pedm-footer-form {
        gap: 6px;
    }

    .pedm-btn-attach {
        width: 38px;
        height: 38px;
        font-size: 17px;
        border-radius: 10px;
        flex-shrink: 0;
    }

    .pedm-input-box {
        height: 38px;
        font-size: 16px; /* 16px avoids iOS Safari auto-zooming the viewport */
        padding: 0 10px;
        border-radius: 10px;
        flex: 1;
        min-width: 0;
    }

    .pedm-btn-submit {
        height: 38px;
        padding: 0 12px;
        font-size: 12.5px;
        border-radius: 10px;
        flex-shrink: 0;
        gap: 4px;
    }
}

@media (max-width: 480px) {
    .pedm-btn-reset .btn-label,
    .pedm-btn-install .btn-label {
        display: none;
    }

    .pedm-btn-reset,
    .pedm-btn-install {
        padding: 4px 7px;
        font-size: 13px;
    }

    .pedm-brand-details h1 {
        max-width: 100%;
    }
}

/* ==========================================================================
   Shortcode Wrapper & Theme Isolation
   ========================================================================== */
.pedm-shortcode-wrapper {
    width: 100%;
    margin: 0 auto;
    direction: rtl !important;
    text-align: right;
    box-sizing: border-box;
}

.pedm-shortcode-wrapper p:empty,
.pedm-shortcode-wrapper > p,
.pedm-shortcode-wrapper br {
    margin: 0;
    padding: 0;
}
.pedm-shortcode-wrapper p:empty {
    display: none !important;
}

/* ==========================================================================
   Real-Time Streaming Typing Cursor
   ========================================================================== */
.pedm-streaming-cursor {
    display: inline-block;
    width: 2px;
    height: 14px;
    background-color: var(--pedm-primary);
    margin-right: 4px;
    vertical-align: middle;
    animation: pedmCursorBlink 0.8s infinite;
}

@keyframes pedmCursorBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* ==========================================================================
   PWA & iOS Modal Styles
   ========================================================================== */
@media all and (display-mode: standalone) {
    .pedm-btn-install {
        display: none !important;
    }
}

.pedm-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(11, 17, 30, 0.75);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    padding: 16px;
    direction: rtl;
    animation: pedmFadeIn 0.25s ease;
}

.pedm-modal-card {
    background: #ffffff;
    border-radius: 16px;
    max-width: 420px;
    width: 100%;
    padding: 24px 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    border: 1px solid #e2e8f0;
    position: relative;
    color: #0f172a;
    animation: pedmSlideUp 0.25s ease;
}

.pedm-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 10px;
}

.pedm-modal-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 800;
    color: #091a2e;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pedm-modal-close {
    background: #f1f5f9;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.pedm-modal-close:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.pedm-modal-body {
    font-size: 13px;
    line-height: 1.7;
    color: #334155;
    margin-bottom: 18px;
}

.pedm-ios-steps {
    margin: 10px 0;
    padding-right: 20px;
}

.pedm-ios-steps li {
    margin-bottom: 8px;
}

.pedm-btn-modal-ok {
    width: 100%;
    background: linear-gradient(135deg, #091a2e 0%, #004d7a 100%);
    color: #ffffff;
    border: none;
    padding: 10px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 13.5px;
    cursor: pointer;
    font-family: inherit;
    transition: opacity 0.2s;
}

.pedm-btn-modal-ok:hover {
    opacity: 0.92;
}

@keyframes pedmFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes pedmSlideUp {
    from { transform: translateY(16px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ==========================================================================
   ParsEDM AI Engine - Unified Microsoft Fluent 3D Sprite Sheet System
   Single HTTP Request, zero-layout-shift, ultra-high performance.
   ========================================================================== */

.pedm-3d {
    display: inline-block;
    vertical-align: middle;
    background-image: var(--pedm-sprites-url, url('/wp-content/plugins/parsedm-ai-engine/assets/images/3d/pedm-fluent-3d-sprites.webp?v=4.1.0'));
    background-repeat: no-repeat;
    background-size: 192px 144px; /* Display grid scaled for 24px base */
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    object-fit: contain;
}

/* Size Modifiers */
.pedm-3d.sz-14 { width: 14px; height: 14px; background-size: 112px 84px; }
.pedm-3d.sz-16 { width: 16px; height: 16px; background-size: 128px 96px; }
.pedm-3d.sz-18 { width: 18px; height: 18px; background-size: 144px 108px; }
.pedm-3d.sz-20 { width: 20px; height: 20px; background-size: 160px 120px; }
.pedm-3d.sz-24 { width: 24px; height: 24px; background-size: 192px 144px; }
.pedm-3d.sz-32 { width: 32px; height: 32px; background-size: 256px 192px; }

/* Individual Icon Coordinate Classes */
.pedm-3d-whatsapp { background-position: 0.00% 0.00%; }
.pedm-3d-send { background-position: 14.29% 0.00%; }
.pedm-3d-catalog { background-position: 28.57% 0.00%; }
.pedm-3d-inquiries { background-position: 42.86% 0.00%; }
.pedm-3d-lightning { background-position: 57.14% 0.00%; }
.pedm-3d-database { background-position: 71.43% 0.00%; }
.pedm-3d-robot { background-position: 85.71% 0.00%; }
.pedm-3d-clock { background-position: 100.00% 0.00%; }
.pedm-3d-pin { background-position: 0.00% 20.00%; }
.pedm-3d-diamond { background-position: 14.29% 20.00%; }
.pedm-3d-gear { background-position: 28.57% 20.00%; }
.pedm-3d-box { background-position: 42.86% 20.00%; }
.pedm-3d-bulb { background-position: 57.14% 20.00%; }
.pedm-3d-refresh { background-position: 71.43% 20.00%; }
.pedm-3d-trophy { background-position: 85.71% 20.00%; }
.pedm-3d-bullseye { background-position: 100.00% 20.00%; }
.pedm-3d-wave { background-position: 0.00% 40.00%; }
.pedm-3d-check { background-position: 14.29% 40.00%; }
.pedm-3d-cross { background-position: 28.57% 40.00%; }
.pedm-3d-alert { background-position: 42.86% 40.00%; }
.pedm-3d-chart { background-position: 57.14% 40.00%; }
.pedm-3d-clipboard { background-position: 71.43% 40.00%; }
.pedm-3d-download { background-position: 85.71% 40.00%; }
.pedm-3d-camera { background-position: 100.00% 40.00%; }
.pedm-3d-desktop { background-position: 0.00% 60.00%; }
.pedm-3d-mobile { background-position: 14.29% 60.00%; }
.pedm-3d-install { background-position: 28.57% 60.00%; }
.pedm-3d-reset { background-position: 42.86% 60.00%; }
.pedm-3d-eye { background-position: 57.14% 60.00%; }
.pedm-3d-trash { background-position: 71.43% 60.00%; }
.pedm-3d-lock { background-position: 85.71% 60.00%; }
.pedm-3d-shield { background-position: 100.00% 60.00%; }
.pedm-3d-shopping { background-position: 0.00% 80.00%; }
.pedm-3d-ruler { background-position: 14.29% 80.00%; }
.pedm-3d-nut-bolt { background-position: 28.57% 80.00%; }
.pedm-3d-oil-drum { background-position: 42.86% 80.00%; }
.pedm-3d-test-tube { background-position: 57.14% 80.00%; }
.pedm-3d-sparkles { background-position: 71.43% 80.00%; }
.pedm-3d-settings { background-position: 85.71% 80.00%; }
.pedm-3d-card-file { background-position: 100.00% 80.00%; }
.pedm-3d-status-online { background-position: 0.00% 100.00%; }
.pedm-3d-status-fast { background-position: 14.29% 100.00%; }
.pedm-3d-status-orange { background-position: 28.57% 100.00%; }
.pedm-3d-status-error { background-position: 42.86% 100.00%; }
.pedm-3d-sync { background-position: 57.14% 100.00%; }
.pedm-3d-logout { background-position: 71.43% 100.00%; }
.pedm-3d-email { background-position: 85.71% 100.00%; }
.pedm-3d-chat { background-position: 100.00% 100.00%; }



