/* chat-widget.css */

.chat-toggle-tab {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    writing-mode: vertical-rl;
    text-orientation: mixed;
    background: #3b82f6;
    color: #fff;
    padding: 16px 6px;
    border-radius: 8px 0 0 8px;
    font-size: 16px;
    font-weight: 500;
    letter-spacing: 1px;
    cursor: pointer;
    z-index: 9999;
    box-shadow: -2px 4px 12px rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.15);
    border-right: none;
    transition: all 0.2s ease;
    user-select: none;
    font-family: 'Segoe UI', sans-serif;
}
.chat-toggle-tab:hover {
    background: #2563eb;
    padding-right: 10px;
}
.chat-toggle-tab.hidden {
    display: none;
}
.chat-toggle-tab .badge {
    position: absolute;
    top: -8px;
    right: 4px;
    background: #f87171;
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    border-radius: 50%;
    padding: 2px 6px;
    min-width: 20px;
    text-align: center;
    border: 2px solid #0f172a;
    writing-mode: horizontal-tb;
}

.chat-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 0;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    background: #1e293b;
    border-left: 1px solid #475569;
    box-shadow: -4px 0 20px rgba(0,0,0,0.4);
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    transition: width 0.3s ease;
    z-index: 9998;
    font-family: 'Segoe UI', sans-serif;
    color: #e2e8f0;
}
.chat-panel.open {
    width: 380px;
}
.chat-panel .resize-handle {
    position: absolute;
    left: -6px;
    top: 0;
    width: 12px;
    height: 100%;
    cursor: col-resize;
    z-index: 10;
    background: transparent;
    transition: background 0.2s;
}
.chat-panel .resize-handle:hover,
.chat-panel .resize-handle.active {
    background: rgba(59,130,246,0.3);
}
.chat-panel-header {
    padding: 16px 20px;
    background: #0f172a;
    border-bottom: 1px solid #475569;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
.chat-panel-header span {
    color: #e2e8f0;
    font-weight: 600;
    font-size: 16px;
}
.chat-panel-header .close-btn {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 24px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.chat-panel-header .close-btn:hover {
    color: #e2e8f0;
}
.chat-panel-body {
    flex: 1 1 0;
    overflow-y: auto;
    padding: 16px 16px 8px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}
.chat-panel-body .msg-user {
    background: #3b82f6;
    padding: 10px 14px;
    border-radius: 8px;
    color: #fff;
    font-size: 13px;
    align-self: flex-end;
    max-width: 85%;
    word-wrap: break-word;
}
.chat-panel-body .msg-bot {
    background: #0f172a;
    padding: 10px 14px;
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 13px;
    align-self: flex-start;
    max-width: 85%;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.chat-panel-body .msg-loader {
    background: #0f172a;
    padding: 10px 14px;
    border-radius: 8px;
    color: #94a3b8;
    font-size: 13px;
    align-self: flex-start;
    max-width: 85%;
}
.chat-panel-footer {
    padding: 10px 16px calc(16px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid #475569;
    display: flex;
    gap: 10px;
    flex-shrink: 0;
    background: #1e293b;
    align-items: flex-end;
}
.chat-panel-footer textarea {
    flex: 1;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #475569;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 13px;
    outline: none;
    resize: vertical;
    min-height: 38px;
    max-height: 150px;
    line-height: 1.4;
    font-family: inherit;
    transition: border-color 0.2s;
}
.chat-panel-footer textarea:focus {
    border-color: #3b82f6;
}
.chat-panel-footer button {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    align-self: flex-end;
    height: 38px;
    flex-shrink: 0;
}
.chat-panel-footer button:hover {
    background: #2563eb;
}

@media (max-width: 768px) {
    .chat-panel.open {
        width: 100%;
    }
    .chat-toggle-tab {
        padding: 12px 4px;
        font-size: 14px;
    }
}
@media print {
    .chat-toggle-tab,
    .chat-panel {
        display: none !important;
    }
}