/**
 * AI Agent Widget Styles
 * Premium glassmorphism floating assistant
 */

/* ===== AI Agent Floating Button ===== */
.ai-agent-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2d5a87 0%, #1e3a5f 100%);
    border: none;
    box-shadow: 0 4px 15px rgba(45, 90, 135, 0.4);
    cursor: pointer;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: none;  /* ปิด pulse เพื่อลดความรำคาญ */
}

.ai-agent-fab:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(45, 90, 135, 0.6);
}

.ai-agent-fab.has-alert {
    animation: ai-fab-alert 0.6s ease-in-out infinite;
}

.ai-agent-fab svg {
    width: 28px;
    height: 28px;
    fill: white;
}

.ai-agent-fab .badge-count {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 22px;
    height: 22px;
    background: #ff4757;
    color: white;
    font-size: 11px;
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    animation: ai-badge-bounce 0.5s ease;
}

/* ===== AI Agent Panel ===== */
.ai-agent-panel {
    position: fixed;
    bottom: 90px;
    right: 24px;
    width: 380px;
    max-height: 520px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.5);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.ai-agent-panel.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Dark mode support */
[data-bs-theme="dark"] .ai-agent-panel {
    background: rgba(30, 34, 45, 0.95);
    border-color: rgba(255, 255, 255, 0.1);
}

/* ===== Panel Header ===== */
.ai-agent-header {
    background: linear-gradient(135deg, #2d5a87 0%, #1e3a5f 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-agent-header .ai-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-agent-header .ai-avatar svg {
    width: 24px;
    height: 24px;
    fill: white;
}

.ai-agent-header .ai-info h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.ai-agent-header .ai-info span {
    font-size: 12px;
    opacity: 0.85;
}

.ai-agent-header .ai-close {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.ai-agent-header .ai-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.ai-agent-header .ai-close svg {
    width: 18px;
    height: 18px;
    fill: white;
}

/* ===== Panel Body ===== */
.ai-agent-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ===== Status Card ===== */
.ai-status-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

[data-bs-theme="dark"] .ai-status-card {
    background: linear-gradient(135deg, #2a2f3a 0%, #1e222d 100%);
}

.ai-status-card .status-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-status-card .status-icon.ok { background: rgba(40, 199, 111, 0.15); color: #28c76f; }
.ai-status-card .status-icon.warning { background: rgba(255, 159, 67, 0.15); color: #ff9f43; }
.ai-status-card .status-icon.error { background: rgba(234, 84, 85, 0.15); color: #ea5455; }

.ai-status-card .status-text h5 {
    margin: 0 0 2px;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

[data-bs-theme="dark"] .ai-status-card .status-text h5 {
    color: #e1e1e1;
}

.ai-status-card .status-text span {
    font-size: 12px;
    color: #6c757d;
}

/* ===== Issue List ===== */
.ai-issues-section {
    margin-top: 4px;
}

.ai-issues-section h6 {
    font-size: 12px;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.ai-issue-item {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 8px;
    transition: all 0.2s;
}

.ai-issue-item:hover {
    border-color: #2d5a87;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}

[data-bs-theme="dark"] .ai-issue-item {
    background: #2a2f3a;
    border-color: #3d4555;
}

.ai-issue-item .issue-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.ai-issue-item .issue-badge {
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 600;
}

.ai-issue-item .issue-badge.critical { background: #ffeef0; color: #ea5455; }
.ai-issue-item .issue-badge.warning { background: #fff4e5; color: #ff9f43; }
.ai-issue-item .issue-badge.info { background: #e8f4fd; color: #3498db; }

[data-bs-theme="dark"] .ai-issue-item .issue-badge.critical { background: rgba(234, 84, 85, 0.2); }
[data-bs-theme="dark"] .ai-issue-item .issue-badge.warning { background: rgba(255, 159, 67, 0.2); }
[data-bs-theme="dark"] .ai-issue-item .issue-badge.info { background: rgba(52, 152, 219, 0.2); }

.ai-issue-item .issue-title {
    font-size: 13px;
    font-weight: 500;
    color: #333;
    flex: 1;
}

[data-bs-theme="dark"] .ai-issue-item .issue-title {
    color: #e1e1e1;
}

.ai-issue-item .issue-desc {
    font-size: 12px;
    color: #6c757d;
    margin-bottom: 10px;
    line-height: 1.4;
}

.ai-issue-item .issue-action {
    display: flex;
    gap: 8px;
}

.ai-issue-item .btn-action {
    font-size: 11px;
    padding: 5px 12px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.ai-issue-item .btn-action.primary {
    background: linear-gradient(135deg, #2d5a87 0%, #1e3a5f 100%);
    color: white;
}

.ai-issue-item .btn-action.primary:hover {
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.ai-issue-item .btn-action.secondary {
    background: #f1f3f4;
    color: #555;
}

[data-bs-theme="dark"] .ai-issue-item .btn-action.secondary {
    background: #3d4555;
    color: #e1e1e1;
}

/* ===== Quick Actions ===== */
.ai-quick-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 8px;
}

.ai-quick-btn {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-quick-btn:hover {
    background: #f1f3f4;
    border-color: #667eea;
    transform: translateY(-2px);
}

[data-bs-theme="dark"] .ai-quick-btn {
    background: #2a2f3a;
    border-color: #3d4555;
}

.ai-quick-btn svg {
    width: 22px;
    height: 22px;
    color: #2d5a87;
}

.ai-quick-btn span {
    font-size: 11px;
    font-weight: 500;
    color: #555;
}

[data-bs-theme="dark"] .ai-quick-btn span {
    color: #b0b0b0;
}

/* ===== Panel Footer ===== */
.ai-agent-footer {
    padding: 12px 16px;
    border-top: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fafbfc;
}

[data-bs-theme="dark"] .ai-agent-footer {
    background: #1e222d;
    border-color: #3d4555;
}

.ai-agent-footer input {
    flex: 1;
    border: 1px solid #e9ecef;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 13px;
    outline: none;
    transition: border 0.2s;
}

.ai-agent-footer input:focus {
    border-color: #2d5a87;
}

[data-bs-theme="dark"] .ai-agent-footer input {
    background: #2a2f3a;
    border-color: #3d4555;
    color: #e1e1e1;
}

.ai-agent-footer .btn-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2d5a87 0%, #1e3a5f 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.ai-agent-footer .btn-send:hover {
    transform: scale(1.05);
}

.ai-agent-footer .btn-send svg {
    width: 18px;
    height: 18px;
    fill: white;
}

/* ===== Animations ===== */
@keyframes ai-fab-pulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4); }
    50% { box-shadow: 0 4px 30px rgba(102, 126, 234, 0.6); }
}

@keyframes ai-fab-alert {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes ai-badge-bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* ===== Toast Notifications ===== */
.ai-toast {
    position: fixed;
    bottom: 90px;
    right: 90px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 14px 18px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 9997;
    animation: ai-toast-slide 0.3s ease;
    max-width: 300px;
}

[data-bs-theme="dark"] .ai-toast {
    background: rgba(42, 47, 58, 0.98);
}

.ai-toast.critical { border-left: 4px solid #ea5455; }
.ai-toast.warning { border-left: 4px solid #ff9f43; }
.ai-toast.info { border-left: 4px solid #3498db; }
.ai-toast.success { border-left: 4px solid #28c76f; }

.ai-toast .toast-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-toast.critical .toast-icon { background: rgba(234, 84, 85, 0.15); color: #ea5455; }
.ai-toast.warning .toast-icon { background: rgba(255, 159, 67, 0.15); color: #ff9f43; }
.ai-toast.info .toast-icon { background: rgba(52, 152, 219, 0.15); color: #3498db; }
.ai-toast.success .toast-icon { background: rgba(40, 199, 111, 0.15); color: #28c76f; }

.ai-toast .toast-content {
    flex: 1;
}

.ai-toast .toast-title {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    margin: 0 0 2px;
}

[data-bs-theme="dark"] .ai-toast .toast-title {
    color: #e1e1e1;
}

.ai-toast .toast-message {
    font-size: 12px;
    color: #6c757d;
    margin: 0;
}

.ai-toast .toast-close {
    background: transparent;
    border: none;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.ai-toast .toast-close:hover {
    opacity: 1;
}

@keyframes ai-toast-slide {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ===== Responsive ===== */
@media (max-width: 576px) {
    .ai-agent-panel {
        right: 12px;
        left: 12px;
        width: auto;
        bottom: 80px;
        max-height: 70vh;
    }
    
    .ai-agent-fab {
        right: 16px;
        bottom: 16px;
        width: 52px;
        height: 52px;
    }
    
    .ai-toast {
        right: 12px;
        left: 12px;
        width: auto;
        bottom: 76px;
    }
}

/* ===== Loading State ===== */
.ai-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
}

.ai-loading-dots {
    display: flex;
    gap: 6px;
}

.ai-loading-dots span {
    width: 10px;
    height: 10px;
    background: #2d5a87;
    border-radius: 50%;
    animation: ai-dot-bounce 1.4s ease-in-out infinite both;
}

.ai-loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.ai-loading-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes ai-dot-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}
