/**
 * Chart Toggle & Reorder Styles
 * Windows-style header bar for charts (admin only)
 */

/* Header bar - Windows-style title bar above each chart */
.ar-chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(to bottom, #f8f9fa 0%, #e9ecef 100%);
    border: 1px solid #dee2e6;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    padding: 8px 12px;
    user-select: none;
    min-height: 40px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* Edit mode header - draggable */
.ar-chart-header-edit {
    cursor: move;
}

/* View mode header - industry standard dashboard style */
.ar-chart-header-view {
    justify-content: space-between;
    cursor: default;
    background: linear-gradient(to bottom, #ffffff 0%, #f8f9fa 100%);
    border-bottom: 1px solid #dee2e6;
}

.ar-chart-header-view .ar-chart-header-title {
    text-align: left;
    padding: 0;
    flex: 1;
    font-weight: 500;
    color: #333;
}

/* Chart/Analytics icon in view mode header (non-interactive) */
.ar-chart-header-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    cursor: default;
}

.ar-chart-header-icon svg {
    width: 18px;
    height: 18px;
    fill: #8e9aaf;
    opacity: 0.7;
}

.ar-chart-header-view .ar-chart-header-icon svg {
    fill: #667eea;
    opacity: 0.6;
}

.ar-chart-header-simple .ar-chart-header-icon svg {
    fill: #6c757d;
    opacity: 0.6;
}

/* Simple header for non-chart elements (disclaimer, first panel) */
.ar-chart-header-simple {
    justify-content: space-between;
    cursor: default;
    background: linear-gradient(to bottom, #ffffff 0%, #f8f9fa 100%);
    border-bottom: 1px solid #dee2e6;
    border-radius: 6px 6px 0 0;
    margin-bottom: 0;
}

.ar-chart-header-simple .ar-chart-header-title {
    text-align: left;
    padding: 0;
    flex: 1;
    font-weight: 500;
    color: #333;
}

.ar-chart-wrapper-simple .p-4,
.ar-chart-wrapper-simple .disclaimer {
    border-top: none !important;
    border-radius: 0 0 6px 6px !important;
}

/* Ensure consistent spacing for wrapper */
.ar-chart-wrapper-simple {
    margin-bottom: 1rem !important;
    margin-top: 0 !important;
}

.ar-chart-wrapper-simple .disclaimer {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

/* Fix disclaimer specific styling - override Bootstrap mb-4 */
.ar-chart-wrapper-simple .disclaimer.mb-4,
.ar-chart-wrapper-simple .disclaimer.p-4,
.ar-chart-wrapper-simple > .disclaimer {
    margin-bottom: 0 !important;
    margin-top: 0 !important;
}

/* All chart wrappers have consistent spacing between each other */
.ar-chart-wrapper {
    margin-bottom: 1rem !important;
}

/* Last chart wrapper before disclaimer - no bottom margin */
.maincol1 > .ar-chart-wrapper:last-child,
.maincol2 > .ar-chart-wrapper:last-child {
    margin-bottom: 0 !important;
}

/* Program sections - no extra margin */
#ar-program-sections,
#section-program,
#section-publications,
#widget-program-charts,
#widget-program-charts > .row,
.maincol1,
.maincol2,
.bottomcol1,
.bottomcol2 {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
}

/* Hide empty containers */
#section-publications:empty,
.bottomcol1:empty,
.bottomcol2:empty {
    display: none !important;
}

/* Simple header icon styles inherited from .ar-chart-header-icon */

/* Drag handle area (left side) */
.ar-chart-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.ar-chart-drag-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    cursor: move;
}

.ar-chart-drag-handle svg {
    width: 16px;
    height: 16px;
    fill: #6c757d;
    transition: fill 0.2s;
}

.ar-chart-header:hover .ar-chart-drag-handle svg {
    fill: #495057;
}

/* Title area (center) */
.ar-chart-header-title {
    flex: 1;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: #495057;
    padding: 0 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Toggle area (right side) */
.ar-chart-header-right {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

/* Toggle switch container */
.ar-chart-toggle {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    cursor: pointer;
}

/* Hide default checkbox */
.ar-chart-toggle-input {
    opacity: 0;
    width: 0;
    height: 0;
}

/* Slider background */
.ar-chart-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #f0ad4e;
    transition: 0.3s;
    border-radius: 22px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.2);
}

/* Slider circle */
.ar-chart-toggle-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* Checked state - green and slider to right */
.ar-chart-toggle-input:checked + .ar-chart-toggle-slider {
    background-color: #5cb85c;
}

.ar-chart-toggle-input:checked + .ar-chart-toggle-slider:before {
    transform: translateX(18px);
}

/* Focus state */
.ar-chart-toggle-input:focus + .ar-chart-toggle-slider {
    box-shadow: 0 0 1px #5cb85c, inset 0 1px 3px rgba(0,0,0,0.2);
}

/* Chart wrapper - includes header + chart */
.ar-chart-wrapper {
    margin-bottom: 1rem;
}

/* When header exists - no top border, bottom corners only */
.ar-chart-wrapper:has(.ar-chart-header) .p-4 {
    border-radius: 0 0 6px 6px !important;
    border-top: none !important;
}

/* When no header (view mode) - full border and rounded corners */
.ar-chart-wrapper:not(:has(.ar-chart-header)) .p-4 {
    border-radius: 6px !important;
}

/* Dragging states */
.ar-chart-wrapper.ar-chart-dragging {
    opacity: 0.6;
    transform: scale(0.98);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

.ar-chart-wrapper.ar-chart-drag-over {
    border-top: 3px solid #007bff;
    margin-top: -3px;
}

.ar-chart-drag-placeholder {
    background: rgba(0, 123, 255, 0.1);
    border: 2px dashed #007bff;
    min-height: 100px;
    margin-bottom: 1rem;
    border-radius: 6px;
}

/* Disabled chart container */
.ar-chart-disabled {
    position: relative !important;
}

/* Disabled chart overlay */
.ar-chart-disabled-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.90);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: 0 0 6px 6px;
    pointer-events: all;
    cursor: default;
}

/* Hide Highcharts tooltips when chart is disabled */
.ar-chart-disabled .highcharts-tooltip {
    display: none !important;
}

/* Disable pointer events on chart content when disabled */
.ar-chart-disabled .highcharts-container {
    pointer-events: none !important;
}

.ar-chart-disabled-overlay span {
    background-color: rgba(240, 173, 78, 0.9);
    color: #333;
    font-size: 14px;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Header bar for disabled charts - slightly dimmed */
.ar-chart-wrapper.ar-chart-disabled-wrapper .ar-chart-header {
    background: linear-gradient(to bottom, #f0f0f0 0%, #e0e0e0 100%);
}

.ar-chart-wrapper.ar-chart-disabled-wrapper .ar-chart-header-title {
    color: #888;
}

/* Collapse/Expand button */
.ar-chart-collapse-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    cursor: pointer;
    border-radius: 6px;
    transition: background-color 0.2s, transform 0.1s;
}

.ar-chart-collapse-btn:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.ar-chart-collapse-btn:active {
    transform: scale(0.92);
}

.ar-chart-collapse-btn svg {
    width: 20px;
    height: 20px;
    fill: #495057;
    transition: fill 0.15s;
}

.ar-chart-header:hover .ar-chart-collapse-btn svg {
    fill: #212529;
}

/* Collapsed state */
.ar-chart-wrapper.ar-chart-collapsed .ar-chart-header {
    border-radius: 6px;
    border-bottom: 1px solid #dee2e6;
}

/* Floating Admin Button (FAB) */
.ar-admin-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.ar-admin-fab-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff !important;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none !important;
    border-radius: 50px;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4), 0 2px 6px rgba(0,0,0,0.15);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

.ar-admin-fab-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5), 0 4px 10px rgba(0,0,0,0.2);
    text-decoration: none !important;
    color: #fff !important;
}

.ar-admin-fab-btn:active {
    transform: translateY(0) scale(0.98);
}

.ar-admin-fab-btn svg {
    flex-shrink: 0;
}

.ar-admin-fab-btn span {
    line-height: 1;
}

/* Edit mode active - different color scheme */
.ar-admin-fab-editing .ar-admin-fab-btn {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    box-shadow: 0 4px 15px rgba(245, 87, 108, 0.4), 0 2px 6px rgba(0,0,0,0.15);
}

.ar-admin-fab-editing .ar-admin-fab-btn:hover {
    box-shadow: 0 6px 20px rgba(245, 87, 108, 0.5), 0 4px 10px rgba(0,0,0,0.2);
}

/* Responsive - smaller on mobile */
@media (max-width: 600px) {
    .ar-admin-fab {
        bottom: 16px;
        right: 16px;
    }

    .ar-admin-fab-btn {
        padding: 10px 16px;
        font-size: 13px;
    }
}
