﻿/* ================================================================
   MINIMAL DASHBOARD FIXES - Let GridStack Handle Positioning
   Only style what GridStack doesn't control
   ================================================================ */

/* ================================================================
   WIDGET CONTENT STYLING ONLY - No positioning!
   ================================================================ */

/* Let GridStack item content show child shadows */
.grid-stack-item-content {
    overflow: visible !important;
    background: transparent !important;
}

/* Resize handles — hidden by default (view mode), visible in edit mode */
.grid-stack-item > .ui-resizable-handle {
    background: transparent !important;
    background-image: none !important;
    z-index: 1000;
}

/* Widget container appearance */
.dynamic-widget-content {
    background: var(--rz-base-background-color, white);
    border: 1px solid var(--rz-base-300, #e0e0e0);
    border-radius: 8px;
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    box-sizing: border-box;
}

/* Widget header styling */
.dynamic-widget-controls {
    background: var(--rz-base-background-color, #f8f9fa);
    padding: 0 14px;
    border-bottom: 1px solid var(--rz-base-300, #e0e0e0);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--rz-text-color, #323130);
    flex-shrink: 0;
    height: 35px;
}

/* 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: var(--rz-text-color, #201f1e);
}

.widget-info-icon {
    font-size: 18px;
    cursor: help;
    opacity: 0.5;
    margin-left: 4px;
    transition: opacity 0.2s ease;
    user-select: none;
    color: var(--rz-text-secondary-color, #605e5c);
}

.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;
    cursor: pointer;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
    line-height: 1;
    user-select: none;
    color: var(--rz-text-secondary-color, #605e5c);
}

.widget-icon-button .rzi {
    font-size: 18px;
}

.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-icon-button.screenshot-btn {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.dynamic-widget-content:hover .widget-icon-button.screenshot-btn {
    opacity: 0.5;
}

.widget-icon-button.screenshot-btn:hover {
    background: rgba(79, 122, 52, 0.1);
    opacity: 1 !important;
}

/* Widget body */
.dynamic-widget-body {
    flex: 1;
    padding: 1px;
    overflow: hidden; /* Let widgets handle their own scrolling */
    background: var(--rz-base-background-color, #fafafa);
}

/* Ensure .widget-content wrapper passes through height constraint */
.widget-content {
    height: 100% !important;
    width: 100% !important;
    overflow: hidden;
}

/* Kill inner widget border-radius — the outer .dynamic-widget-content handles all rounding */
.dynamic-widget-body > * {
    border-radius: 0 !important;
    box-shadow: none !important;
}

/* 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 .covered-calls-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 column 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%/24 - 1px),
        rgba(150, 150, 150, 0.15) calc(100%/24 - 1px),
        rgba(150, 150, 150, 0.15) calc(100%/24)
    );
    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;
    }
}