/* ===== Layout & Container Styles ===== */
.dashboard-container {
    width: 100%;
    height: 100%;
    background-color: #f0f3f8;
    position: relative;
    overflow: hidden;
    margin: 0 auto !important;
}

.grid-stack,
.resize-container,
#gridstack-container {
    width: 100%;
    height: 100%;
    position: relative;
}

/* ===== Grid Item Styles ===== */
.grid-stack-item {
    position: relative;
    padding-top: 15px !important;
}

.grid-widget {
    table-layout: fixed;
}

/* disable scroll for report grid items */
.grid-item-body[id^="gwt-gridstack-body-report"] {
    overflow: hidden !important;
}

.grid-stack-item-content {
    padding: 0 8px;
    box-sizing: border-box;
    border-radius: 10px;
    position: relative;
    overflow: hidden !important;
    height: calc(100% - 30px) !important;
    display: flex;
    flex-direction: column;
    background-color: #ffffff;
    box-shadow: 0px 3px 15px #d9dae7;
    /*box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);*/
}

/* Grid Item States */
.grid-stack-item.ui-draggable-dragging {
    cursor: move !important;
}

.grid-item-header {
    flex: 0 0 auto;
    height: 16px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 8px 0px;
    background: #ffffff;
}

/* Footer */
.grid-item-footer {
    flex: 0 0 auto;
    height: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #ffffff;
}

.grid-item-footer:not(:empty) {
    height: auto;
    min-height: 40px;
}

/* Updated hover states for grid-stack-item-content */
.grid-stack-item-content:hover {
    border: 2px solid #007aab;
    box-shadow: none;
    /*box-shadow: 0 3px 15px #007aab;*/
}

.grid-stack-item.ui-draggable-dragging .grid-stack-item-content {
    border: 2px solid #007aab;
    box-shadow: none;
}

.grid-stack-item.ui-resizable-resizing .grid-stack-item-content {
    border: 2px solid #007aab;
    box-shadow: none;
}

.grid-item-body {
    flex: 1 1 auto;
    overflow: auto;
    border-radius: 0px;
    background: #ffffff;
    position: relative;
    display: flex;
    flex-direction: column;
}

.grid-item-body > *:not(.loading-placeholder) {
    flex: 1;
    overflow: auto; /* Individual content is also scrollable */
    width: 100%;
    height: 100%;
    position: relative;
}

/* Close/ Button */
.close-button-container {
    pointer-events: auto;
}

.grid-item-close-button {
    cursor: pointer;
}

.grid-item-button-wrapper {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

.grid-stack-item > .grid-stack-item-content {
    inset: 8px !important;
}

.grid-stack-item:hover .grid-item-button-wrapper {
    opacity: 1;
}

.grid-item-close-button {
    font-size: 16px;
    font-weight: bold;
    padding: 0 6px;
    background: #f0f0f0;
    border-radius: 3px;
    border: 1px solid #ccc;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

.grid-stack-item:hover .grid-item-close-button {
    opacity: 1;
}

.grid-item-close-button:hover {
    background: #dc3545; /* Red background on hover */
    color: white; /* White text/X on hover */
}

/* ===== Resize Handles ===== */
.grid-stack > .grid-stack-item > .ui-resizable-handle {
    position: absolute;
    z-index: 0 !important;
    display: block;
    background-color: transparent;
    border: none;
    touch-action: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: auto;
}

.grid-stack > .grid-stack-item > .ui-resizable-s {
    bottom: 5px;
    cursor: s-resize;
    height: 10px;
    left: 25px;
    right: 25px;
}

.grid-stack > .grid-stack-item > .ui-resizable-e {
    cursor: e-resize;
    width: 10px;
    right: 5px;
    top: 25px;
    bottom: 25px;
}

.grid-stack > .grid-stack-item > .ui-resizable-se {
    cursor: se-resize;
    width: 20px;
    height: 20px;
    right: 16px !important;
    bottom: 30px !important;
    transform: rotate(5deg) !important;
    background: transparent;
    background-image: url("images/resize.svg") !important;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.grid-stack > .grid-stack-item:hover > .ui-resizable-se {
    opacity: 1 !important;
    background-image: url("images/resize.svg") !important;
}

.grid-stack > .grid-stack-item.ui-resizable-resizing > .ui-resizable-se {
    opacity: 1 !important;
    background-image: url("images/resize.svg") !important;
}

/* ===== CRITICAL FIX: Override GridStack's problematic autohide behavior, resize icon hidden until browser refresh===== */
.grid-stack > .grid-stack-item.ui-resizable-autohide > .ui-resizable-handle,
.grid-stack > .grid-stack-item.ui-resizable-disabled > .ui-resizable-handle {
    /* Override the display: none that gets stuck */
    display: block !important;
    opacity: 0;
}

/* ===== Handle Visibility States ===== */
.grid-stack > .grid-stack-item:hover > .ui-resizable-handle {
    opacity: 1 !important;
}

/* Show handles during interactions */
.grid-stack > .grid-stack-item.ui-draggable-dragging > .ui-resizable-handle,
.grid-stack > .grid-stack-item.ui-resizable-resizing > .ui-resizable-handle {
    opacity: 1 !important;
    z-index: 1001;
}

/* ===== Loading States ===== */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(255, 255, 255, 0.5);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading-spinner,
.placeholder-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    font-size: 14px;
    color: #6c757d;
}

.loading-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
    color: #6c757d;
    gap: 12px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== Toast Notifications ===== */
.toast-message {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 20px;
    border-radius: 5px;
    color: white;
    font-size: 14px;
    z-index: 1000;
    opacity: 0.9;
    animation: fadein 0.5s, fadeout 0.5s 2.5s;
}

.toast-success {
    background-color: #4CAF50; /* Green */
}

.toast-error {
    background-color: #F44336; /* Red */
}

.toast-info {
    background-color: #2196F3; /* Blue */
}

@keyframes fadein {
    from { opacity: 0; }
    to { opacity: 0.9; }
}

@keyframes fadeout {
    from { opacity: 0.9; }
    to { opacity: 0; }
}

/* ===== Error States ===== */
.dashboard-error {
    padding: 15px;
    background-color: #ffebee;
    color: #c62828;
    border-radius: 4px;
    margin: 10px 0;
    border: 1px solid #ffcdd2;
}

/* ===== Misc ===== */
.popupContent table {
    border-radius: 0px; // this is interferring with border radius on all popups
}

@media (max-width: 768px) {
    .grid-item-body {
        padding: 12px; /* Slightly less padding on mobile */
    }
}

.grid-item-body.compact {
    padding: 8px; /* Less padding for compact content */
}

.grid-item-body.spacious {
    padding: 24px; /* More padding for spacious content */
}

.grid-item-body.minimal {
    padding: 4px; /* Minimal padding */
}