/* Pipe Chat - Estilos del Widget de Chat */

/* =========================================================
   Variables CSS (dark theme por defecto)
   Sobreescritas por el bloque <style> inline del template
   ========================================================= */
#pipe-chat-widget-container {
    --pipe-header-bg       : #111827;
    --pipe-chat-bg         : #0f172a;
    --pipe-accent          : #25D366;

    /* Derivados — se calculan en base a los anteriores */
    --pipe-bot-bubble-bg   : #1e293b;
    --pipe-bot-bubble-text : #e2e8f0;
    --pipe-bot-bubble-border: #334155;
    --pipe-user-bubble-bg  : #1a3a2a;
    --pipe-user-bubble-text: #d1fae5;
    --pipe-input-bg        : #1e293b;
    --pipe-input-border    : #334155;
    --pipe-input-text      : #e2e8f0;
    --pipe-input-area-bg   : #111827;
    --pipe-input-area-border: #1e293b;
    --pipe-time-color      : #64748b;
    --pipe-scrollbar       : #334155;
    --pipe-typing-bg       : #111827;
    --pipe-typing-dot      : #64748b;
    --pipe-window-shadow   : rgba(0, 0, 0, 0.6);
}

/* Contenedor del Widget */
#pipe-chat-widget-container {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.pipe-chat-widget-right {
    bottom: 20px;
    right: 20px;
}

.pipe-chat-widget-left {
    bottom: 20px;
    left: 20px;
}

/* Botón de Chat */
.pipe-chat-button {
    width: 60px !important;
    height: 60px !important;
    border-radius: 50% !important;
    border: none !important;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    display: flex !important;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    padding: 0 !important;
    outline: none;
}

.pipe-chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
}

.pipe-chat-button:active {
    transform: scale(0.95);
}

.pipe-chat-icon {
    width: 32px;
    height: 32px;
    position: relative;
    z-index: 1;
}

/* Ventana de Chat */
.pipe-chat-window {
    position: absolute;
    bottom: 80px;
    width: 370px;
    max-width: calc(100vw - 40px);
    height: 550px;
    max-height: calc(100vh - 120px);
    background: var(--pipe-chat-bg);
    border-radius: 12px;
    box-shadow: 0 8px 32px var(--pipe-window-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

.pipe-chat-widget-right .pipe-chat-window {
    right: 0;
}

.pipe-chat-widget-left .pipe-chat-window {
    left: 0;
}

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

/* Encabezado */
.pipe-chat-header {
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #ffffff;
    background: var(--pipe-header-bg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.pipe-chat-header-info {
    display: flex;
    flex-direction: column;
}

.pipe-chat-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #ffffff;
}

.pipe-chat-status {
    font-size: 12px;
    opacity: 0.85;
    margin-top: 2px;
    color: #d1fae5;
}

.pipe-chat-status::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    margin-right: 5px;
    vertical-align: middle;
}

.pipe-chat-close {
    background: transparent !important;
    border: none !important;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: background 0.2s;
    outline: none;
}

.pipe-chat-close:hover {
    background: rgba(255, 255, 255, 0.12) !important;
}

/* Área de Mensajes */
.pipe-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--pipe-chat-bg);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pipe-chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

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

/* Burbujas de Mensaje */
.pipe-chat-message {
    max-width: 80%;
    animation: fadeIn 0.3s ease;
}

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

.pipe-chat-bot-message {
    align-self: flex-start;
}

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

.pipe-chat-message-text {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.pipe-chat-bot-message .pipe-chat-message-text {
    background: var(--pipe-bot-bubble-bg);
    color: var(--pipe-bot-bubble-text);
    border: 1px solid var(--pipe-bot-bubble-border);
    border-top-left-radius: 4px;
}

.pipe-chat-user-message .pipe-chat-message-text {
    background: var(--pipe-user-bubble-bg);
    color: var(--pipe-user-bubble-text);
    border-top-right-radius: 4px;
}

.pipe-chat-message-time {
    font-size: 11px;
    color: var(--pipe-time-color);
    margin-top: 4px;
    display: block;
}

.pipe-chat-bot-message .pipe-chat-message-time {
    text-align: left;
}

.pipe-chat-user-message .pipe-chat-message-time {
    text-align: right;
}

/* Área de Entrada */
.pipe-chat-input-area {
    display: flex;
    padding: 12px 16px;
    background: var(--pipe-input-area-bg);
    border-top: 1px solid var(--pipe-input-area-border);
    gap: 10px;
}

.pipe-chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--pipe-input-border);
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    background: var(--pipe-input-bg);
    color: var(--pipe-input-text);
}

.pipe-chat-input::placeholder {
    color: #64748b;
}

.pipe-chat-input:focus {
    border-color: var(--pipe-accent);
}

.pipe-chat-send {
    background: transparent !important;
    border: none !important;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
}

.pipe-chat-send:hover {
    background: rgba(255, 255, 255, 0.06) !important;
}

.pipe-chat-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Indicador de Escritura */
.pipe-chat-typing {
    padding: 10px 20px;
    background: var(--pipe-typing-bg);
    border-top: 1px solid var(--pipe-input-area-border);
}

.pipe-chat-typing-dots {
    display: flex;
    gap: 4px;
}

.pipe-chat-typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--pipe-typing-dot);
    border-radius: 50%;
    animation: typingDot 1.4s infinite;
}

.pipe-chat-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.pipe-chat-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    30% {
        opacity: 1;
        transform: scale(1);
    }
}

/* =========================================================
   Botón de enlace estilo WhatsApp
   ========================================================= */

.pipe-link-divider {
    border: none;
    border-top: 1px solid var(--pipe-bot-bubble-border);
    margin: 8px 0 6px;
}

.pipe-link-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    margin-top: 4px;
    border-radius: 8px;
    border: 1px solid var(--pipe-bot-bubble-border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--pipe-accent) !important;
    text-decoration: none !important;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s, border-color 0.2s;
    word-break: break-all;
}

.pipe-link-btn:hover {
    background: rgba(255, 255, 255, 0.09);
    border-color: var(--pipe-accent);
    text-decoration: none !important;
}

.pipe-link-btn__icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    color: var(--pipe-accent);
}

.pipe-link-btn__icon svg {
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.pipe-link-btn__label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Mensaje de Error */
.pipe-chat-error {
    background: #2d1b1b !important;
    border-color: #7f1d1d !important;
    color: #fca5a5 !important;
}

/* =========================================================
   Tarjeta de Pedido WooCommerce
   ========================================================= */

.pipe-order-card {
    background: #1e293b;
    border: 1px solid #334155;
    border-top-left-radius: 4px;
    border-top-right-radius: 12px;
    border-bottom-right-radius: 12px;
    border-bottom-left-radius: 12px;
    overflow: hidden;
    font-size: 13px;
    min-width: 260px;
    max-width: 300px;
    color: #e2e8f0;
}

.pipe-order-card__header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #14532d;
    color: #d1fae5;
}

.pipe-order-card__icon {
    font-size: 22px;
    line-height: 1;
}

.pipe-order-card__title {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.pipe-order-card__label {
    font-size: 11px;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pipe-order-card__number {
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
    color: #ffffff;
}

.pipe-order-card__section {
    padding: 10px 14px;
    border-bottom: 1px solid #334155;
}

.pipe-order-card__section-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #64748b;
    margin-bottom: 6px;
}

.pipe-order-card__row {
    font-size: 13px;
    color: #cbd5e1;
    margin-bottom: 3px;
    line-height: 1.4;
}

.pipe-order-card__row span {
    color: #94a3b8;
}

.pipe-order-card__items {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pipe-order-card__item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 6px;
    font-size: 13px;
    color: #cbd5e1;
}

.pipe-order-card__item-name {
    flex: 1;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pipe-order-card__item-qty {
    color: #94a3b8;
    font-size: 12px;
    white-space: nowrap;
}

.pipe-order-card__item-price {
    font-weight: 600;
    color: #4ade80;
    white-space: nowrap;
}

.pipe-order-card__footer {
    padding: 10px 14px;
    background: #0f172a;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.pipe-order-card__total {
    font-size: 15px;
    color: #e2e8f0;
}

.pipe-order-card__total strong {
    color: #4ade80;
}

.pipe-order-card__status {
    margin-top: 4px;
}

.pipe-order-card__badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    background: #14532d;
    color: #86efac;
    border: 1px solid #166534;
    text-transform: capitalize;
}

/* Responsivo */
@media (max-width: 480px) {
    .pipe-chat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        bottom: 70px;
    }

    .pipe-chat-widget-right {
        right: 10px;
    }

    .pipe-chat-widget-left {
        left: 10px;
    }
}
