/* ==========================================================
   Order Chat Widget — Production Styles
   Namespaced under .ocw-widget to avoid WP theme collisions
   ========================================================== */

/* --- Floating trigger button --- */
.ocw-trigger-btn {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: auto;
    height: 60px;
    border-radius: 5px !important;
    background: #000;
    color: #fff;
    border: 1px solid #FFF;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999998;
    transition: transform 0.25s, box-shadow 0.25s;
}

.ocw-trigger-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(59, 130, 246, 0.55);
}

.ocw-trigger-btn svg {
    width: 28px;
    height: 28px;
    transition: transform 0.25s;
}

.ocw-trigger-btn.open svg.ocw-icon-chat {
    display: none;
}

.ocw-trigger-btn.open svg.ocw-icon-close {
    display: block;
}

.ocw-trigger-btn:not(.open) svg.ocw-icon-chat {
    display: block;
}

.ocw-trigger-btn:not(.open) svg.ocw-icon-close {
    display: none;
}

@media(max-width: 767px) {

    .ocw-trigger-btn {
        right: 0;
        height: 40px;
        padding: 0 10px;
    }
}

@media (max-width: 480px) {

    .ocw-trigger-btn {
        bottom: 16px;
        right: 0;
        margin-right: 0;
    }
}


/* --- Popup container --- */
.ocw-widget {
    position: fixed;
    bottom: 100px;
    right: 28px;
    width: 400px;
    max-height: 600px;
    border-radius: 16px;
    overflow: hidden;
    display: none;
    flex-direction: column;
    z-index: 999999;
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.35);
    border: 1px solid var(--ocw-border);
}

.ocw-widget.ocw-open {
    display: flex;
}

/* --- CSS custom properties (scoped) --- */
.ocw-widget {
    --ocw-bg-primary: #0f1419;
    --ocw-bg-secondary: #1a1f26;
    --ocw-bg-tertiary: #252b33;
    --ocw-accent: #3b82f6;
    --ocw-accent-hover: #2563eb;
    --ocw-accent-soft: rgba(59, 130, 246, 0.15);
    --ocw-text-primary: #e7e9ea;
    --ocw-text-secondary: #8b98a5;
    --ocw-text-muted: #5c6b7a;
    --ocw-border: #2f3943;
    --ocw-user-bubble: #3b82f6;
    --ocw-assistant-bubble: #252b33;
    --ocw-success: #22c55e;
    --ocw-warning: #f59e0b;
    --ocw-error: #ef4444;
}

@media (max-width: 480px) {
    .ocw-widget {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
}

/* --- Widget header --- */
.ocw-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    background: var(--ocw-bg-secondary);
    border-bottom: 1px solid var(--ocw-border);
}

.ocw-header-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--ocw-text-primary);
    margin: 0;
}

.ocw-header-subtitle {
    font-size: 0.75rem;
    color: var(--ocw-text-muted);
    margin: 0;
}

/* Reference number badge shown in the header */
.ocw-ref-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-family: monospace;
    color: var(--ocw-success);
    background: rgba(34, 197, 94, 0.12);
    border: 1px solid rgba(34, 197, 94, 0.3);
    padding: 2px 8px;
    border-radius: 4px;
    margin-top: 4px;
    animation: ocwMessageIn 0.3s ease-out;
}

.ocw-header-close {
    background: transparent;
    border: none;
    color: var(--ocw-text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.ocw-header-close:hover {
    background: var(--ocw-bg-tertiary);
    color: var(--ocw-text-primary);
}

.ocw-header-close svg {
    width: 20px;
    height: 20px;
}

/* --- Status bar (minimal for production) --- */
.ocw-status-bar {
    display: none; /* hidden by default, shown when order is active */
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    background: var(--ocw-bg-primary);
    border-bottom: 1px solid var(--ocw-border);
    font-size: 0.75rem;
}

.ocw-status-bar.ocw-visible {
    display: flex;
}

.ocw-status-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ocw-status-label {
    color: var(--ocw-text-muted);
}

.ocw-status-value {
    font-family: monospace;
    font-size: 0.7rem;
    color: var(--ocw-text-secondary);
    background: var(--ocw-bg-tertiary);
    padding: 3px 8px;
    border-radius: 5px;
}

.ocw-status-value.ocw-active {
    color: var(--ocw-success);
    background: rgba(34, 197, 94, 0.12);
}

.ocw-status-value.ocw-warning {
    color: var(--ocw-warning);
    background: rgba(245, 158, 11, 0.12);
}

.ocw-status-value.ocw-ref-active {
    color: var(--ocw-success);
    background: rgba(34, 197, 94, 0.12);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

/* --- Messages area --- */
.ocw-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
    background: var(--ocw-bg-primary);
    min-height: 200px;
    max-height: 380px;
}

@media (max-width: 480px) {

    .ocw-messages {
        max-height: calc(100vh - 200px);
    }
}


.ocw-messages::-webkit-scrollbar {
    width: 5px;
}

.ocw-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ocw-messages::-webkit-scrollbar-thumb {
    background: var(--ocw-border);
    border-radius: 3px;
}

/* --- Messages --- */
.ocw-message {
    max-width: 85%;
    animation: ocwMessageIn 0.3s ease-out;
}

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

.ocw-message.ocw-user {
    align-self: flex-end;
}

.ocw-message.ocw-assistant {
    align-self: flex-start;
}

.ocw-message-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    line-height: 1.5;
    font-size: 0.875rem;
}

.ocw-message.ocw-user .ocw-message-bubble {
    background: var(--ocw-user-bubble);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.ocw-message.ocw-assistant .ocw-message-bubble {
    background: var(--ocw-assistant-bubble);
    border: 1px solid var(--ocw-border);
    color: var(--ocw-text-primary);
    border-bottom-left-radius: 4px;
}

/* Links inside bubbles */
.ocw-message-bubble a {
    color: #60a5fa;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.ocw-message-bubble a:hover {
    color: #93c5fd;
}

.ocw-message.ocw-user .ocw-message-bubble a {
    color: #bfdbfe;
}

.ocw-message.ocw-user .ocw-message-bubble a:hover {
    color: #fff;
}

.ocw-message-bubble strong { font-weight: 600; }
.ocw-message-bubble em     { font-style: italic; }
.ocw-message-bubble code   {
    font-family: monospace;
    font-size: 0.85em;
    background: rgba(0,0,0,0.2);
    padding: 2px 6px;
    border-radius: 4px;
}

.ocw-message-meta {
    font-size: 0.65rem;
    color: var(--ocw-text-muted);
    margin-top: 4px;
    padding: 0 4px;
}

.ocw-message.ocw-user .ocw-message-meta {
    text-align: right;
}

/* --- Typing indicator --- */
.ocw-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 14px;
    align-self: flex-start;
}

.ocw-typing-indicator span {
    width: 7px;
    height: 7px;
    background: var(--ocw-text-muted);
    border-radius: 50%;
    animation: ocwTyping 1.4s infinite;
}

.ocw-typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.ocw-typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes ocwTyping {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30%           { transform: translateY(-5px); opacity: 1; }
}

/* --- Analyzing indicator --- */
.ocw-analyzing-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: linear-gradient(135deg, rgba(59,130,246,0.1), rgba(139,92,246,0.1));
    border: 1px solid rgba(59,130,246,0.3);
    border-radius: 10px;
    margin: 6px 0;
    animation: ocwAnalyzeIn 0.3s ease-out;
}

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

.ocw-analyzing-indicator .ocw-doc-icon {
    width: 28px;
    height: 28px;
    animation: ocwDocPulse 1.5s ease-in-out infinite;
}

@keyframes ocwDocPulse {
    0%, 100% { transform: scale(1); opacity: 0.7; }
    50%      { transform: scale(1.1); opacity: 1; }
}

.ocw-analyzing-indicator .ocw-analyze-text { flex: 1; }

.ocw-analyzing-indicator .ocw-analyze-title {
    font-weight: 600;
    color: var(--ocw-text-primary);
    font-size: 0.875rem;
    margin-bottom: 3px;
}

.ocw-analyzing-indicator .ocw-analyze-subtitle {
    color: var(--ocw-text-secondary);
    font-size: 0.75rem;
}

.ocw-analyzing-indicator .ocw-progress-bar {
    width: 100%;
    height: 3px;
    background: rgba(59,130,246,0.2);
    border-radius: 2px;
    margin-top: 6px;
    overflow: hidden;
}

.ocw-analyzing-indicator .ocw-progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--ocw-accent), #8b5cf6);
    border-radius: 2px;
    animation: ocwProgressSlide 2s ease-in-out infinite;
}

@keyframes ocwProgressSlide {
    0%   { width: 0%;  margin-left: 0%; }
    50%  { width: 40%; margin-left: 30%; }
    100% { width: 0%;  margin-left: 100%; }
}

/* --- Input area --- */
.ocw-input-area {
    display: flex;
    gap: 8px;
    padding: 14px;
    background: var(--ocw-bg-tertiary);
    border-top: 1px solid var(--ocw-border);
    align-items: center;
}

.ocw-input-area.ocw-analyzing .ocw-message-input {
    background: var(--ocw-bg-tertiary);
    cursor: not-allowed;
}

.ocw-input-area.ocw-analyzing .ocw-send-btn,
.ocw-input-area.ocw-analyzing .ocw-attach-btn {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.ocw-input-wrapper {
    flex: 1;
}

.ocw-message-input {
    width: 100%;
    padding: 12px 14px;
    background: var(--ocw-bg-secondary);
    border: 1px solid var(--ocw-border);
    border-radius: 10px;
    color: var(--ocw-text-primary);
    font-family: inherit;
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.ocw-message-input:focus {
    border-color: var(--ocw-accent);
    box-shadow: 0 0 0 3px var(--ocw-accent-soft);
}

.ocw-message-input::placeholder {
    color: var(--ocw-text-muted);
}

.ocw-send-btn {
    padding: 12px 18px;
    background: var(--ocw-accent);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
}

.ocw-send-btn:hover:not(:disabled) {
    background: var(--ocw-accent-hover);
    transform: translateY(-1px);
}

.ocw-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* --- Attach button --- */
.ocw-attach-btn {
    padding: 12px;
    background: var(--ocw-bg-secondary);
    border: 1px solid var(--ocw-border);
    color: var(--ocw-text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.ocw-attach-btn:hover:not(.ocw-disabled) {
    background: var(--ocw-bg-tertiary);
    color: var(--ocw-text-primary);
    border-color: var(--ocw-accent);
}

.ocw-attach-btn.ocw-disabled {
    opacity: 0.4;
    cursor: not-allowed;
    color: var(--ocw-text-muted);
}

.ocw-attach-btn.ocw-enabled {
    opacity: 1;
    color: var(--ocw-success);
    border-color: var(--ocw-success);
    background: rgba(34, 197, 94, 0.1);
}

.ocw-attach-btn.ocw-enabled:hover {
    background: rgba(34, 197, 94, 0.2);
}

.ocw-attach-btn svg {
    width: 18px;
    height: 18px;
}

/* Hidden file input */
.ocw-file-input {
    display: none;
}

/* --- File preview area --- */
.ocw-file-preview-area {
    display: none;
    padding: 10px 14px;
    background: var(--ocw-bg-tertiary);
    border-top: 1px solid var(--ocw-border);
    flex-wrap: wrap;
    gap: 6px;
    height: 150px;
    overflow-y: auto;
}

.ocw-file-preview-area.ocw-has-files {
    display: flex;
}

.ocw-file-preview-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--ocw-bg-secondary);
    border: 1px solid var(--ocw-border);
    border-radius: 6px;
    padding: 2px 10px;
    font-size: 0.75rem;
    color: var(--ocw-text-secondary);
    animation: ocwFileIn 0.2s ease-out;
}

@keyframes ocwFileIn {
    from { opacity: 0; transform: scale(0.9); }
    to   { opacity: 1; transform: scale(1); }
}

.ocw-file-preview-item .ocw-file-name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ocw-file-preview-item .ocw-file-size {
    font-size: 0.65rem;
    color: var(--ocw-text-muted);
}

.ocw-file-preview-item .ocw-file-remove {
    width: 16px;
    height: 16px;
    background: transparent;
    border: none;
    color: var(--ocw-text-muted);
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    transition: all 0.15s;
}

.ocw-file-preview-item .ocw-file-remove:hover {
    background: var(--ocw-error);
    color: #fff;
}

.ocw-file-preview-item .ocw-file-remove svg {
    width: 12px;
    height: 12px;
}

/* --- Attachments inside message bubbles --- */
.ocw-message-attachments {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.ocw-message.ocw-assistant .ocw-message-attachments {
    border-top-color: var(--ocw-border);
}

.ocw-attachment-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    background: rgba(0,0,0,0.15);
    border-radius: 6px;
    font-size: 0.75rem;
}

.ocw-message.ocw-assistant .ocw-attachment-item {
    background: var(--ocw-bg-tertiary);
}

.ocw-attachment-item .ocw-attachment-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ocw-attachment-item .ocw-attachment-size {
    font-size: 0.65rem;
    opacity: 0.7;
    flex-shrink: 0;
}

/* --- Empty state --- */
.ocw-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--ocw-text-muted);
    text-align: center;
    padding: 32px 20px;
}

.ocw-empty-state svg {
    width: 40px;
    height: 40px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.ocw-empty-state p {
    font-size: 0.85rem;
    line-height: 1.6;
}

/* --- Toasts --- */
.ocw-error-toast,
.ocw-info-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 0.8125rem;
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000000;
}

.ocw-error-toast {
    background: var(--ocw-error);
    color: #fff;
}

.ocw-info-toast {
    border: 1px solid var(--ocw-border);
    background-color: #000;
    color: #FFF;
}

.ocw-error-toast.ocw-show,
.ocw-info-toast.ocw-show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* --- New conversation button --- */
.ocw-footer-actions {
    display: flex;
    padding: 8px 14px;
    background: var(--ocw-bg-secondary);
    border-top: 1px solid var(--ocw-border);
}

.ocw-new-chat-btn {
    width: 100%;
    padding: 8px;
    background: transparent;
    border: 1px solid var(--ocw-border);
    color: var(--ocw-text-secondary);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s;
}

.ocw-new-chat-btn:hover {
    background: var(--ocw-bg-tertiary);
    color: var(--ocw-text-primary);
    border-color: var(--ocw-text-muted);
}
