/* ============================================
   DASHBOARD WIDGETS CSS FRAMEWORK
   Apple-Style Widget-System
   ============================================ */

/* === BASE WIDGET CONTAINER === */
.dashboard-widget {
    background: var(--bs-body-bg);
    border-radius: 22px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06),
                0 0 1px rgba(0, 0, 0, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    height: 100%;
    min-height: 400px;
    display: flex;
    flex-direction: column;
    border: 0.5px solid rgba(0, 0, 0, 0.04);
}

.dashboard-widget:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12),
                0 0 1px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

[data-bs-theme="dark"] .dashboard-widget {
    background: rgba(28, 28, 30, 0.95);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3),
                0 0 1px rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.06);
}

[data-bs-theme="dark"] .dashboard-widget:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5),
                0 0 1px rgba(255, 255, 255, 0.1);
    background: rgba(32, 32, 34, 0.95);
}

/* === WIDGET HEADER === */
.widget-header {
    padding: 1.25rem 1.5rem 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.widget-header-title {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--bs-body-color);
    margin: 0;
}

.widget-header-icon {
    font-size: 1.25rem;
    color: var(--bs-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.9;
}

.widget-header-actions {
    display: flex;
    gap: 0.375rem;
    align-items: center;
}

.widget-action-btn {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.04);
    border: none;
    color: var(--bs-body-color);
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
}

.widget-action-btn:hover {
    background: rgba(0, 0, 0, 0.08);
    transform: scale(1.05);
}

[data-bs-theme="dark"] .widget-action-btn {
    background: rgba(255, 255, 255, 0.08);
}

[data-bs-theme="dark"] .widget-action-btn:hover {
    background: rgba(255, 255, 255, 0.14);
}

.widget-action-btn:active {
    transform: scale(0.95);
}

/* === WIDGET BODY === */
.widget-body {
    padding: 0 1.5rem 1.5rem 1.5rem;
    flex: 1;
    overflow: auto;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Important for flex scrolling */
}

/* Widget Body mit fixer Höhe und Scroll */
.widget-body-scrollable {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    max-height: none;
}

/* Scrollbar Styling für Widget Body */
.widget-body::-webkit-scrollbar {
    width: 6px;
}

.widget-body::-webkit-scrollbar-track {
    background: transparent;
}

.widget-body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 3px;
}

.widget-body::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

[data-bs-theme="dark"] .widget-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
}

[data-bs-theme="dark"] .widget-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* === WIDGET STATISTICS === */
.widget-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.widget-stat {
    background: rgba(0, 0, 0, 0.03);
    border-radius: 14px;
    padding: 1rem 0.875rem;
    text-align: center;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
}

[data-bs-theme="dark"] .widget-stat {
    background: rgba(255, 255, 255, 0.06);
}

.widget-stat:hover {
    transform: scale(1.02);
    background: rgba(0, 0, 0, 0.05);
}

[data-bs-theme="dark"] .widget-stat:hover {
    background: rgba(255, 255, 255, 0.09);
}

.widget-stat-value {
    font-size: 1.875rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.375rem;
    color: var(--bs-body-color);
    display: block;
    letter-spacing: -0.02em;
}

.widget-stat-label {
    font-size: 0.75rem;
    color: var(--bs-secondary);
    text-transform: none;
    letter-spacing: 0;
    font-weight: 500;
    line-height: 1.2;
}

.widget-stat-icon {
    font-size: 1rem;
    margin-bottom: 0.375rem;
    opacity: 0.6;
}

/* Color variants - solid backgrounds */
.widget-stat.stat-primary {
    background: rgba(13, 110, 253, 0.1);
}
.widget-stat.stat-success {
    background: rgba(25, 135, 84, 0.1);
}
.widget-stat.stat-danger {
    background: rgba(220, 53, 69, 0.1);
}
.widget-stat.stat-warning {
    background: rgba(255, 193, 7, 0.1);
}
.widget-stat.stat-info {
    background: rgba(13, 202, 240, 0.1);
}
.widget-stat.stat-secondary {
    background: rgba(108, 117, 125, 0.1);
}

[data-bs-theme="dark"] .widget-stat.stat-primary {
    background: rgba(13, 110, 253, 0.15);
}
[data-bs-theme="dark"] .widget-stat.stat-success {
    background: rgba(25, 135, 84, 0.15);
}
[data-bs-theme="dark"] .widget-stat.stat-danger {
    background: rgba(220, 53, 69, 0.15);
}
[data-bs-theme="dark"] .widget-stat.stat-warning {
    background: rgba(255, 193, 7, 0.15);
}
[data-bs-theme="dark"] .widget-stat.stat-info {
    background: rgba(13, 202, 240, 0.15);
}
[data-bs-theme="dark"] .widget-stat.stat-secondary {
    background: rgba(108, 117, 125, 0.15);
}

/* === WIDGET CHART CONTAINER === */
.widget-chart {
    padding: 1rem;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 14px;
    margin-bottom: 1rem;
}

[data-bs-theme="dark"] .widget-chart {
    background: rgba(255, 255, 255, 0.04);
}

.widget-chart-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--bs-secondary);
    margin-bottom: 0.875rem;
    text-transform: none;
    letter-spacing: 0;
}

/* === PROGRESS BARS === */
.widget-progress {
    margin-bottom: 1rem;
}

.widget-progress-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.8125rem;
    color: var(--bs-secondary);
    font-weight: 500;
}

.widget-progress-bar {
    height: 6px;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 3px;
    overflow: hidden;
}

[data-bs-theme="dark"] .widget-progress-bar {
    background: rgba(255, 255, 255, 0.1);
}

.widget-progress-fill {
    height: 100%;
    background: var(--bs-primary);
    border-radius: 3px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* === WIDGET LIST === */
.widget-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.widget-list-item {
    padding: 0.75rem;
    border-radius: 12px;
    margin-bottom: 0.5rem;
    background: rgba(0, 0, 0, 0.02);
    transition: all 0.2s ease;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

[data-bs-theme="dark"] .widget-list-item {
    background: rgba(255, 255, 255, 0.04);
}

.widget-list-item:hover {
    background: rgba(0, 0, 0, 0.04);
    transform: translateX(2px);
}

[data-bs-theme="dark"] .widget-list-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.widget-list-item:last-child {
    margin-bottom: 0;
}

.widget-list-item-icon {
    font-size: 1.125rem;
    opacity: 0.7;
}

.widget-list-item-content {
    flex: 1;
}

.widget-list-item-title {
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.125rem;
}

.widget-list-item-subtitle {
    font-size: 0.75rem;
    opacity: 0.7;
}

/* === SKELETON LOADER === */
.widget-skeleton {
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}

@keyframes skeleton-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.skeleton-header {
    height: 20px;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 6px;
    margin-bottom: 1rem;
    width: 60%;
}

[data-bs-theme="dark"] .skeleton-header {
    background: rgba(255, 255, 255, 0.1);
}

.skeleton-text {
    height: 14px;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 4px;
    margin-bottom: 0.625rem;
}

[data-bs-theme="dark"] .skeleton-text {
    background: rgba(255, 255, 255, 0.07);
}

.skeleton-text:last-child {
    width: 80%;
}

.skeleton-stat {
    height: 80px;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 14px;
}

[data-bs-theme="dark"] .skeleton-stat {
    background: rgba(255, 255, 255, 0.05);
}

/* === WIDGET EMPTY STATE === */
.widget-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1rem;
    text-align: center;
    color: var(--bs-secondary);
}

.widget-empty-icon {
    font-size: 3.5rem;
    opacity: 0.25;
    margin-bottom: 0.875rem;
}

.widget-empty-text {
    font-size: 0.9375rem;
    margin-bottom: 1rem;
}

/* === WIDGET ERROR STATE === */
.widget-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    text-align: center;
    color: var(--bs-danger);
}

.widget-error-icon {
    font-size: 2.5rem;
    margin-bottom: 0.875rem;
    opacity: 0.8;
}

.widget-error-text {
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

/* === WIDGET BADGE === */
.widget-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    font-size: 0.6875rem;
    font-weight: 600;
    border-radius: 8px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.widget-badge-success {
    background: rgba(25, 135, 84, 0.1);
    color: var(--bs-success);
}

.widget-badge-danger {
    background: rgba(220, 53, 69, 0.1);
    color: var(--bs-danger);
}

.widget-badge-warning {
    background: rgba(255, 193, 7, 0.1);
    color: var(--bs-warning);
}

.widget-badge-info {
    background: rgba(13, 202, 240, 0.1);
    color: var(--bs-info);
}

/* === ANIMATED COUNTER === */
.widget-counter {
    font-variant-numeric: tabular-nums;
}

/* Value Update Animation */
.value-updating {
    animation: value-pulse 0.3s ease-in-out;
}

@keyframes value-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* === PULSE ANIMATION === */
.widget-pulse {
    animation: widget-pulse 2s ease-in-out infinite;
}

@keyframes widget-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* === WIDGET FOOTER === */
.widget-footer {
    padding: 0.875rem 1.5rem 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8125rem;
    border-top: 1px solid rgba(0, 0, 0, 0.04);
    margin-top: auto;
}

[data-bs-theme="dark"] .widget-footer {
    border-top-color: rgba(255, 255, 255, 0.06);
}

.widget-footer-link {
    color: var(--bs-primary);
    text-decoration: none;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    transition: all 0.2s ease;
    font-size: 0.8125rem;
}

.widget-footer-link:hover {
    color: var(--bs-primary);
    text-decoration: none;
    transform: translateX(2px);
}

.widget-footer-link i {
    font-size: 0.75rem;
}

/* === CLICKABLE WIDGET === */
.widget-clickable {
    cursor: pointer;
    transition: all 0.3s ease;
}

.widget-clickable:active {
    transform: translateY(-1px) scale(0.99);
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .dashboard-widget {
        border-radius: 18px;
    }

    .widget-header {
        padding: 1rem 1.25rem 0.875rem 1.25rem;
    }

    .widget-body {
        padding: 0 1.25rem 1.25rem 1.25rem;
    }

    .widget-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.625rem;
    }

    .widget-stat {
        padding: 0.875rem 0.75rem;
    }

    .widget-stat-value {
        font-size: 1.625rem;
    }

    .widget-footer {
        padding: 0.75rem 1.25rem 1rem 1.25rem;
        flex-direction: row;
        gap: 0.5rem;
    }
}

/* === LOADING OVERLAY === */
.widget-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.widget-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 32px;
    height: 32px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--bs-primary);
    border-radius: 50%;
    animation: widget-spin 0.6s linear infinite;
}

@keyframes widget-spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* === MICRO ANIMATIONS === */
.widget-fade-in {
    animation: widget-fade-in 0.4s ease-out;
}

@keyframes widget-fade-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.widget-scale-in {
    animation: widget-scale-in 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes widget-scale-in {
    from {
        opacity: 0;
        transform: scale(0.96);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* === SF PRO DISPLAY INSPIRED === */
.widget-header-title,
.widget-stat-value {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* === SUBTLE DIVIDERS === */
.widget-divider {
    height: 1px;
    background: rgba(0, 0, 0, 0.06);
    margin: 1rem 0;
}

[data-bs-theme="dark"] .widget-divider {
    background: rgba(255, 255, 255, 0.08);
}