/*
 * Beautiful Dashboard Widget Styles for Vitalis EHR
 * Modern, Professional, and Responsive Design
 */

/* ===== ROOT VARIABLES ===== */
:root {
    --vitalis-primary: #3b82f6;
    --vitalis-success: #10b981;
    --vitalis-warning: #f59e0b;
    --vitalis-danger: #ef4444;
    --vitalis-info: #06b6d4;
    --vitalis-purple: #8b5cf6;
    --vitalis-gradient-1: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --vitalis-gradient-2: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --vitalis-gradient-3: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --vitalis-gradient-4: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    --vitalis-shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --vitalis-shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --vitalis-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --vitalis-shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

/* ===== MAIN WIDGET CONTAINER STYLES ===== */
.fi-widget {
    border-radius: 1.25rem !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    backdrop-filter: blur(10px) !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    overflow: hidden !important;
    position: relative !important;
}

/* Hover effects for all widgets */
.fi-widget:hover {
    transform: translateY(-4px) scale(1.02) !important;
    box-shadow: var(--vitalis-shadow-xl) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
}

/* ===== STATS OVERVIEW WIDGET STYLES ===== */
.fi-wi-stats-overview {
    gap: 1.5rem !important;
}

.fi-wi-stats-overview .fi-wi-stats-overview-stat {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 50%, #f1f5f9 100%) !important;
    border-radius: 1rem !important;
    border: 1px solid rgba(148, 163, 184, 0.2) !important;
    box-shadow: var(--vitalis-shadow-md) !important;
    padding: 1.75rem !important;
    position: relative !important;
    overflow: hidden !important;
    transition: all 0.3s ease !important;
}

/* Dark mode stats */
.dark .fi-wi-stats-overview .fi-wi-stats-overview-stat {
    background: linear-gradient(135deg, #1e293b 0%, #334155 50%, #475569 100%) !important;
    border-color: rgba(148, 163, 184, 0.1) !important;
    color: #f1f5f9 !important;
}

/* Add subtle gradient overlay */
.fi-wi-stats-overview .fi-wi-stats-overview-stat::before {
    content: '' !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 4px !important;
    background: var(--vitalis-gradient-1) !important;
    z-index: 1 !important;
}

/* Individual stat color themes */
.fi-wi-stats-overview .fi-wi-stats-overview-stat:nth-child(1)::before {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8) !important;
}

.fi-wi-stats-overview .fi-wi-stats-overview-stat:nth-child(2)::before {
    background: linear-gradient(135deg, #10b981, #059669) !important;
}

.fi-wi-stats-overview .fi-wi-stats-overview-stat:nth-child(3)::before {
    background: linear-gradient(135deg, #06b6d4, #0891b2) !important;
}

.fi-wi-stats-overview .fi-wi-stats-overview-stat:nth-child(4)::before {
    background: linear-gradient(135deg, #f59e0b, #d97706) !important;
}

/* Stat value styling */
.fi-wi-stats-overview-stat-value {
    font-size: 2.5rem !important;
    font-weight: 800 !important;
    background: linear-gradient(135deg, #1e293b, #475569) !important;
    background-clip: text !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    margin-bottom: 0.5rem !important;
}

.dark .fi-wi-stats-overview-stat-value {
    background: linear-gradient(135deg, #f1f5f9, #cbd5e1) !important;
    background-clip: text !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
}

/* Stat label styling */
.fi-wi-stats-overview-stat-label {
    font-size: 0.95rem !important;
    font-weight: 600 !important;
    color: #64748b !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    margin-bottom: 1rem !important;
}

.dark .fi-wi-stats-overview-stat-label {
    color: #94a3b8 !important;
}

/* Stat description styling */
.fi-wi-stats-overview-stat-description {
    font-size: 0.875rem !important;
    font-weight: 500 !important;
    color: #64748b !important;
    display: flex !important;
    align-items: center !important;
    gap: 0.5rem !important;
    margin-top: 1rem !important;
}

.dark .fi-wi-stats-overview-stat-description {
    color: #94a3b8 !important;
}

/* Icon styling in descriptions */
.fi-wi-stats-overview-stat-description .fi-icon {
    width: 1.125rem !important;
    height: 1.125rem !important;
    flex-shrink: 0 !important;
}

/* Chart styling within stats */
.fi-wi-stats-overview-stat-chart {
    height: 80px !important;
    margin-top: 1.25rem !important;
    opacity: 0.8 !important;
    border-radius: 0.5rem !important;
    overflow: hidden !important;
}

/* ===== HOVER ANIMATIONS FOR STATS ===== */
.fi-wi-stats-overview .fi-wi-stats-overview-stat:hover {
    transform: translateY(-3px) !important;
    box-shadow: var(--vitalis-shadow-lg) !important;
    border-color: rgba(148, 163, 184, 0.3) !important;
}

.fi-wi-stats-overview .fi-wi-stats-overview-stat:hover .fi-wi-stats-overview-stat-value {
    transform: scale(1.05) !important;
    transition: transform 0.2s ease !important;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .fi-wi-stats-overview {
        gap: 1rem !important;
    }
    
    .fi-wi-stats-overview .fi-wi-stats-overview-stat {
        padding: 1.25rem !important;
    }
    
    .fi-wi-stats-overview-stat-value {
        font-size: 2rem !important;
    }
}

@media (max-width: 640px) {
    .fi-wi-stats-overview-stat-value {
        font-size: 1.75rem !important;
    }
    
    .fi-wi-stats-overview .fi-wi-stats-overview-stat {
        padding: 1rem !important;
    }
}

/* ===== TABLE WIDGET STYLES ===== */
.fi-wi-table {
    border-radius: 1.25rem !important;
    overflow: hidden !important;
}

.fi-wi-table > .fi-section {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%) !important;
    border-radius: 1.25rem !important;
    border: 1px solid rgba(148, 163, 184, 0.15) !important;
    box-shadow: var(--vitalis-shadow-md) !important;
    transition: all 0.3s ease !important;
}

.dark .fi-wi-table > .fi-section {
    background: linear-gradient(135deg, #1e293b 0%, #2d3748 100%) !important;
    border-color: rgba(148, 163, 184, 0.1) !important;
}

/* Table header styling */
.fi-wi-table .fi-section-header {
    padding: 1.5rem 1.5rem 1rem 1.5rem !important;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1) !important;
    background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%) !important;
}

.dark .fi-wi-table .fi-section-header {
    background: linear-gradient(135deg, #374151 0%, #4b5563 100%) !important;
    border-bottom-color: rgba(148, 163, 184, 0.1) !important;
}

.fi-wi-table .fi-section-header-heading {
    font-size: 1.25rem !important;
    font-weight: 700 !important;
    background: linear-gradient(135deg, #1e293b, #475569) !important;
    background-clip: text !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
}

.dark .fi-wi-table .fi-section-header-heading {
    background: linear-gradient(135deg, #f1f5f9, #e2e8f0) !important;
    background-clip: text !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
}

/* Table content */
.fi-wi-table .fi-ta {
    border-radius: 0 0 1.25rem 1.25rem !important;
    overflow: hidden !important;
}

/* Table rows */
.fi-wi-table .fi-ta-row {
    transition: all 0.2s ease !important;
    border-bottom: 1px solid rgba(148, 163, 184, 0.08) !important;
}

.fi-wi-table .fi-ta-row:hover {
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%) !important;
    transform: translateX(4px) !important;
}

.dark .fi-wi-table .fi-ta-row:hover {
    background: linear-gradient(135deg, #374151 0%, #4b5563 100%) !important;
}

/* Table cells */
.fi-wi-table .fi-ta-cell {
    padding: 1rem 1.5rem !important;
    font-weight: 500 !important;
    color: #475569 !important;
}

.dark .fi-wi-table .fi-ta-cell {
    color: #cbd5e1 !important;
}

/* Table header actions */
.fi-wi-table .fi-section-header-actions .fi-btn {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8) !important;
    border: none !important;
    border-radius: 0.75rem !important;
    padding: 0.75rem 1.5rem !important;
    font-weight: 600 !important;
    color: white !important;
    box-shadow: var(--vitalis-shadow-sm) !important;
    transition: all 0.2s ease !important;
}

.fi-wi-table .fi-section-header-actions .fi-btn:hover {
    transform: translateY(-2px) !important;
    box-shadow: var(--vitalis-shadow-md) !important;
    background: linear-gradient(135deg, #2563eb, #1e40af) !important;
}

/* Badge styling in tables */
.fi-wi-table .fi-badge {
    font-weight: 600 !important;
    font-size: 0.75rem !important;
    padding: 0.375rem 0.875rem !important;
    border-radius: 0.5rem !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
}

/* ===== CHART WIDGET STYLES ===== */
.fi-wi-chart {
    border-radius: 1.25rem !important;
    overflow: hidden !important;
}

.fi-wi-chart > .fi-section {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%) !important;
    border-radius: 1.25rem !important;
    border: 1px solid rgba(148, 163, 184, 0.15) !important;
    box-shadow: var(--vitalis-shadow-md) !important;
    transition: all 0.3s ease !important;
    position: relative !important;
    overflow: hidden !important;
}

.dark .fi-wi-chart > .fi-section {
    background: linear-gradient(135deg, #1e293b 0%, #2d3748 100%) !important;
    border-color: rgba(148, 163, 184, 0.1) !important;
}

/* Add decorative top border for charts */
.fi-wi-chart > .fi-section::before {
    content: '' !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 4px !important;
    background: linear-gradient(135deg, #06b6d4, #0891b2) !important;
    z-index: 1 !important;
}

/* Chart header styling */
.fi-wi-chart .fi-section-header {
    padding: 1.5rem 1.5rem 1rem 1.5rem !important;
    background: transparent !important;
    position: relative !important;
    z-index: 2 !important;
}

.fi-wi-chart .fi-section-header-heading {
    font-size: 1.25rem !important;
    font-weight: 700 !important;
    background: linear-gradient(135deg, #1e293b, #475569) !important;
    background-clip: text !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
}

.dark .fi-wi-chart .fi-section-header-heading {
    background: linear-gradient(135deg, #f1f5f9, #e2e8f0) !important;
    background-clip: text !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
}

/* Chart content area */
.fi-wi-chart .fi-section-content {
    padding: 1rem 1.5rem 1.5rem 1.5rem !important;
    position: relative !important;
    z-index: 2 !important;
}

/* Chart canvas styling */
.fi-wi-chart canvas {
    border-radius: 0.75rem !important;
    background: rgba(255, 255, 255, 0.5) !important;
    backdrop-filter: blur(10px) !important;
}

.dark .fi-wi-chart canvas {
    background: rgba(0, 0, 0, 0.2) !important;
}

/* Different chart types get different accent colors */
.fi-wi-chart[data-chart-type="line"] > .fi-section::before {
    background: linear-gradient(135deg, #10b981, #059669) !important;
}

.fi-wi-chart[data-chart-type="doughnut"] > .fi-section::before,
.fi-wi-chart[data-chart-type="pie"] > .fi-section::before {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed) !important;
}

.fi-wi-chart[data-chart-type="bar"] > .fi-section::before {
    background: linear-gradient(135deg, #f59e0b, #d97706) !important;
}

/* ===== APPOINTMENT STATS WIDGET SPECIFIC STYLES ===== */
/* Target the AppointmentStatsWidget specifically */
.fi-wi-stats-overview.appointment-stats .fi-wi-stats-overview-stat:nth-child(1)::before {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8) !important;
}

.fi-wi-stats-overview.appointment-stats .fi-wi-stats-overview-stat:nth-child(2)::before {
    background: linear-gradient(135deg, #f59e0b, #d97706) !important;
}

.fi-wi-stats-overview.appointment-stats .fi-wi-stats-overview-stat:nth-child(3)::before {
    background: linear-gradient(135deg, #ef4444, #dc2626) !important;
}

.fi-wi-stats-overview.appointment-stats .fi-wi-stats-overview-stat:nth-child(4)::before {
    background: linear-gradient(135deg, #10b981, #059669) !important;
}

/* ===== HOVER EFFECTS FOR ALL WIDGETS ===== */
.fi-wi-table:hover > .fi-section {
    transform: translateY(-2px) !important;
    box-shadow: var(--vitalis-shadow-lg) !important;
    border-color: rgba(148, 163, 184, 0.25) !important;
}

.fi-wi-chart:hover > .fi-section {
    transform: translateY(-2px) !important;
    box-shadow: var(--vitalis-shadow-lg) !important;
    border-color: rgba(148, 163, 184, 0.25) !important;
}

/* ===== EMPTY STATES ===== */
.fi-wi-table .fi-ta-empty {
    padding: 3rem 1.5rem !important;
    text-align: center !important;
    color: #64748b !important;
}

.dark .fi-wi-table .fi-ta-empty {
    color: #94a3b8 !important;
}

.fi-wi-table .fi-ta-empty::before {
    content: '📅' !important;
    font-size: 3rem !important;
    display: block !important;
    margin-bottom: 1rem !important;
    opacity: 0.3 !important;
}

/* ===== LOADING STATES ===== */
.fi-widget[data-loading] {
    opacity: 0.7 !important;
    pointer-events: none !important;
}

.fi-widget[data-loading]::after {
    content: '' !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: rgba(255, 255, 255, 0.8) !important;
    backdrop-filter: blur(2px) !important;
    z-index: 10 !important;
}

/* ===== ACCESSIBILITY IMPROVEMENTS ===== */
.fi-widget:focus-within {
    outline: 2px solid var(--vitalis-primary) !important;
    outline-offset: 2px !important;
}

@media (prefers-reduced-motion: reduce) {
    .fi-widget,
    .fi-wi-stats-overview .fi-wi-stats-overview-stat {
        transition: none !important;
    }
    
    .fi-widget:hover {
        transform: none !important;
    }
}

/* ===== CUSTOM ANIMATIONS ===== */
@keyframes vitalisSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fi-wi-stats-overview .fi-wi-stats-overview-stat {
    animation: vitalisSlideUp 0.6s ease-out !important;
}

.fi-wi-stats-overview .fi-wi-stats-overview-stat:nth-child(2) {
    animation-delay: 0.1s !important;
}

.fi-wi-stats-overview .fi-wi-stats-overview-stat:nth-child(3) {
    animation-delay: 0.2s !important;
}

.fi-wi-stats-overview .fi-wi-stats-overview-stat:nth-child(4) {
    animation-delay: 0.3s !important;
}

/* ===== WIDGET LAYOUT AND GRID ===== */
/* Dashboard grid improvements */
.fi-dashboard-widgets {
    gap: 1.5rem !important;
}

/* Full-width widgets (tables) */
.fi-widget[data-column-span="full"] {
    grid-column: 1 / -1 !important;
}

/* ===== SPECIFIC WIDGET TARGETING ===== */
/* Target specific widgets by their heading content */
.fi-section-header-heading:contains("Today's Appointments") {
    color: #3b82f6 !important;
}

.fi-section-header-heading:contains("Today's Consultations") {
    color: #10b981 !important;
}

.fi-section-header-heading:contains("Patient Distribution") {
    color: #8b5cf6 !important;
}

.fi-section-header-heading:contains("Consultations - Last 7 Days") {
    color: #06b6d4 !important;
}

/* ===== ENHANCED BUTTON STYLES ===== */
.fi-btn-primary {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8) !important;
    border: none !important;
    border-radius: 0.75rem !important;
    font-weight: 600 !important;
    box-shadow: var(--vitalis-shadow-sm) !important;
    transition: all 0.2s ease !important;
}

.fi-btn-primary:hover {
    transform: translateY(-1px) !important;
    box-shadow: var(--vitalis-shadow-md) !important;
    background: linear-gradient(135deg, #2563eb, #1e40af) !important;
}

/* ===== TABLE BADGE COLORS ===== */
.fi-badge[data-color="primary"] {
    background: linear-gradient(135deg, #dbeafe, #bfdbfe) !important;
    color: #1d4ed8 !important;
    border: 1px solid rgba(59, 130, 246, 0.2) !important;
}

.fi-badge[data-color="success"] {
    background: linear-gradient(135deg, #d1fae5, #a7f3d0) !important;
    color: #047857 !important;
    border: 1px solid rgba(16, 185, 129, 0.2) !important;
}

.fi-badge[data-color="warning"] {
    background: linear-gradient(135deg, #fef3c7, #fde68a) !important;
    color: #92400e !important;
    border: 1px solid rgba(245, 158, 11, 0.2) !important;
}

.fi-badge[data-color="danger"] {
    background: linear-gradient(135deg, #fee2e2, #fecaca) !important;
    color: #dc2626 !important;
    border: 1px solid rgba(239, 68, 68, 0.2) !important;
}

/* Dark mode badge adjustments */
.dark .fi-badge[data-color="primary"] {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(29, 78, 216, 0.3)) !important;
    color: #60a5fa !important;
}

.dark .fi-badge[data-color="success"] {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(5, 150, 105, 0.3)) !important;
    color: #34d399 !important;
}

.dark .fi-badge[data-color="warning"] {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(217, 119, 6, 0.3)) !important;
    color: #fbbf24 !important;
}

.dark .fi-badge[data-color="danger"] {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(220, 38, 38, 0.3)) !important;
    color: #f87171 !important;
}

/* ===== LOADING AND SKELETON STATES ===== */
.fi-widget[data-loading="true"] {
    position: relative !important;
    opacity: 0.8 !important;
}

.fi-widget[data-loading="true"]::after {
    content: '' !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent) !important;
    animation: vitalisShimmer 1.5s ease-in-out infinite !important;
    z-index: 10 !important;
}

@keyframes vitalisShimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ===== CHART LEGEND STYLING ===== */
.fi-wi-chart .chartjs-tooltip {
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(10px) !important;
    border: 1px solid rgba(148, 163, 184, 0.2) !important;
    border-radius: 0.5rem !important;
    box-shadow: var(--vitalis-shadow-md) !important;
}

.dark .fi-wi-chart .chartjs-tooltip {
    background: rgba(30, 41, 59, 0.95) !important;
    border-color: rgba(148, 163, 184, 0.1) !important;
    color: #f1f5f9 !important;
}

/* ===== RESPONSIVE IMPROVEMENTS ===== */
@media (max-width: 1024px) {
    .fi-dashboard-widgets {
        gap: 1rem !important;
    }
    
    .fi-wi-table .fi-ta-cell,
    .fi-wi-chart .fi-section-content {
        padding: 0.75rem !important;
    }
}

@media (max-width: 640px) {
    .fi-wi-table .fi-section-header,
    .fi-wi-chart .fi-section-header {
        padding: 1rem !important;
    }
    
    .fi-wi-table .fi-section-header-heading,
    .fi-wi-chart .fi-section-header-heading {
        font-size: 1.1rem !important;
    }
    
    .fi-wi-table .fi-ta-cell {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.875rem !important;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .fi-widget {
        break-inside: avoid !important;
        box-shadow: none !important;
        border: 1px solid #e2e8f0 !important;
    }
    
    .fi-wi-stats-overview .fi-wi-stats-overview-stat,
    .fi-wi-table > .fi-section,
    .fi-wi-chart > .fi-section {
        background: white !important;
        transform: none !important;
    }
}

/* ===== FOCUS ACCESSIBILITY ===== */
.fi-widget:focus-within {
    outline: 3px solid rgba(59, 130, 246, 0.3) !important;
    outline-offset: 2px !important;
}

.fi-wi-table .fi-ta-row:focus-within {
    background: linear-gradient(135deg, #eff6ff, #dbeafe) !important;
    outline: 2px solid rgba(59, 130, 246, 0.5) !important;
    outline-offset: -2px !important;
}

/* ===== HIGH CONTRAST MODE SUPPORT ===== */
@media (prefers-contrast: high) {
    .fi-widget {
        border-width: 2px !important;
        border-color: #000 !important;
    }
    
    .fi-wi-stats-overview-stat-value {
        color: #000 !important;
        -webkit-text-fill-color: #000 !important;
    }
    
    .dark .fi-wi-stats-overview-stat-value {
        color: #fff !important;
        -webkit-text-fill-color: #fff !important;
    }
}