/**
 * Aetheric AI EPM Suite
 * Component Styles - Matching Original Wireframe Design
 */

/* ==========================================================================
   Loading Overlay
   ========================================================================== */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-overlay[hidden] {
    display: none !important;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-light);
    border-top-color: var(--accent-teal);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   Toast Notifications
   ========================================================================== */

.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: var(--bg-secondary);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-light);
    min-width: 300px;
    max-width: 450px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.success {
    border-left: 4px solid var(--status-success);
}

.toast.error {
    border-left: 4px solid var(--status-danger);
}

.toast.warning {
    border-left: 4px solid var(--status-warning);
}

.toast.info {
    border-left: 4px solid var(--accent-blue);
}

.toast-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.toast.success .toast-icon { color: var(--status-success); }
.toast.error .toast-icon { color: var(--status-danger); }
.toast.warning .toast-icon { color: var(--status-warning); }
.toast.info .toast-icon { color: var(--accent-blue); }

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.toast-message {
    font-size: 13px;
    color: var(--text-secondary);
}

.toast-close {
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0.5;
    padding: 4px;
}

.toast-close:hover {
    opacity: 1;
}

/* ==========================================================================
   Modals
   ========================================================================== */

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.modal-backdrop[hidden] {
    display: none !important;
}

/* Inner modal box when used inside modal-backdrop */
.modal-backdrop .modal {
    background: var(--bg-secondary);
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.95);
    transition: transform 0.2s ease;
}

.modal-backdrop.active .modal {
    transform: scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-light);
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    color: var(--text-muted);
    transition: all var(--transition-fast);
    font-size: 24px;
    line-height: 1;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 10;
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    max-height: calc(90vh - 140px);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-light);
    background: var(--bg-tertiary);
}

/* Modal as Overlay (when used without modal-backdrop wrapper) */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.95);
    transition: transform 0.2s ease;
}

.modal.active .modal-content {
    transform: scale(1);
}

.modal-content.modal-lg {
    max-width: 700px;
}

.modal-content.modal-xl {
    max-width: 900px;
}

/* ==========================================================================
   Data Tables
   ========================================================================== */

.sku-table,
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.sku-table th,
.data-table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: var(--bg-tertiary);
}

.sku-table td,
.data-table td {
    padding: 14px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--border-light);
}

.sku-table tr:hover,
.data-table tr:hover {
    background: var(--bg-tertiary);
}

.sku-id {
    font-family: 'Space Mono', monospace;
    font-weight: 600;
    color: var(--text-primary);
}

.sku-name {
    color: var(--text-secondary);
    font-size: 12px;
}

/* Risk Badges */
.risk-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
}

.risk-badge.critical {
    background: #FEE2E2;
    color: var(--status-danger);
}

.risk-badge.high {
    background: #FEF3C7;
    color: var(--status-warning);
}

.risk-badge.medium {
    background: #E0E7FF;
    color: #6366F1;
}

.risk-badge.low {
    background: #D1FAE5;
    color: var(--status-success);
}

/* Stock Bar */
.stock-bar {
    width: 80px;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
}

.stock-bar-fill {
    height: 100%;
    border-radius: 3px;
}

.stock-bar-fill.critical { background: var(--status-danger); }
.stock-bar-fill.low { background: var(--status-warning); }
.stock-bar-fill.good { background: var(--status-success); }

/* ==========================================================================
   AI Panel & Recommendations
   ========================================================================== */

.ai-panel {
    background: linear-gradient(135deg, var(--pastel-lavender) 0%, var(--pastel-sky) 100%);
}

.ai-recommendation,
.recommendation-card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid rgba(167, 139, 250, 0.2);
    transition: all var(--transition-normal);
}

.ai-recommendation:hover,
.recommendation-card:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow-md);
}

.ai-recommendation:last-child,
.recommendation-card:last-child {
    margin-bottom: 0;
}

.ai-rec-header,
.recommendation-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.ai-rec-icon,
.recommendation-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.recommendation-icon.slotting {
    background: linear-gradient(135deg, var(--accent-teal), var(--accent-emerald));
}

.recommendation-icon.replenishment {
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
}

.recommendation-icon.logistics {
    background: linear-gradient(135deg, var(--accent-amber), #FCD34D);
}

.ai-rec-title,
.recommendation-title {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.ai-rec-desc,
.recommendation-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.ai-rec-actions,
.recommendation-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.recommendation-impact {
    font-size: 11px;
    color: var(--status-success);
    font-weight: 600;
    margin-top: 8px;
}

/* ==========================================================================
   Warehouse Visualization
   ========================================================================== */

.warehouse-3d-container,
.heatmap-container {
    height: 420px;
    position: relative;
    background: linear-gradient(180deg, var(--pastel-sky) 0%, var(--bg-tertiary) 100%);
    border-radius: 12px;
    overflow: hidden;
}

.zone-rect {
    cursor: pointer;
    transition: all 0.3s ease;
}

.zone-rect:hover {
    filter: brightness(1.1);
    transform: scale(1.02);
}

.zone-group {
    transition: transform 0.2s ease;
}

.zone-group:hover {
    transform: translateY(-2px);
}

.zone-normal { fill: rgba(16, 185, 129, 0.3); stroke: #10B981; stroke-width: 2; }
.zone-warning { fill: rgba(245, 158, 11, 0.3); stroke: #F59E0B; stroke-width: 2; }
.zone-danger { fill: rgba(239, 68, 68, 0.3); stroke: #EF4444; stroke-width: 2; }

.warehouse-legend,
.heatmap-legend {
    position: absolute;
    bottom: 16px;
    left: 16px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 12px 16px;
    border-radius: 10px;
    display: flex;
    gap: 16px;
    font-size: 11px;
    box-shadow: var(--shadow-md);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.legend-normal { background: rgba(16, 185, 129, 0.5); border: 1px solid #10B981; }
.legend-warning { background: rgba(245, 158, 11, 0.5); border: 1px solid #F59E0B; }
.legend-danger { background: rgba(239, 68, 68, 0.5); border: 1px solid #EF4444; }

/* ==========================================================================
   Sliders & Range Inputs
   ========================================================================== */

.slider-container {
    margin-bottom: 20px;
}

.slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.slider-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.slider-value {
    font-family: 'Space Mono', monospace;
    font-size: 14px;
    font-weight: 600;
    color: var(--accent-teal);
}

input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, var(--accent-teal), var(--accent-emerald));
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(78, 205, 196, 0.4);
    transition: transform 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

/* ==========================================================================
   Stats Cards
   ========================================================================== */

.stat-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 16px;
    border: 1px solid var(--border-light);
}

.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    font-family: 'Space Mono', monospace;
    color: var(--text-primary);
}

.stat-value.positive { color: var(--status-success); }
.stat-value.negative { color: var(--status-danger); }

.stat-change {
    font-size: 11px;
    margin-top: 4px;
}

.stat-change.up { color: var(--status-success); }
.stat-change.down { color: var(--status-danger); }

/* ==========================================================================
   Tabs
   ========================================================================== */

.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 24px;
}

.tab {
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    background: none;
    border: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all var(--transition-fast);
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    color: var(--accent-teal);
    border-bottom-color: var(--accent-teal);
}

/* ==========================================================================
   Empty States
   ========================================================================== */

.empty-state {
    text-align: center;
    padding: 48px 24px;
}

.empty-state-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    color: var(--text-muted);
    opacity: 0.5;
}

.empty-state-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state-desc {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* ==========================================================================
   Progress Bars
   ========================================================================== */

.progress-bar {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(135deg, var(--accent-teal), var(--accent-emerald));
    transition: width 0.5s ease;
}

.progress-fill.warning { background: var(--status-warning); }
.progress-fill.danger { background: var(--status-danger); }
.progress-fill.success { background: var(--status-success); }

/* ==========================================================================
   Metric Cards (Carrier Performance etc)
   ========================================================================== */

/* Metrics Grid Layout */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

@media (min-width: 768px) {
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .metrics-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.metric-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border-light);
    transition: all var(--transition-normal);
}

.metric-card:hover {
    box-shadow: var(--shadow-md);
}

.metric-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.metric-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--pastel-mint);
    color: var(--accent-teal);
}

.metric-value {
    font-size: 28px;
    font-weight: 700;
    font-family: 'Space Mono', monospace;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.metric-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.metric-change {
    font-size: 11px;
    font-weight: 600;
}

.metric-change.positive { color: var(--status-success); }
.metric-change.negative { color: var(--status-danger); }

/* ========================================
   AI Chatbot Widget
   ======================================== */

.chatbot-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: var(--font-primary);
}

/* Toggle Button */
.chatbot-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-teal) 0%, var(--accent-purple) 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 20px rgba(78, 205, 196, 0.4);
    transition: all 0.3s ease;
    position: relative;
}

.chatbot-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 28px rgba(78, 205, 196, 0.5);
}

.chatbot-toggle .chatbot-icon-close {
    display: none;
}

.chatbot-widget.open .chatbot-toggle .chatbot-icon-chat {
    display: none;
}

.chatbot-widget.open .chatbot-toggle .chatbot-icon-close {
    display: block;
}

.chatbot-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--status-danger);
    color: white;
    font-size: 11px;
    font-weight: 600;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}

/* Chat Panel */
.chatbot-panel {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 400px;
    height: 560px;
    background: var(--bg-primary);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-light);
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.chatbot-widget.open .chatbot-panel {
    display: flex;
    animation: chatbot-slide-up 0.3s ease;
}

@keyframes chatbot-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
.chatbot-header {
    padding: 16px;
    background: linear-gradient(135deg, var(--accent-teal) 0%, var(--accent-purple) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

.chatbot-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-avatar-header {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-header-info h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

.chatbot-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chatbot-status-dot {
    width: 8px;
    height: 8px;
    background: #4ADE80;
    border-radius: 50%;
    animation: chatbot-pulse 2s infinite;
}

.chatbot-tagline {
    font-size: 11px;
    opacity: 0.85;
    font-style: italic;
    letter-spacing: 0.3px;
}

@keyframes chatbot-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.chatbot-header-actions {
    display: flex;
    gap: 8px;
}

.chatbot-header-actions button {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.chatbot-header-actions button:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Conversation History */
.chatbot-history {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-light);
    max-height: 250px;
    overflow-y: auto;
    display: none;
    z-index: 10;
}

.chatbot-history.show {
    display: block;
}

.chatbot-history-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
}

.chatbot-history-header h5 {
    margin: 0;
    font-size: 13px;
    color: var(--text-secondary);
}

.chatbot-history-list {
    padding: 8px;
}

.chatbot-history-item {
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chatbot-history-item:hover {
    background: var(--bg-tertiary);
}

.chatbot-history-item.active {
    background: var(--pastel-mint);
}

.chatbot-history-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 24px;
}

.chatbot-history-meta {
    font-size: 11px;
    color: var(--text-tertiary);
}

.chatbot-history-delete {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    opacity: 0;
    transition: all 0.2s;
}

.chatbot-history-item:hover .chatbot-history-delete {
    opacity: 1;
}

.chatbot-history-delete:hover {
    color: var(--status-danger);
    background: rgba(239, 68, 68, 0.1);
}

.chatbot-history-empty {
    padding: 20px;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 13px;
}

/* Messages Container */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Welcome Screen */
.chatbot-welcome {
    text-align: center;
    padding: 24px 16px;
}

.chatbot-welcome-icon {
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, var(--pastel-mint) 0%, var(--pastel-lavender) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    color: var(--accent-teal);
}

.chatbot-welcome h3 {
    margin: 0 0 8px;
    font-size: 18px;
    color: var(--text-primary);
}

.chatbot-welcome p {
    margin: 0 0 20px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.chatbot-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.chatbot-suggestion {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 12px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.chatbot-suggestion:hover {
    background: var(--accent-teal);
    color: white;
    border-color: var(--accent-teal);
}

/* Message Bubbles */
.chatbot-message {
    display: flex;
    gap: 10px;
    max-width: 90%;
}

.chatbot-message-user {
    flex-direction: row-reverse;
    align-self: flex-end;
}

.chatbot-message-assistant {
    align-self: flex-start;
}

.chatbot-message-error {
    align-self: center;
}

.chatbot-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chatbot-message-user .chatbot-avatar {
    background: var(--pastel-peach);
    color: var(--accent-coral);
}

.chatbot-message-assistant .chatbot-avatar {
    background: var(--pastel-mint);
    color: var(--accent-teal);
}

.chatbot-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 13px;
    line-height: 1.5;
}

.chatbot-message-user .chatbot-bubble {
    background: linear-gradient(135deg, var(--accent-teal) 0%, var(--accent-purple) 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.chatbot-message-assistant .chatbot-bubble {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.chatbot-message-error .chatbot-bubble {
    background: rgba(239, 68, 68, 0.1);
    color: var(--status-danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.chatbot-bubble strong {
    font-weight: 600;
}

.chatbot-bubble code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Space Mono', monospace;
    font-size: 12px;
}

.chatbot-bubble pre {
    background: var(--bg-secondary);
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
}

.chatbot-bubble pre code {
    background: none;
    padding: 0;
}

.chatbot-bubble ul, .chatbot-bubble ol {
    margin: 8px 0;
    padding-left: 20px;
}

.chatbot-bubble li {
    margin: 4px 0;
}

/* Function Data Results */
.chatbot-function-results {
    margin-top: 12px;
}

.chatbot-data-item {
    background: var(--bg-secondary);
    border-radius: 8px;
    margin-top: 8px;
}

.chatbot-data-item summary {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
}

.chatbot-data-item pre {
    margin: 0;
    padding: 12px;
    font-size: 10px;
    max-height: 150px;
    overflow: auto;
}

/* Typing Indicator */
.chatbot-typing {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chatbot-typing .chatbot-avatar {
    background: var(--pastel-mint);
    color: var(--accent-teal);
}

.chatbot-typing-dots {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
}

.chatbot-typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--text-tertiary);
    border-radius: 50%;
    animation: chatbot-typing-bounce 1.4s infinite ease-in-out both;
}

.chatbot-typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.chatbot-typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes chatbot-typing-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Quick Actions */
.chatbot-quick-actions {
    padding: 8px 16px;
    display: flex;
    gap: 8px;
    border-top: 1px solid var(--border-light);
    overflow-x: auto;
}

.chatbot-quick-action {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 6px 12px;
    font-size: 11px;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.chatbot-quick-action:hover {
    background: var(--accent-teal);
    color: white;
    border-color: var(--accent-teal);
}

/* Input Area */
.chatbot-input-area {
    padding: 12px 16px;
    border-top: 1px solid var(--border-light);
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chatbot-input {
    flex: 1;
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 13px;
    font-family: var(--font-primary);
    resize: none;
    max-height: 100px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: border-color 0.2s;
}

.chatbot-input:focus {
    outline: none;
    border-color: var(--accent-teal);
}

.chatbot-input::placeholder {
    color: var(--text-tertiary);
}

.chatbot-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-teal) 0%, var(--accent-purple) 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chatbot-send:hover:not(:disabled) {
    transform: scale(1.05);
}

.chatbot-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.chatbot-spinner {
    animation: chatbot-spin 1s linear infinite;
}

@keyframes chatbot-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Footer */
.chatbot-footer {
    padding: 8px 16px;
    text-align: center;
    font-size: 10px;
    color: var(--text-tertiary);
    border-top: 1px solid var(--border-light);
}

/* Responsive */
@media (max-width: 480px) {
    .chatbot-widget {
        bottom: 16px;
        right: 16px;
    }

    .chatbot-panel {
        position: fixed;
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }

    .chatbot-widget.open .chatbot-toggle {
        display: none;
    }
}

/* Dark mode adjustments */
[data-theme="dark"] .chatbot-bubble code {
    background: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .chatbot-message-user .chatbot-bubble code {
    background: rgba(0, 0, 0, 0.2);
}

/* Chat message content formatting */
.chatbot-bubble p {
    margin: 0 0 8px 0;
}

.chatbot-bubble p:last-child {
    margin-bottom: 0;
}

.chatbot-bubble h1.chat-heading,
.chatbot-bubble h2.chat-heading,
.chatbot-bubble h3.chat-heading,
.chatbot-bubble h4.chat-heading {
    margin: 12px 0 8px 0;
    font-weight: 600;
    color: var(--text-primary);
}

.chatbot-bubble h1.chat-heading:first-child,
.chatbot-bubble h2.chat-heading:first-child,
.chatbot-bubble h3.chat-heading:first-child,
.chatbot-bubble h4.chat-heading:first-child {
    margin-top: 0;
}

.chatbot-bubble h3.chat-heading {
    font-size: 14px;
    color: var(--accent-teal);
}

.chatbot-bubble h4.chat-heading {
    font-size: 13px;
}

.chatbot-bubble ul,
.chatbot-bubble ol {
    margin: 8px 0;
    padding-left: 20px;
}

.chatbot-bubble li {
    margin: 4px 0;
    line-height: 1.5;
}

/* Chat tables */
.chat-table-wrapper {
    overflow-x: auto;
    margin: 10px 0;
    border-radius: 8px;
    border: 1px solid var(--border-light);
}

.chat-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    white-space: nowrap;
}

.chat-table th,
.chat-table td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}

.chat-table th {
    background: var(--bg-tertiary);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.5px;
}

.chat-table tbody tr:hover {
    background: var(--bg-hover);
}

.chat-table tbody tr:last-child td {
    border-bottom: none;
}

/* Status colors in tables */
.chat-table .status-danger {
    color: var(--status-danger);
    font-weight: 600;
}

.chat-table .status-warning {
    color: var(--status-warning);
    font-weight: 600;
}

.chat-table .status-success {
    color: var(--status-success);
    font-weight: 600;
}

/* User bubble table adjustments */
.chatbot-message-user .chat-table-wrapper {
    border-color: rgba(255, 255, 255, 0.2);
}

.chatbot-message-user .chat-table th {
    background: rgba(0, 0, 0, 0.1);
    color: rgba(255, 255, 255, 0.8);
}

.chatbot-message-user .chat-table th,
.chatbot-message-user .chat-table td {
    border-color: rgba(255, 255, 255, 0.1);
}

/* Function results collapse */
.chatbot-function-results {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-light);
}

.chatbot-data-item {
    font-size: 11px;
    margin-bottom: 6px;
}

.chatbot-data-item summary {
    cursor: pointer;
    color: var(--text-tertiary);
    padding: 4px 0;
}

.chatbot-data-item summary:hover {
    color: var(--text-secondary);
}

.chatbot-data-item pre {
    margin: 8px 0;
    padding: 10px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    overflow-x: auto;
    font-size: 10px;
    max-height: 200px;
}
