/**
 * Cargo Express ChatBot PRO - Widget Frontend CSS
 * Branding: Navy #0a2342 + Orange #e8420a
 */

:root {
    --seg-primary:   #0a2342;
    --seg-secondary: #e8420a;
    --seg-text:      #1c1e21;
    --seg-bg:        #f7f8fa;
    --seg-border:    #e8eaed;
    --seg-shadow:    rgba(0,0,0,.12);
}

/* ── Trigger Button ── */
#cargoex-chat-trigger {
    position: fixed;
    bottom: 20px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--seg-primary);
    cursor: pointer;
    box-shadow: 0 4px 20px var(--seg-shadow);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .3s cubic-bezier(.4,0,.2,1), box-shadow .3s;
    border: none;
    outline: none;
}
#cargoex-chat-trigger:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(0,0,0,.25);
}
#cargoex-chat-trigger svg {
    width: 30px;
    height: 30px;
    fill: #fff;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,.15));
}
.seg-trigger-pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--seg-primary);
    opacity: .35;
    animation: segPulse 2.2s ease-out infinite;
    pointer-events: none;
}
@keyframes segPulse {
    0%   { transform: scale(1); opacity: .35; }
    100% { transform: scale(1.6); opacity: 0; }
}

.seg-pos-right { right: 20px; }
.seg-pos-left  { left: 20px; }

/* ── Chat Window ── */
#cargoex-chat-window {
    position: fixed;
    bottom: 96px;
    width: 400px;
    max-width: calc(100vw - 30px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0,0,0,.18);
    z-index: 99999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
#cargoex-chat-window.seg-open {
    display: flex;
    animation: segSlideUp .35s cubic-bezier(.4,0,.2,1);
}
#cargoex-chat-window.seg-closing {
    animation: segSlideDown .3s ease forwards;
}
@keyframes segSlideUp {
    from { opacity: 0; transform: translateY(24px) scale(.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes segSlideDown {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to   { opacity: 0; transform: translateY(24px) scale(.96); }
}

/* ── Header ── */
.seg-header {
    background: linear-gradient(135deg, var(--seg-primary) 0%, #0d3060 100%);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
    flex-shrink: 0;
}
.seg-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}
.seg-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255,255,255,.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
    border: 2px solid rgba(232,66,10,.6);
}
.seg-header-text h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
}
.seg-status {
    font-size: 12px;
    opacity: .88;
    display: flex;
    align-items: center;
    gap: 5px;
}
.seg-status-dot {
    width: 7px;
    height: 7px;
    background: #2ecc71;
    border-radius: 50%;
    animation: segDotPulse 2s infinite;
}
@keyframes segDotPulse {
    0%,100% { opacity: 1; }
    50%     { opacity: .45; }
}
.seg-close-btn {
    background: rgba(255,255,255,.1);
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 8px;
    transition: background .2s;
    line-height: 1;
}
.seg-close-btn:hover { background: rgba(255,255,255,.22); }

/* ── Messages Area ── */
.seg-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--seg-bg);
}
.seg-messages::-webkit-scrollbar { width: 5px; }
.seg-messages::-webkit-scrollbar-track { background: transparent; }
.seg-messages::-webkit-scrollbar-thumb { background: #c0c0c0; border-radius: 3px; }

/* ── Message Bubbles ── */
.seg-msg { max-width: 85%; animation: segMsgIn .3s ease; }
@keyframes segMsgIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
.seg-msg-content {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.55;
    word-wrap: break-word;
}
.seg-msg-content strong { font-weight: 700; }

.seg-msg-bot { align-self: flex-start; }
.seg-msg-bot .seg-msg-content {
    background: #fff;
    color: var(--seg-text);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    border: 1px solid var(--seg-border);
}
.seg-msg-user { align-self: flex-end; }
.seg-msg-user .seg-msg-content {
    background: var(--seg-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.seg-msg-time {
    font-size: 11px;
    color: #aaa;
    margin-top: 3px;
    padding: 0 4px;
}
.seg-msg-user .seg-msg-time { text-align: right; }

/* ── Typing Indicator ── */
.seg-typing {
    display: none;
    align-self: flex-start;
    padding: 12px 20px;
    background: #fff;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    border: 1px solid var(--seg-border);
}
.seg-typing.active { display: flex; gap: 4px; align-items: center; }
.seg-typing span {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #b0b0b0;
    border-radius: 50%;
    animation: segBounce .7s infinite alternate;
}
.seg-typing span:nth-child(2) { animation-delay: .15s; }
.seg-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes segBounce { to { transform: translateY(-7px); opacity: .4; } }

/* ── Quick Buttons ── */
.seg-quick-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 16px 10px;
    background: var(--seg-bg);
}
.seg-quick-btn {
    background: rgba(10,35,66,.07);
    color: var(--seg-primary);
    border: 1px solid rgba(10,35,66,.18);
    border-radius: 20px;
    padding: 7px 14px;
    font-size: 12px;
    cursor: pointer;
    transition: all .2s;
    white-space: nowrap;
    font-family: inherit;
}
.seg-quick-btn:hover {
    background: var(--seg-secondary);
    color: #fff;
    border-color: var(--seg-secondary);
}

/* ── Tracking Bar ── */
.seg-cedula-bar {
    padding: 8px 16px;
    background: rgba(232,66,10,.05);
    border-top: 1px solid rgba(232,66,10,.2);
    display: flex;
    gap: 6px;
    align-items: center;
    flex-shrink: 0;
}
.seg-cedula-bar input {
    flex: 1;
    border: 1px solid rgba(232,66,10,.3);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    outline: none;
    font-family: inherit;
    transition: border-color .2s;
    text-transform: uppercase;
}
.seg-cedula-bar input:focus { border-color: var(--seg-secondary); }
.seg-cedula-bar button {
    background: var(--seg-secondary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    font-weight: 600;
    font-family: inherit;
    transition: opacity .2s;
}
.seg-cedula-bar button:hover { opacity: .88; }

/* ── Input Area ── */
.seg-input-area {
    background: #fff;
    border-top: 1px solid #eee;
    padding: 12px 16px;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}
.seg-input-area input {
    flex: 1;
    border: 1px solid #dde;
    border-radius: 24px;
    padding: 11px 18px;
    font-size: 14px;
    outline: none;
    font-family: inherit;
    transition: border-color .2s, box-shadow .2s;
}
.seg-input-area input:focus {
    border-color: var(--seg-primary);
    box-shadow: 0 0 0 3px rgba(10,35,66,.08);
}
.seg-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--seg-secondary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .15s, box-shadow .2s;
    flex-shrink: 0;
}
.seg-send-btn:hover {
    transform: scale(1.06);
    box-shadow: 0 3px 12px rgba(232,66,10,.35);
}
.seg-send-btn:active { transform: scale(.94); }
.seg-send-btn svg { width: 18px; height: 18px; fill: #fff; }

/* ── Footer ── */
.seg-footer {
    padding: 6px;
    text-align: center;
    font-size: 10px;
    color: #bbb;
    background: #fff;
    flex-shrink: 0;
}
.seg-footer a { color: #bbb; text-decoration: none; }
.seg-footer a:hover { color: var(--seg-secondary); }

/* ── Responsive ── */
@media (max-width: 480px) {
    #cargoex-chat-window {
        width: 100%;
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        bottom: 0;
        left: 0 !important;
        right: 0 !important;
        border-radius: 0;
    }
    .seg-quick-btns { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 8px; }
}

.seg-msg-history { opacity: .82; }
.seg-msg-history .seg-msg-content { font-size: 13px; }
