/* Widget Container Styles
 * Styles for analytics widget area and widget cards
 * Compatible with both sidebar and center-focused layouts
 */

/* ============================================
   FefferyGrid Grid Item Wrapper Fix
   ============================================
   Ensure wrapper doesn't interfere with widget glassmorphism styling
   Note: FefferyGrid uses react-grid-layout under the hood
*/

/* Reset grid item wrapper to be transparent and non-interfering */
.react-grid-item {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    overflow: visible !important;  /* Allow glassmorphism ::before pseudo-element to extend */
}

/* Ensure widget card fills the grid item properly */
.react-grid-item > .ant-card {
    width: 100%;
    /* height controlled by grid item and Python styles, not CSS */
    box-sizing: border-box;
}

/* FefferyGridItem styling - ensure proper fill */
.feffery-grid-item-container {
    height: 100%;
    width: 100%;
}

/* Allow widget card hover glow (box-shadow) to extend beyond grid item bounds */
.feffery-grid-item-container > div, .react-grid-item > div {
    overflow: visible !important;
}

/* ============================================
   Widget Container Styles
   ============================================ */

/* Widget container - scrollable area for widget cards */
.widget-container,
#widget-container {
    overflow-y: auto;
    max-height: calc(100vh - 40px); /* Leave room for padding */
    padding: 0; /* Parent .analytics-widget-area handles padding */
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Analytics widget area (center-focused layout) */
.analytics-widget-area {
    overflow-x: visible; /* Allow box-shadow to extend beyond bounds */
    overflow-y: auto;
    padding: 20px;
    background: rgba(255, 255, 255, 0.02);
}

/* Scrollbar styling for widget container (dark theme) */
.widget-container::-webkit-scrollbar,
#widget-container::-webkit-scrollbar,
.analytics-widget-area::-webkit-scrollbar {
    width: 8px;
}

.widget-container::-webkit-scrollbar-track,
#widget-container::-webkit-scrollbar-track,
.analytics-widget-area::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.widget-container::-webkit-scrollbar-thumb,
#widget-container::-webkit-scrollbar-thumb,
.analytics-widget-area::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

.widget-container::-webkit-scrollbar-thumb:hover,
#widget-container::-webkit-scrollbar-thumb:hover,
.analytics-widget-area::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Glassmorphism widget cards */
.widget-card-glass {
    position: relative;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    overflow: hidden;
    /* box-shadow: 0 8px 32px rgba(139, 92, 246, 0.1); */ /* Removed - only show on hover */
    transition: all 0.25s cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* Extended backdrop technique for realistic blur */
.widget-card-glass::before {
    content: '';
    position: absolute;
    inset: 0;
    height: 200%; /* Extended to capture nearby elements */
    backdrop-filter: blur(16px) brightness(105%);
    -webkit-backdrop-filter: blur(16px) brightness(105%); /* Safari support */
    mask-image: linear-gradient(to bottom, black 0% 50%, transparent 50% 100%);
    -webkit-mask-image: linear-gradient(to bottom, black 0% 50%, transparent 50% 100%);
    pointer-events: none;
    z-index: -1;
}

/* Glassmorphism hover effect */
.widget-card-glass:hover {
    box-shadow: 0 8px 24px rgba(139, 92, 246, 0.08);
    transform: translateY(-2px);
}

/* Remove border between header and content in glassmorphism cards */
/* Target ALL possible elements that could have borders */
.widget-card-glass .ant-card-head,
.widget-card-glass.ant-card .ant-card-head,
.widget-card-glass .ant-card-head-wrapper,
.widget-card-glass.ant-card .ant-card-head-wrapper,
.widget-card-glass .ant-card-head-title,
.widget-card-glass.ant-card .ant-card-head-title {
    border: none !important;
    border-bottom: none !important;
    border-bottom-width: 0 !important;
    border-bottom-color: transparent !important;
}

/* Also remove border-top from body */
.widget-card-glass .ant-card-body,
.widget-card-glass.ant-card .ant-card-body {
    border: none !important;
    border-top: none !important;
    border-top-width: 0 !important;
    border-top-color: transparent !important;
}

/* Hide the ant-card-cover element that creates the line */
.widget-card-glass .ant-card-cover,
.widget-card-glass.ant-card .ant-card-cover {
    display: none !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Hide default chart axis label tooltips (we use custom dark tooltips) */
svg text[title] {
    pointer-events: none !important;
}

/* Fallback for browsers without backdrop-filter support */
@supports not (backdrop-filter: blur(16px)) {
    .widget-card-glass {
        background: rgba(255, 255, 255, 0.08);
    }
}

/* Legacy hover effects (for non-glass cards) */
.ant-card.ant-card-hoverable:hover {
    box-shadow: 0 4px 12px rgba(75, 156, 211, 0.15);
    transform: translateY(-2px);
    transition: all 0.3s ease;
}

/* Widget card title styling */
.ant-card-head {
    user-select: none;
}

/* Widget header icon styling */
.widget-header-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    font-size: 12px;
    color: rgba(255, 255, 255, 0.85);
    flex-shrink: 0;  /* Prevent icon from shrinking */
}

/* Widget markdown content styling */
.widget-container .feffery-markdown,
#widget-container .feffery-markdown {
    font-size: 14px;
    line-height: 1.6;
}

/* Widget markdown headings - match chat message styling exactly */
.widget-container .feffery-markdown h1,
#widget-container .feffery-markdown h1 {
    font-size: 24px;  /* Match chat */
    font-weight: 600;
    margin-top: 16px;
    margin-bottom: 8px;
    color: rgba(255, 255, 255, 0.9);
}

.widget-container .feffery-markdown h2,
#widget-container .feffery-markdown h2 {
    font-size: 20px;  /* Match chat */
    font-weight: 600;
    margin-top: 16px;
    margin-bottom: 8px;
    color: rgba(255, 255, 255, 0.85);
}

.widget-container .feffery-markdown h3,
#widget-container .feffery-markdown h3 {
    font-size: 18px;  /* Match chat */
    font-weight: 600;
    margin-top: 16px;
    margin-bottom: 8px;
    color: rgba(255, 255, 255, 0.8);
}

.widget-container .feffery-markdown h4,
#widget-container .feffery-markdown h4 {
    font-size: 16px;  /* Match chat */
    font-weight: 600;
    margin-top: 16px;
    margin-bottom: 8px;
    color: rgba(255, 255, 255, 0.75);
}

/* Widget markdown code blocks */
.widget-container .feffery-markdown pre,
#widget-container .feffery-markdown pre {
    background: rgba(0, 0, 0, 0.3) !important;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    padding: 12px;
    overflow-x: auto;
}

/* Widget markdown inline code */
.widget-container .feffery-markdown code,
#widget-container .feffery-markdown code {
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.9em;
    color: #4b9cd3;
}

/* Widget markdown lists */
.widget-container .feffery-markdown ul,
#widget-container .feffery-markdown ul,
.widget-container .feffery-markdown ol,
#widget-container .feffery-markdown ol {
    padding-left: 20px;
}

/* Widget markdown tables */
.widget-container .feffery-markdown table,
#widget-container .feffery-markdown table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
}

.widget-container .feffery-markdown th,
#widget-container .feffery-markdown th,
.widget-container .feffery-markdown td,
#widget-container .feffery-markdown td {
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px;
    text-align: left;
}

.widget-container .feffery-markdown th,
#widget-container .feffery-markdown th {
    background: rgba(255, 255, 255, 0.05);
    font-weight: 500;
}

/* Widget markdown blockquotes */
.widget-container .feffery-markdown blockquote,
#widget-container .feffery-markdown blockquote {
    border-left: 4px solid #4b9cd3;
    padding-left: 16px;
    margin: 10px 0;
    color: rgba(255, 255, 255, 0.7);
    font-style: italic;
}

/* Empty state message (if no widgets) */
.analytics-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 40px;
}
