﻿/* ================================================================
   MINIMAL DASHBOARD FIXES - Let GridStack Handle Positioning
   Only style what GridStack doesn't control
   ================================================================ */

/* ================================================================
   WIDGET CONTENT STYLING ONLY - No positioning!
   ================================================================ */

/* Widget container appearance */
.dynamic-widget-content {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    box-sizing: border-box;
}

/* Widget header styling - Always visible with compact height */
.dynamic-widget-controls {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    padding: 6px 10px;
    border-bottom: 1px solid #e0e0e0;
    border-radius: 8px 8px 0 0; /* Rounded top corners only */
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    font-weight: 600;
    color: #495057;
    flex-shrink: 0;
    min-height: 22px; /* Smaller fixed height */
    height: 22px;
}

/* Widget title section with info icon */
.widget-title-section {
    display: flex;
    align-items: center;
    gap: 4px;
}

.widget-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.widget-info-icon {
    font-size: 14px;
    cursor: help;
    opacity: 0.6;
    margin-left: 6px;
    transition: opacity 0.2s ease;
    user-select: none;
}

.widget-info-icon:hover {
    opacity: 1 !important;
}

/* Widget actions */
.dynamic-widget-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* Icon buttons */
.widget-icon-button {
    background: transparent;
    border: none;
    padding: 4px 6px;
    cursor: pointer;
    border-radius: 3px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
    font-size: 16px;
    line-height: 1;
    user-select: none;
}

.widget-icon-button:hover {
    background: rgba(0, 0, 0, 0.05);
}

.widget-icon-button.settings-btn {
    opacity: 0.7;
}

.widget-icon-button.settings-btn:hover {
    background: rgba(108, 117, 125, 0.1);
    opacity: 1;
}

.widget-icon-button.delete-btn {
    opacity: 0.7;
}

.widget-icon-button.delete-btn:hover {
    background: rgba(220, 53, 69, 0.1);
    opacity: 1;
}

/* Widget body */
.dynamic-widget-body {
    flex: 1;
    padding: 1px;
    overflow: hidden; /* Changed from auto - let widgets handle their own scrolling */
/*    display: flex;*/
    align-items: center;
    justify-content: center;
    text-align: center;
}

/* Ensure .widget-content wrapper passes through height constraint */
.widget-content {
    height: 100% !important;
    width: 100% !important;
    border-radius: 0 0 8px 8px; /* Only rounded bottom corners */
    overflow: hidden;
}

/* Ensure widget content takes full height so internal scrolling works */
.dynamic-widget-body,
.dynamic-widget-body > *,
.dynamic-widget-body > div,
.dynamic-widget-body .credit-spreads-widget,
.dynamic-widget-body .technical-ideas-widget,
.dynamic-widget-body .widget-base {
    height: 100% !important;
    width: 100% !important;
}

/* ================================================================
   MODE-SPECIFIC VISIBILITY ONLY - No positioning!
   ================================================================ */

/* Headers are always visible in all modes */
.dynamic-widget-controls {
    display: flex !important;
}

/* Dragging cursor in edit mode */
.dashboard-grid.edit-mode .dynamic-widget-controls,
.dashboard-grid.configure-mode .dynamic-widget-controls {
    cursor: grab;
}

/* Grabbing cursor while dragging */
.grid-stack-item.ui-draggable-dragging .dynamic-widget-controls {
    cursor: grabbing;
}

/* ================================================================
   VISUAL ENHANCEMENTS ONLY - No transforms or positioning!
   ================================================================ */

/* Hover effects */
.dynamic-widget-content:hover {
    border-color: var(--rz-primary-light, #4CAF50);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Dragging visual feedback */
.grid-stack-item.ui-draggable-dragging .dynamic-widget-content {
    opacity: 0.8;
    box-shadow: 0 12px 24px rgba(0,0,0,0.3);
}

/* Grid lines for edit mode */
.dashboard-grid.edit-mode::before,
.dashboard-grid.configure-mode::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: repeating-linear-gradient(
        90deg,
        transparent,
        transparent calc(100%/12 - 1px),
        rgba(0, 123, 212, 0.1) calc(100%/12 - 1px),
        rgba(0, 123, 212, 0.1) calc(100%/12)
    );
    pointer-events: none;
    z-index: 0;
}

/* ================================================================
   RESPONSIVE ADJUSTMENTS - Content only, no positioning!
   ================================================================ */

@media (max-width: 768px) {
    .dynamic-widget-body {
        padding: 8px;
    }
    
    .dynamic-widget-controls {
        padding: 6px 8px;
        font-size: 11px;
    }
}