/* OPERIS Cloud - AI Chatbox Styles */

/* Floating Chat Button */
.ai-chat-button {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    cursor: pointer;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: all 0.3s ease;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    will-change: left, top;
}

.ai-chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(102, 126, 234, 0.6);
}

.ai-chat-button.active {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.ai-chat-button.dragging {
    transition: none !important;
    cursor: grabbing;
    transform: none !important;
}

.ai-chat-button .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #dc3545;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
}

/* Chatbox Modal */
.ai-chatbox {
    position: fixed;
    top: 120px;
    right: 30px;
    bottom: auto;
    width: 400px;
    max-width: calc(100vw - 60px);
    height: calc(100vh - 150px);
    max-height: calc(100vh - 150px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s ease;
}

.ai-chatbox.hidden {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
}

/* Chatbox Header */
.ai-chatbox-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 16px 16px 0 0;
}

.ai-chatbox-header-main {
    min-width: 0;
}

.ai-chatbox-header h6 {
    margin: 0;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-chatbox-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-chatbox-header-btn {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

.ai-chatbox-header-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.ai-chatbox-header .status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    animation: pulse 2s infinite;
}

.ai-chatbox-header .status-indicator.offline {
    background: #ef4444;
    animation: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.ai-chatbox-header .btn-close {
    filter: brightness(0) invert(1);
    opacity: 0.8;
}

.ai-chatbox-header .btn-close:hover {
    opacity: 1;
}

/* Chatbox Messages */
.ai-chatbox-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-chatbox-message {
    display: flex;
    gap: 10px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-chatbox-message.user {
    flex-direction: row-reverse;
}

.ai-chatbox-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
}

.ai-chatbox-message.user .ai-chatbox-message-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.ai-chatbox-message.ai .ai-chatbox-message-avatar {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.ai-chatbox-message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 12px;
    word-wrap: break-word;
}

.ai-chatbox-message.user .ai-chatbox-message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-chatbox-message.ai .ai-chatbox-message-content {
    background: white;
    color: #333;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
    line-height: 1.5;
}

.ai-chatbox-message-time {
    font-size: 11px;
    color: #6b7280;
    margin-top: 4px;
    text-align: right;
}

.ai-chatbox-message.ai .ai-chatbox-message-time {
    text-align: left;
}

/* Typing Indicator */
.ai-chatbox-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    width: fit-content;
}

.ai-chatbox-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9ca3af;
    animation: typing 1.4s infinite;
}

.ai-chatbox-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-chatbox-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Chatbox Input */
.ai-chatbox-input-container {
    padding: 16px 20px;
    background: white;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.ai-chatbox-input {
    flex: 1;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 10px 14px;
    resize: none;
    font-size: 14px;
    max-height: 100px;
    font-family: inherit;
}

.ai-chatbox-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.ai-chatbox-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.ai-chatbox-attach-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, #f8fafc 0%, #eef2ff 100%);
    color: #4f46e5;
    border: 1px solid #dbeafe;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.22s ease;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.12);
}

.ai-chatbox-attach-btn:hover {
    background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
    border-color: #c7d2fe;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.18);
}

.ai-chatbox-attach-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.16);
}

.ai-chatbox-attach-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2), 0 6px 16px rgba(79, 70, 229, 0.18);
}

.ai-chatbox-attach-btn i {
    font-size: 16px;
    transform: rotate(-12deg);
}

.ai-chatbox-attachment-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 20px 10px 20px;
    background: #fff;
    border-top: 1px dashed #e5e7eb;
    font-size: 12px;
    color: #4b5563;
}

.ai-chatbox-attachment-remove {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #6b7280;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.ai-chatbox-send-btn:hover:not(:disabled) {
    transform: scale(1.1);
}

.ai-chatbox-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Welcome Message */
.ai-chatbox-welcome {
    text-align: center;
    padding: 40px 20px;
    color: #6b7280;
}

.ai-chatbox-welcome-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.ai-chatbox-welcome h6 {
    color: #374151;
    margin-bottom: 8px;
}

.ai-chatbox-welcome p {
    font-size: 13px;
    margin: 0;
}

.ai-chatbox-suggestions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
}

.ai-chatbox-suggestion {
    appearance: none;
    width: 100%;
    padding: 10px 14px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    text-align: left;
    transition: all 0.2s ease;
}

.ai-chatbox-suggestion i {
    margin-right: 8px;
    color: #667eea;
}

.ai-chatbox-suggestion:hover {
    background: #f3f4f6;
    border-color: #667eea;
}

.ai-chatbox-richtext {
    font-size: 14px;
    color: inherit;
}

.ai-chatbox-richtext p {
    margin: 0 0 10px;
}

.ai-chatbox-richtext p:last-child {
    margin-bottom: 0;
}

.ai-chatbox-richtext ul,
.ai-chatbox-richtext ol {
    margin: 0 0 10px 18px;
    padding: 0;
}

.ai-chatbox-richtext li + li {
    margin-top: 4px;
}

.ai-chatbox-richtext code {
    background: #eef2ff;
    color: #3730a3;
    border-radius: 6px;
    padding: 2px 6px;
    font-size: 12px;
}

.ai-chatbox-richtext a {
    color: #2563eb;
    text-decoration: underline;
    word-break: break-word;
}

/* Error Message */
.ai-chatbox-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    animation: fadeIn 0.3s ease;
}

.ai-chatbox-error-icon {
    text-align: center;
    font-size: 36px;
    color: #ef4444;
    margin-bottom: 12px;
}

.ai-chatbox-error h6 {
    color: #dc2626;
    font-weight: 600;
    margin-bottom: 12px;
    text-align: center;
}

.ai-chatbox-error p {
    color: #7f1d1d;
    font-size: 14px;
    margin-bottom: 12px;
}

.ai-chatbox-error ol {
    color: #7f1d1d;
    font-size: 13px;
    padding-left: 20px;
    margin-bottom: 12px;
}

.ai-chatbox-error ol li {
    margin-bottom: 12px;
}

.ai-chatbox-error ol li strong {
    color: #dc2626;
    display: block;
    margin-bottom: 4px;
}

.ai-chatbox-error code {
    font-size: 12px;
    color: #1f2937;
    font-family: 'Courier New', monospace;
}

.ai-chatbox-error .btn {
    font-size: 12px;
    padding: 6px 12px;
}

.ai-chatbox-error small {
    color: #991b1b;
    font-size: 12px;
}

.ai-chatbox-action-message .ai-chatbox-message-content {
    max-width: 88%;
}

.ai-chatbox-report-card {
    border: 1px solid #dbe5ff;
    border-radius: 12px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    padding: 12px;
}

.ai-chatbox-report-card.generated {
    border-color: #bfdbfe;
}

.ai-chatbox-report-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.ai-chatbox-report-title {
    font-weight: 700;
    color: #1f2937;
}

.ai-chatbox-report-status {
    font-size: 11px;
    color: #4f46e5;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    border-radius: 999px;
    padding: 3px 8px;
    white-space: nowrap;
}

.ai-chatbox-report-summary {
    display: grid;
    gap: 6px;
    margin-bottom: 10px;
}

.ai-chatbox-report-summary-item {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 13px;
    color: #374151;
}

.ai-chatbox-report-summary-label {
    color: #6b7280;
}

.ai-chatbox-report-note {
    font-size: 13px;
    color: #92400e;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 10px;
    padding: 8px 10px;
    margin-bottom: 10px;
}

.ai-chatbox-report-result {
    margin-bottom: 10px;
}

.ai-chatbox-report-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 12px;
    color: #334155;
}

.ai-chatbox-report-metrics span {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    padding: 5px 9px;
}

.ai-chatbox-report-error {
    font-size: 13px;
    color: #b91c1c;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 10px;
    padding: 8px 10px;
    margin-bottom: 10px;
}

.ai-chatbox-report-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ai-chatbox-report-btn {
    border: none;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.ai-chatbox-report-btn:hover:not(:disabled) {
    transform: translateY(-1px);
}

.ai-chatbox-report-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

.ai-chatbox-report-btn.primary {
    background: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
    color: #fff;
    box-shadow: 0 6px 14px rgba(79, 70, 229, 0.18);
}

.ai-chatbox-report-btn.secondary {
    background: #eef2ff;
    color: #3730a3;
    border: 1px solid #c7d2fe;
}

/* Responsive */
@media (max-width: 768px) {
    .ai-chatbox {
        width: calc(100vw - 20px);
        right: 10px;
        top: auto;
        bottom: 80px;
        height: calc(100vh - 100px);
    }
    
    .ai-chat-button {
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
    }

    .ai-chatbox-action-message .ai-chatbox-message-content {
        max-width: 100%;
    }

    .ai-chatbox-report-head,
    .ai-chatbox-report-summary-item {
        flex-direction: column;
    }
}

