/* ACC Dashboard - Custom Styles */

/* Base styles */
* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Gridstack customization */
.grid-stack {
    min-height: 400px;
    width: 100%;
}

.grid-stack-item-content {
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.grid-stack > .grid-stack-item > .grid-stack-item-content {
    inset: 4px;
    border-radius: 0.75rem;
    overflow: hidden;
}

.grid-stack-placeholder > .placeholder-content {
    background-color: rgba(59, 130, 246, 0.1);
    border: 2px dashed rgba(59, 130, 246, 0.3);
    border-radius: 0.75rem;
}

/* Chart container */
.chart-container {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 150px;
}

/* Ensure canvas fills container */
.grid-stack-item-content canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Chart content container */
.chart-content {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-content canvas {
    max-width: 100%;
    max-height: 100%;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Query input focus ring */
#query-input:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* Sample query buttons */
.sample-query {
    transition: all 0.15s ease;
}

.sample-query:hover {
    transform: translateY(-1px);
}

/* Widget styling */
.grid-stack-item-content {
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.grid-stack-item-content:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    transform: translateY(-2px);
}

/* Widget header styling */
.widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #f3f4f6;
    margin-bottom: 0.75rem;
}

.widget-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #111827;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.widget-title-icon {
    width: 1rem;
    height: 1rem;
    min-width: 1rem;
    min-height: 1rem;
    max-width: 1rem;
    max-height: 1rem;
    color: #6b7280;
    flex-shrink: 0;
}

.widget-close {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.grid-stack-item-content:hover .widget-close {
    opacity: 1;
}

/* Loading animation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Status badge colors */
.status-open { background-color: #fee2e2; color: #991b1b; }
.status-in-progress { background-color: #fef3c7; color: #92400e; }
.status-resolved { background-color: #d1fae5; color: #065f46; }
.status-closed { background-color: #f3f4f6; color: #374151; }

/* Priority badge colors */
.priority-critical { background-color: #fee2e2; color: #991b1b; }
.priority-high { background-color: #ffedd5; color: #9a3412; }
.priority-medium { background-color: #fef3c7; color: #92400e; }
.priority-low { background-color: #d1fae5; color: #065f46; }

/* KPI card styles */
.kpi-value {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
}

.kpi-trend-up {
    color: #059669;
}

.kpi-trend-down {
    color: #dc2626;
}

.kpi-trend-stable {
    color: #6b7280;
}

/* Table styles */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    background-color: #f9fafb;
    font-weight: 500;
    text-align: left;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e5e7eb;
}

.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e5e7eb;
}

.data-table tr:hover {
    background-color: #f9fafb;
}

/* Prose styling for message content */
.prose p {
    margin-bottom: 1rem;
}

.prose strong {
    font-weight: 600;
    color: #111827;
}

.prose ul, .prose ol {
    padding-left: 1.5rem;
    margin-bottom: 1rem;
}

.prose li {
    margin-bottom: 0.25rem;
}

/* Interaction Timeline Styles */
#interaction-timeline {
    border-top: 1px solid #e5e7eb;
    padding-top: 1rem;
}

.timeline-item {
    border-left: 2px solid transparent;
    transition: all 0.15s ease;
}

.timeline-item:hover {
    border-left-color: #3b82f6;
    background-color: #f9fafb;
}

.timeline-item .details-content {
    font-family: monospace;
    font-size: 10px;
    background-color: #f3f4f6;
    padding: 0.5rem;
    border-radius: 0.25rem;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 150px;
    overflow-y: auto;
}

/* Timeline type colors */
.text-blue-600 { color: #2563eb; }
.text-purple-600 { color: #9333ea; }
.text-green-600 { color: #16a34a; }
.text-orange-600 { color: #ea580c; }
.text-teal-600 { color: #0d9488; }
.text-gray-600 { color: #4b5563; }
.text-red-600 { color: #dc2626; }

/* Live log styles */
#live-log {
    font-family: monospace;
    font-size: 11px;
}

#live-log > div {
    padding: 2px 0;
    border-bottom: 1px solid #f3f4f6;
}

/* Processing status animation */
#processing-status {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Chat panel styles */
.chat-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Chat messages container */
#chat-messages {
    display: flex;
    flex-direction: column;
    padding-bottom: 1rem;
    min-height: 0;
}

#chat-messages.hidden {
    display: none !important;
}

/* Chat message styles */
.chat-message {
    display: flex;
    margin-bottom: 0.75rem;
    animation: messageSlide 0.3s ease;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.user {
    justify-content: flex-end;
}

.chat-message.agent {
    justify-content: flex-start;
}

.chat-bubble {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    word-wrap: break-word;
}

.chat-message.user .chat-bubble {
    background-color: #3b82f6;
    color: white;
    border-bottom-right-radius: 0.25rem;
}

.chat-message.agent .chat-bubble {
    background-color: #f3f4f6;
    color: #1f2937;
    border-bottom-left-radius: 0.25rem;
    border: 1px solid #e5e7eb;
}

.chat-bubble p {
    margin: 0;
    line-height: 1.5;
}

.chat-bubble p + p {
    margin-top: 0.5rem;
}

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

.chat-message.agent .chat-bubble strong {
    color: #111827;
}

.chat-message-label {
    font-size: 0.675rem;
    color: #9ca3af;
    margin-bottom: 0.25rem;
}

.chat-message.user .chat-message-label {
    text-align: right;
}

.chat-message.agent .chat-message-label {
    text-align: left;
}

.chat-message-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 85%;
}

/* Agent avatar */
.agent-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background-color: #e0e7ff;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.5rem;
    flex-shrink: 0;
}

.agent-avatar svg {
    width: 1.25rem;
    height: 1.25rem;
    color: #4f46e5;
}

/* Response section scroll */
#response-section {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f1f5f9;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    main {
        flex-direction: column-reverse;
    }

    main > div:last-child {
        width: 100%;
        height: auto;
        max-height: 50vh;
        border-left: none;
        border-bottom: 1px solid #e5e7eb;
    }

    main > div:first-child {
        flex: 1;
        min-height: 50vh;
    }

    .grid-stack {
        --gs-columns: 6;
    }
}

@media (max-width: 768px) {
    .sample-query {
        font-size: 0.7rem;
    }

    main > div:last-child {
        width: 100%;
    }
}

/* Print styles */
@media print {
    header,
    #query-section,
    .widget-close,
    #reload-btn,
    .sample-query,
    #processing-status,
    #interaction-timeline {
        display: none !important;
    }

    main {
        display: block;
    }

    main > div:last-child {
        display: none;
    }

    .grid-stack-item {
        page-break-inside: avoid;
    }
}

/* Animation for toast notifications */
.toast-enter {
    transform: translateY(0);
    opacity: 1;
}

.toast-exit {
    transform: translateY(100%);
    opacity: 0;
}

/* Focus visible for accessibility */
button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Disabled state */
button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Widget resize handles */
.gs-resizable-handle {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.grid-stack-item:hover .gs-resizable-handle {
    opacity: 0.5;
}

.gs-resizable-handle:hover {
    opacity: 1 !important;
}

/* Agent badges in response */
#agents-used span:not(:first-child) {
    margin-left: 0.25rem;
}

/* Empty state in dashboard */
#empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
}

/* Two-column layout optimization */
main.flex {
    overflow: hidden;
}

main > div:first-child {
    overflow-y: auto;
    overflow-x: hidden;
}
