.h3-ai-chatbot {
    --h3-ai-primary: #111827;
    --h3-ai-accent: #22c55e;
    position: fixed;
    bottom: 24px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.h3-ai-position-right { right: 24px; }
.h3-ai-position-left { left: 24px; }

.h3-ai-toggle {
    width: 64px;
    height: 64px;
    border-radius: 999px;
    border: 0;
    cursor: pointer;
    background: linear-gradient(135deg, var(--h3-ai-primary), var(--h3-ai-accent));
    color: #fff;
    box-shadow: 0 18px 44px rgba(15, 23, 42, 0.32);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
}

.h3-ai-toggle-ring {
    position: absolute;
    inset: -7px;
    border-radius: inherit;
    border: 1px solid color-mix(in srgb, var(--h3-ai-accent) 42%, transparent);
    opacity: .75;
}

.h3-ai-toggle:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 24px 56px rgba(15, 23, 42, 0.38);
}

.h3-ai-toggle-icon {
    font-size: 27px;
    line-height: 1;
    position: relative;
}

.h3-ai-panel {
    position: absolute;
    bottom: 84px;
    width: 390px;
    max-width: calc(100vw - 32px);
    height: 570px;
    max-height: calc(100vh - 125px);
    background: #ffffff;
    border-radius: 26px;
    overflow: hidden;
    box-shadow: 0 28px 85px rgba(15, 23, 42, 0.30);
    display: none;
    flex-direction: column;
    border: 1px solid rgba(15, 23, 42, 0.08);
}

.h3-ai-position-right .h3-ai-panel { right: 0; }
.h3-ai-position-left .h3-ai-panel { left: 0; }
.h3-ai-open .h3-ai-panel { display: flex; }

.h3-ai-header {
    padding: 18px;
    background: radial-gradient(circle at top right, color-mix(in srgb, var(--h3-ai-accent) 30%, transparent), transparent 34%), linear-gradient(135deg, var(--h3-ai-primary), #111827 72%);
    color: #fff;
    display: flex;
    align-items: center;
    gap: 12px;
}

.h3-ai-agent-avatar {
    width: 42px;
    height: 42px;
    border-radius: 16px;
    background: rgba(255,255,255,0.14);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 21px;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12);
}

.h3-ai-header-copy {
    flex: 1;
    min-width: 0;
}

.h3-ai-header strong {
    display: block;
    font-size: 16px;
    line-height: 1.2;
    letter-spacing: -0.01em;
}

.h3-ai-header span {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    opacity: 0.86;
    margin-top: 5px;
}

.h3-ai-header span i {
    width: 7px;
    height: 7px;
    display: inline-block;
    border-radius: 50%;
    background: var(--h3-ai-accent);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--h3-ai-accent) 18%, transparent);
}

.h3-ai-close {
    background: rgba(255,255,255,0.14);
    color: #fff;
    border: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
}

.h3-ai-intro,
.h3-ai-chat-area {
    flex: 1;
    min-height: 0;
}

.h3-ai-intro {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 22px;
    background: linear-gradient(180deg, #f8fafc, #eef2f7);
}

.h3-ai-intro-card {
    width: 100%;
    background: rgba(255,255,255,0.88);
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 24px;
    padding: 22px;
    box-shadow: 0 18px 44px rgba(15, 23, 42, 0.08);
}

.h3-ai-intro-icon {
    width: 48px;
    height: 48px;
    border-radius: 18px;
    background: color-mix(in srgb, var(--h3-ai-accent) 13%, #fff);
    color: var(--h3-ai-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 14px;
}

.h3-ai-intro-card h3 {
    margin: 0;
    font-size: 20px;
    line-height: 1.2;
    color: #0f172a;
    letter-spacing: -0.02em;
}

.h3-ai-intro-card p {
    margin: 8px 0 18px;
    color: #64748b;
    font-size: 13px;
    line-height: 1.5;
}

.h3-ai-lead-form label {
    display: block;
    margin-bottom: 12px;
}

.h3-ai-lead-form span {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: #334155;
    margin-bottom: 6px;
}

.h3-ai-lead-form input {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 14px;
    padding: 12px 13px;
    font-size: 14px;
    outline: none;
    background: #fff;
    color: #111827;
}

.h3-ai-lead-form input:focus {
    border-color: var(--h3-ai-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--h3-ai-accent) 18%, transparent);
}

.h3-ai-lead-form button {
    width: 100%;
    border: 0;
    border-radius: 14px;
    padding: 13px 16px;
    cursor: pointer;
    background: linear-gradient(135deg, var(--h3-ai-primary), var(--h3-ai-accent));
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    margin-top: 4px;
}

.h3-ai-lead-error {
    display: block;
    color: #dc2626;
    min-height: 18px;
    margin-top: 10px;
    font-size: 12px;
}

.h3-ai-chat-area {
    display: flex;
    flex-direction: column;
    background: #f8fafc;
}

.h3-ai-messages {
    flex: 1;
    padding: 18px;
    overflow-y: auto;
    background: linear-gradient(180deg, #f8fafc, #eef2f7);
}

.h3-ai-message {
    display: flex;
    margin-bottom: 12px;
}

.h3-ai-message-user { justify-content: flex-end; }
.h3-ai-message-assistant { justify-content: flex-start; }

.h3-ai-bubble {
    max-width: 82%;
    padding: 12px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    white-space: normal;
    overflow-wrap: anywhere;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.06);
}

.h3-ai-message-user .h3-ai-bubble {
    background: linear-gradient(135deg, var(--h3-ai-primary), color-mix(in srgb, var(--h3-ai-primary) 70%, var(--h3-ai-accent)));
    color: #fff;
    border-bottom-right-radius: 6px;
}

.h3-ai-message-assistant .h3-ai-bubble {
    background: #fff;
    color: #111827;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-bottom-left-radius: 6px;
}

.h3-ai-bubble a {
    color: inherit;
    text-decoration: underline;
}

.h3-ai-form {
    padding: 12px;
    display: flex;
    gap: 8px;
    background: rgba(255,255,255,0.96);
    border-top: 1px solid rgba(15, 23, 42, 0.08);
}

.h3-ai-input {
    flex: 1;
    resize: none;
    border: 1px solid rgba(15, 23, 42, 0.14);
    border-radius: 16px;
    padding: 12px 13px;
    font-size: 14px;
    line-height: 1.35;
    outline: none;
    max-height: 100px;
    background: #fff;
    color: #111827;
}

.h3-ai-input:focus {
    border-color: var(--h3-ai-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--h3-ai-accent) 16%, transparent);
}

.h3-ai-send {
    width: 46px;
    height: 46px;
    border: 0;
    border-radius: 16px;
    background: var(--h3-ai-accent);
    color: #fff;
    font-size: 17px;
    cursor: pointer;
    box-shadow: 0 12px 24px color-mix(in srgb, var(--h3-ai-accent) 30%, transparent);
}

.h3-ai-loader .h3-ai-bubble span {
    width: 7px;
    height: 7px;
    display: inline-block;
    border-radius: 50%;
    background: #94a3b8;
    margin: 0 2px;
    animation: h3AiPulse 1s infinite ease-in-out;
}

.h3-ai-loader .h3-ai-bubble span:nth-child(2) { animation-delay: 0.15s; }
.h3-ai-loader .h3-ai-bubble span:nth-child(3) { animation-delay: 0.3s; }

.is-hidden { display: none !important; }

@keyframes h3AiPulse {
    0%, 80%, 100% { opacity: .35; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-4px); }
}

.h3-ai-admin-wrap .h3-ai-admin-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    max-width: 1200px;
    margin-top: 20px;
}

.h3-ai-admin-card {
    background: #fff;
    border: 1px solid #dcdcde;
    border-radius: 16px;
    padding: 18px 20px;
    box-shadow: 0 8px 24px rgba(15,23,42,0.05);
}

.h3-ai-admin-card h2 {
    margin-top: 0;
    padding-bottom: 10px;
    border-bottom: 1px solid #f0f0f1;
}

.h3-ai-logs-wrap > h1 {
    font-size: 28px;
    letter-spacing: -0.02em;
}

.h3-ai-logs-grid {
    display: grid;
    grid-template-columns: 330px minmax(0, 1fr);
    gap: 18px;
    max-width: 1280px;
    margin-top: 20px;
}

.h3-ai-log-list {
    max-height: 76vh;
    overflow: auto;
    padding: 14px;
    background: #f8fafc;
}

.h3-ai-log-list h2,
.h3-ai-log-detail h2 {
    font-size: 18px;
}

.h3-ai-log-item {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 10px;
    padding: 12px;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    margin-bottom: 10px;
    background: #fff;
    text-decoration: none;
    color: #111827;
    transition: border-color .16s ease, background .16s ease, transform .16s ease;
}

.h3-ai-log-item:hover,
.h3-ai-log-item.is-active {
    border-color: #2271b1;
    background: #f0f6fc;
    transform: translateY(-1px);
}

.h3-ai-log-avatar {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background: #e0f2fe;
    color: #0369a1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
}

.h3-ai-log-meta {
    min-width: 0;
}

.h3-ai-log-meta strong,
.h3-ai-log-meta span,
.h3-ai-log-meta small {
    display: block;
}

.h3-ai-log-meta strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.h3-ai-log-meta span {
    color: #64748b;
    margin-top: 2px;
    font-size: 12px;
}

.h3-ai-log-meta small {
    color: #475569;
    margin-top: 5px;
    line-height: 1.35;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.h3-ai-session-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 12px 0 16px;
}

.h3-ai-session-summary div {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 10px 12px;
}

.h3-ai-session-summary span {
    display: block;
    color: #64748b;
    font-size: 12px;
    margin-bottom: 3px;
}

.h3-ai-session-summary strong,
.h3-ai-session-summary a {
    color: #111827;
    font-size: 13px;
    word-break: break-word;
}

.h3-ai-admin-chat-box {
    background: linear-gradient(180deg, #f8fafc, #eef2f7);
    border: 1px solid #e5e7eb;
    border-radius: 18px;
    padding: 16px;
    max-height: 67vh;
    overflow: auto;
}

.h3-ai-admin-message {
    border-radius: 16px;
    padding: 11px 13px;
    margin-bottom: 12px;
    max-width: 720px;
    box-shadow: 0 7px 18px rgba(15, 23, 42, 0.05);
}

.h3-ai-admin-message-user {
    margin-left: auto;
    background: #111827;
    color: #fff;
    border-bottom-right-radius: 6px;
}

.h3-ai-admin-message-assistant {
    margin-right: auto;
    background: #fff;
    color: #111827;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-bottom-left-radius: 6px;
}

.h3-ai-admin-message-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.h3-ai-admin-message strong {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.h3-ai-admin-message span {
    color: inherit;
    opacity: .7;
    font-size: 11px;
}

.h3-ai-admin-message p {
    margin: 0;
    white-space: normal;
    line-height: 1.5;
    font-size: 13px;
}

@media (max-width: 960px) {
    .h3-ai-logs-grid,
    .h3-ai-session-summary {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 782px) {
    .h3-ai-chatbot {
        right: 16px;
        left: 16px;
        bottom: 16px;
    }

    .h3-ai-position-left,
    .h3-ai-position-right {
        left: 16px;
        right: 16px;
    }

    .h3-ai-panel {
        width: 100%;
        height: min(560px, calc(100vh - 112px));
        bottom: 78px;
    }

    .h3-ai-position-left .h3-ai-panel,
    .h3-ai-position-right .h3-ai-panel {
        left: 0;
        right: 0;
    }

    .h3-ai-admin-wrap .h3-ai-admin-grid {
        grid-template-columns: 1fr;
    }
}

.h3-ai-products {
    display: grid;
    gap: 10px;
    margin: -2px 0 14px;
    max-width: 92%;
}

.h3-ai-product-card {
    display: grid;
    grid-template-columns: 78px minmax(0, 1fr);
    gap: 10px;
    background: #fff;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 18px;
    padding: 10px;
    box-shadow: 0 10px 26px rgba(15, 23, 42, 0.07);
}

.h3-ai-product-image {
    display: block;
    width: 78px;
    height: 78px;
    border-radius: 14px;
    background: #f1f5f9;
    overflow: hidden;
}

.h3-ai-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.h3-ai-product-info {
    min-width: 0;
}

.h3-ai-product-title {
    display: block;
    color: #0f172a;
    text-decoration: none;
    font-weight: 800;
    font-size: 13px;
    line-height: 1.25;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.h3-ai-product-info p {
    margin: 5px 0 7px;
    color: #64748b;
    font-size: 12px;
    line-height: 1.35;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.h3-ai-product-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.h3-ai-product-meta strong {
    color: #111827;
    font-size: 13px;
    line-height: 1.2;
}

.h3-ai-product-meta del {
    color: #94a3b8;
    font-weight: 500;
    margin-right: 4px;
}

.h3-ai-product-meta ins {
    text-decoration: none;
}

.h3-ai-product-stock {
    flex: 0 0 auto;
    color: #16a34a;
    background: #dcfce7;
    border-radius: 999px;
    padding: 3px 7px;
    font-size: 10px;
    font-weight: 800;
}

.h3-ai-product-buy {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 8px 12px;
    border-radius: 999px;
    background: var(--h3-ai-accent);
    color: #fff !important;
    text-decoration: none !important;
    font-size: 12px;
    font-weight: 800;
    box-shadow: 0 8px 18px color-mix(in srgb, var(--h3-ai-accent) 26%, transparent);
}

@media (max-width: 420px) {
    .h3-ai-products {
        max-width: 100%;
    }

    .h3-ai-product-card {
        grid-template-columns: 68px minmax(0, 1fr);
    }

    .h3-ai-product-image {
        width: 68px;
        height: 68px;
    }
}
