/*
 *
 *  This is file is part of DGL's tech stack.
 *
 *  @copyright (c) 2024, Deadan Group Limited (DGL).
 *  @link https://www.dgl.co.ke/apps
 *  All rights reserved.
 *
 *  <code>Build something people want!</code>
 *
 *  Dashboard Widget Panel Styles
 */

/* ==========================================================================
   Widget Panel Base
   ========================================================================== */
.widget-panel {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    margin-bottom: 15px;
    transition: all 0.3s ease;
    position: relative;
}

.widget-panel.dragging {
    opacity: 0.6;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    z-index: 100;
}

.widget-panel.drag-over {
    border: 2px dashed #0d6efd;
    background: #f0f7ff;
}

/* ==========================================================================
   Widget Header
   ========================================================================== */
.widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 15px;
    border-bottom: 1px solid #dee2e6;
    background: #f8f9fa;
    border-radius: 0.375rem 0.375rem 0 0;
    cursor: grab;
    user-select: none;
}

.widget-header:active {
    cursor: grabbing;
}

.widget-title {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.widget-title i {
    margin-right: 5px;
    color: #6c757d;
}

.widget-refresh-indicator {
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

/* ==========================================================================
   Widget Controls
   ========================================================================== */
.widget-controls {
    display: flex;
    gap: 2px;
}

.widget-ctrl {
    padding: 2px 6px;
    color: #6c757d;
    text-decoration: none;
    border: none;
    background: none;
    font-size: 12px;
    line-height: 1;
    border-radius: 3px;
    transition: all 0.15s;
}

.widget-ctrl:hover {
    color: #333;
    background: #e9ecef;
}

.widget-ctrl[data-action="hide"]:hover {
    color: #dc3545;
    background: #f8d7da;
}

/* ==========================================================================
   Widget Body
   ========================================================================== */
.widget-body {
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

/* ==========================================================================
   Collapsed State
   ========================================================================== */
.widget-panel.collapsed .widget-body {
    max-height: 0 !important;
    padding: 0 !important;
    overflow: hidden;
}

.widget-panel.collapsed .widget-header {
    border-bottom: none;
    border-radius: 0.375rem;
}

.widget-panel.collapsed .widget-ctrl[data-action="collapse"] i {
    transform: rotate(180deg);
}

/* ==========================================================================
   Maximized State
   ========================================================================== */
.widget-panel.maximized {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1050;
    margin: 0;
    border-radius: 0;
    overflow-y: auto;
}

.widget-panel.maximized .widget-header {
    border-radius: 0;
    position: sticky;
    top: 0;
    z-index: 1;
}

/* Icon swap handled by JS: bi-arrows-fullscreen ↔ bi-fullscreen-exit */

body.widget-maximized {
    overflow: hidden;
}

/* ==========================================================================
   Hidden State
   ========================================================================== */
.widget-panel.widget-hidden {
    display: none !important;
}

/* ==========================================================================
   Hidden Widgets Bar
   ========================================================================== */
#hidden-widgets-bar .badge {
    cursor: pointer;
    font-size: 12px;
}

#hidden-widgets-bar .badge:hover {
    opacity: 0.8;
}

/* ==========================================================================
   Stat Tiles (no header, top-level widget)
   ========================================================================== */
.widget-panel[data-widget-id="stat-tiles"] {
    border: none;
    background: transparent;
}

.widget-panel-no-header .widget-refresh-indicator {
    position: absolute;
    top: 8px;
    right: 10px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid #dee2e6;
    border-radius: 999px;
    padding: 3px 8px;
    z-index: 2;
}

/* ==========================================================================
   Nav Tabs inside widget
   ========================================================================== */
.widget-body .nav-tabs {
    padding: 0 10px;
    border-bottom: 2px solid #dee2e6;
}

.widget-body .nav-tabs .nav-link {
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    color: #6c757d;
    border: none;
    padding: 8px 15px;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}

.widget-body .nav-tabs .nav-link:hover {
    color: #333;
    border-bottom-color: #adb5bd;
}

.widget-body .nav-tabs .nav-link.active {
    color: #0d6efd;
    border-bottom-color: #0d6efd;
    background: transparent;
}

/* ==========================================================================
   Candidate Results Widget
   ========================================================================== */
.candidate-results-widget .progress {
    border-radius: 3px;
    background-color: #e9ecef;
}

.candidate-results-widget .progress-bar {
    transition: width 0.6s ease;
    border-radius: 3px;
}

.candidate-results-widget .candidate-row {
    transition: opacity 0.2s;
}

.candidate-results-widget .leader-highlight {
    background: linear-gradient(135deg, #f7fbff, #f4f7ff);
}

.candidate-avatar-lg,
.candidate-avatar-fallback-lg {
    width: 56px;
    height: 56px;
    border-radius: 999px;
}

.candidate-avatar-sm,
.candidate-avatar-fallback-sm {
    width: 36px;
    height: 36px;
    border-radius: 999px;
}

.candidate-avatar-lg,
.candidate-avatar-sm {
    object-fit: cover;
    border: 1px solid #dee2e6;
}

.candidate-avatar-fallback-lg,
.candidate-avatar-fallback-sm {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #6c757d;
    color: #fff;
    font-weight: 700;
}

.latest-results-strip {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.latest-results-track {
    display: flex;
    gap: 1.25rem;
    min-width: max-content;
}

.latest-results-item {
    white-space: nowrap;
    font-size: 0.8rem;
}

/* ==========================================================================
   Fullscreen mode - hide stat tiles
   ========================================================================== */
.fullscreen .widget-panel[data-widget-id="stat-tiles"] {
    display: none;
}

@media (display-mode: fullscreen) {
    .widget-panel[data-widget-id="stat-tiles"] {
        display: none !important;
    }
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 991.98px) {
    .widget-panel.maximized {
        position: relative;
        z-index: auto;
    }
    body.widget-maximized {
        overflow: auto;
    }
}

/* ==========================================================================
   Print
   ========================================================================== */
@media print {
    .widget-controls {
        display: none !important;
    }
    .widget-header {
        cursor: default;
    }
    #hidden-widgets-bar {
        display: none !important;
    }
}
