/* ================================================================
   Traniva Lea Chat – Widget Styles
   ================================================================ */

:root {
    --tlc-primary:    #0a1f3f;
    --tlc-accent:     #00b4a0;
    --tlc-bg:         #ffffff;
    --tlc-bg-light:   #f4f6f8;
    --tlc-text:       #1a1a2e;
    --tlc-text-light: #6b7280;
    --tlc-radius:     16px;
    --tlc-shadow:     0 8px 32px rgba(0, 0, 0, 0.18);
    --tlc-font:       'Segoe UI', system-ui, -apple-system, sans-serif;
    --tlc-header-grad-end: #0d2a52;
    --tlc-header-text: #ffffff;
    --tlc-user-bubble: var(--tlc-primary);
    --tlc-bot-bubble:  #ffffff;
    --tlc-bot-text:    #1a1a2e;
    --tlc-window-height: 70vh;
}

/* ---- Bubble ---------------------------------------------------- */
#tlc-bubble {
    position: fixed;
    bottom: 24px;
    z-index: 999999;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: var(--tlc-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--tlc-shadow);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}
#tlc-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}
#tlc-bubble svg {
    width: 28px;
    height: 28px;
    transition: transform 0.3s ease;
}
#tlc-bubble.tlc-open svg {
    transform: rotate(90deg);
}
[data-position="right"] #tlc-bubble { right: 24px; }
[data-position="left"]  #tlc-bubble { left: 24px; }

/* ---- Notification dot ------------------------------------------ */
#tlc-bubble .tlc-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: var(--tlc-accent);
    border-radius: 50%;
    border: 2px solid #fff;
    animation: tlc-pulse 2s infinite;
}
@keyframes tlc-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50%      { transform: scale(1.3); opacity: 0.7; }
}

/* ---- Window ---------------------------------------------------- */
#tlc-window {
    position: fixed;
    bottom: 100px;
    z-index: 999998;
    width: 400px;
    max-width: calc(100vw - 32px);
    height: var(--tlc-window-height, 70vh);
    max-height: calc(100vh - 120px);
    background: var(--tlc-bg);
    border-radius: var(--tlc-radius);
    box-shadow: var(--tlc-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    font-family: var(--tlc-font);
}
#tlc-window.tlc-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}
[data-position="right"] #tlc-window { right: 24px; }
[data-position="left"]  #tlc-window { left: 24px; }

/* ---- Header ---------------------------------------------------- */
.tlc-header {
    background: linear-gradient(135deg, var(--tlc-primary) 0%, var(--tlc-header-grad-end) 100%);
    color: var(--tlc-header-text);
    padding: 18px 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    flex-shrink: 0;
}
.tlc-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--tlc-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    flex-shrink: 0;
    color: #fff;
}
.tlc-header-info h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
}
.tlc-header-info span {
    font-size: 12px;
    opacity: 0.8;
    display: flex;
    align-items: center;
    gap: 4px;
}
.tlc-header-info span::before {
    content: '';
    width: 7px;
    height: 7px;
    background: var(--tlc-accent);
    border-radius: 50%;
    display: inline-block;
}
.tlc-close {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--tlc-header-text);
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
    padding: 4px;
}
.tlc-close:hover { opacity: 1; }
.tlc-close svg { width: 20px; height: 20px; }

/* ---- Header bio & links ---------------------------------------- */
.tlc-header-bio {
    margin: 4px 0 0 0;
    font-size: 12px;
    line-height: 1.4;
    opacity: 0.85;
    font-weight: 400;
    max-height: 2.8em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.tlc-header-links {
    display: flex;
    gap: 12px;
    margin-top: 6px;
    flex-wrap: wrap;
}
.tlc-header-links a {
    font-size: 11px;
    font-weight: 600;
    color: var(--tlc-accent);
    text-decoration: none;
    transition: color 0.2s, opacity 0.2s;
    opacity: 0.95;
}
.tlc-header-links a:hover {
    color: #fff;
    opacity: 1;
    text-decoration: underline;
}

/* ---- Messages -------------------------------------------------- */
.tlc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--tlc-bg-light);
}
.tlc-messages::-webkit-scrollbar { width: 4px; }
.tlc-messages::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }

.tlc-msg {
    max-width: 82%;
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.55;
    word-wrap: break-word;
    white-space: pre-wrap;
    animation: tlc-fadeIn 0.3s ease;
}
@keyframes tlc-fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.tlc-msg.tlc-bot {
    background: var(--tlc-bot-bubble, var(--tlc-bg));
    color: var(--tlc-bot-text, var(--tlc-text));
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.tlc-msg.tlc-user {
    background: var(--tlc-user-bubble, var(--tlc-primary));
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

/* ---- Bot message links ----------------------------------------- */
.tlc-msg.tlc-bot a {
    color: var(--tlc-accent);
    text-decoration: underline;
    text-underline-offset: 2px;
    font-weight: 600;
    word-break: break-word;
    transition: color 0.2s;
}
.tlc-msg.tlc-bot a:hover {
    color: var(--tlc-primary);
}
.tlc-msg.tlc-bot strong {
    font-weight: 700;
}

/* Typing indicator */
.tlc-typing {
    display: flex;
    gap: 5px;
    padding: 12px 18px;
    align-self: flex-start;
    background: var(--tlc-bg);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.tlc-typing span {
    width: 8px;
    height: 8px;
    background: var(--tlc-accent);
    border-radius: 50%;
    animation: tlc-bounce 1.4s infinite ease-in-out both;
}
.tlc-typing span:nth-child(1) { animation-delay: -0.32s; }
.tlc-typing span:nth-child(2) { animation-delay: -0.16s; }
@keyframes tlc-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40%           { transform: scale(1);   opacity: 1; }
}

/* ---- Input ----------------------------------------------------- */
.tlc-input-area {
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: var(--tlc-bg);
    flex-shrink: 0;
}
.tlc-input-area textarea {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: var(--tlc-font);
    resize: none;
    outline: none;
    max-height: 100px;
    line-height: 1.4;
    transition: border-color 0.2s;
}
.tlc-input-area textarea:focus {
    border-color: var(--tlc-accent);
}
.tlc-input-area textarea::placeholder {
    color: var(--tlc-text-light);
}
.tlc-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--tlc-accent);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.15s;
}
.tlc-send-btn:hover {
    background: var(--tlc-primary);
    transform: scale(1.05);
}
.tlc-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}
.tlc-send-btn svg { width: 18px; height: 18px; }

/* ---- Footer ---------------------------------------------------- */
.tlc-footer {
    text-align: center;
    padding: 6px;
    font-size: 11px;
    color: var(--tlc-text-light);
    background: var(--tlc-bg);
    flex-shrink: 0;
}
.tlc-footer a {
    color: var(--tlc-accent);
    text-decoration: none;
}

/* ---- Mobile ---------------------------------------------------- */
@media (max-width: 480px) {
    #tlc-window {
        width: calc(100vw - 16px);
        height: calc(100vh - 80px);
        bottom: 72px;
        right: 8px !important;
        left: 8px !important;
        border-radius: 12px;
    }
    #tlc-bubble {
        width: 54px;
        height: 54px;
        bottom: 12px;
    }
    [data-position="right"] #tlc-bubble { right: 12px; }
    [data-position="left"]  #tlc-bubble { left: 12px; }
}

/* ---- Bubble with avatar ---------------------------------------- */
#tlc-bubble .tlc-bubble-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* ---- Header avatar --------------------------------------------- */
.tlc-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}
.tlc-header-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--tlc-accent);
}
.tlc-header-link {
    color: var(--tlc-header-text) !important;
    text-decoration: none;
    transition: opacity 0.2s;
}
.tlc-header-link:hover {
    opacity: 0.85;
    text-decoration: underline;
}

/* ---- Tooltip --------------------------------------------------- */
.tlc-tooltip {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    width: 260px;
    background: #fff;
    color: var(--tlc-text);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    padding: 14px 16px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
    z-index: 10;
    pointer-events: none;
}
.tlc-tooltip::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 16px;
    width: 12px;
    height: 12px;
    background: #fff;
    transform: rotate(45deg);
    box-shadow: -2px -2px 4px rgba(0,0,0,0.04);
}
.tlc-avatar-wrap:hover .tlc-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}
.tlc-tooltip-bio {
    margin: 0 0 10px 0;
    font-size: 13px;
    line-height: 1.5;
    color: #374151;
}
.tlc-tooltip-links {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.tlc-tooltip-links a {
    font-size: 12px;
    font-weight: 600;
    color: var(--tlc-accent);
    text-decoration: none;
    transition: color 0.2s;
}
.tlc-tooltip-links a:hover {
    color: var(--tlc-primary);
    text-decoration: underline;
}
