/* ========================================
   DASHBOARD WIDGET STYLES
   Modern, clean widget cards for dashboard
   ======================================== */

/* Widget Card Container */
.widget-card {
    background: white;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.widget-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: #d1d5db;
}

/* Widget Header */
.widget-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.25rem;
}

.widget-title-section {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.widget-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0;
}

.widget-last-updated {
    font-size: 0.75rem;
    color: #9ca3af;
}

.widget-refresh-btn {
    background: transparent;
    border: 1px solid #e5e7eb;
    color: #6b7280;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.widget-refresh-btn:hover:not(:disabled) {
    background: #f3f4f6;
    border-color: #d1d5db;
    color: #374151;
}

.widget-refresh-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.widget-refresh-btn .spinning {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Widget Content */
.widget-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.widget-value-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.widget-value {
    font-size: 2rem;
    font-weight: 700;
    color: #111827;
    line-height: 1;
}

.widget-change {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.875rem;
    font-weight: 600;
}

.widget-change.positive {
    color: #10b981;
}

.widget-change.negative {
    color: #ef4444;
}

.widget-change-label {
    font-weight: 400;
    color: #6b7280;
    margin-left: 0.25rem;
}

.widget-margin {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

.widget-margin-label {
    color: #6b7280;
    font-weight: 400;
}

.widget-margin-value {
    color: #111827;
    font-weight: 600;
}

.widget-count {
    display: flex;
    align-items: baseline;
    gap: 0.375rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: #111827;
    margin-top: 0.5rem;
}

.widget-count-label {
    font-size: 0.875rem;
    font-weight: 400;
    color: #6b7280;
}

/* Sparkline Chart */
.widget-sparkline {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 60px;
    padding: 0.5rem 0;
}

.sparkline-bar {
    flex: 1;
    background: linear-gradient(180deg, #6366f1 0%, #4f46e5 100%);
    border-radius: 2px 2px 0 0;
    min-height: 2px;
    transition: all 0.2s;
    cursor: pointer;
}

.sparkline-bar:hover {
    background: linear-gradient(180deg, #818cf8 0%, #6366f1 100%);
    transform: scaleY(1.05);
}

/* Widget Actions */
.widget-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: auto;
}

.btn-widget-action {
    flex: 1;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: white;
    border: none;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.2);
    cursor: pointer;
}

.btn-widget-action:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(79, 70, 229, 0.3);
}

.btn-widget-action:active {
    transform: translateY(0);
}

/* Loading State */
.widget-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    color: #6b7280;
}

.widget-loading .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #6366f1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

.widget-loading p {
    margin: 0;
    font-size: 0.875rem;
}

/* Error State */
.widget-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    color: #ef4444;
}

.widget-error .bi {
    font-size: 2rem;
    margin-bottom: 0.75rem;
}

.widget-error p {
    margin: 0;
    font-size: 0.875rem;
    text-align: center;
}

/* Widgets Grid Layout */
.widgets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .widget-card {
        padding: 1rem;
    }

    .widget-value {
        font-size: 1.75rem;
    }

    .widgets-grid {
        grid-template-columns: 1fr;
    }

    .widget-sparkline {
        height: 50px;
    }
}

@media (min-width: 1024px) {
    .widgets-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}