/* ============================================
   MAIN STYLESHEET
   Imports base styles and defines widget components
   ============================================ */

@import 'base.css';

/* ============================================
   STAT CARD WIDGET
   Small metric display with icon, value, and optional chart
   Uses container queries to adapt layout
   ============================================ */

.stat-card {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;

    .stat-card-header {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
        text-align: center;
    }

    .stat-card-icon {
        width: clamp(36px, 8cqi, 48px);
        height: clamp(36px, 8cqi, 48px);
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: clamp(1.25rem, 3cqi + 0.5rem, 1.75rem);
        flex-shrink: 0;

        &.blue {
            background: rgba(59, 130, 246, 0.1);
            color: #3b82f6;
        }

        &.green {
            background: rgba(34, 197, 94, 0.1);
            color: #22c55e;
        }

        &.purple {
            background: rgba(168, 85, 247, 0.1);
            color: #a855f7;
        }

        &.orange {
            background: rgba(249, 115, 22, 0.1);
            color: #f97316;
        }
    }

    .stat-card-title {
        font-size: 0.875rem;
        color: #94a3b8;
        font-weight: 500;
    }

    .stat-card-content {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .stat-card-value {
        font-size: clamp(1.5rem, 4cqi + 1rem, 2.5rem);
        font-weight: 700;
        color: #f1f5f9;
    }

    .stat-card-change {
        font-size: clamp(0.75rem, 2cqi + 0.5rem, 1rem);
        display: flex;
        align-items: center;
        gap: 0.25rem;

        &.positive {
            color: #22c55e;
        }

        &.negative {
            color: #ef4444;
        }
    }

    .stat-card-chart {
        display: none;
        width: 100%;
        height: 60px;
        margin-top: 0.5rem;
    }
}

@container (min-width: 200px) {
    .widget-container {
        .stat-card {
            .stat-card-header {
                flex-direction: row;
                text-align: left;
            }
        }
    }
}

@container (min-width: 250px) {
    .stat-card {
        flex-direction: row;
        justify-content: space-between;

        .stat-card-content {
            flex: 1;
            text-align: right;
        }

        .stat-card-change {
            justify-content: flex-end;
        }
    }
}

@container (min-width: 350px) {
    .stat-card .stat-card-chart {
        display: block;
        width: 80px;
        flex-shrink: 0;
    }
}

/* ============================================
   REVENUE CHART WIDGET
   Bar chart with header stats
   ============================================ */

.revenue-chart {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;

    .revenue-chart-header {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .revenue-chart-title {
        font-size: 1.125rem;
        font-weight: 600;
        color: #f1f5f9;
    }

    .revenue-chart-stats {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

    .revenue-stat {
        display: flex;
        align-items: baseline;
        gap: 0.5rem;
    }

    .revenue-stat-label {
        font-size: 0.75rem;
        color: #94a3b8;
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }

    .revenue-stat-value {
        font-size: clamp(1.25rem, 3cqi + 0.75rem, 2rem);
        font-weight: 700;
        color: #f1f5f9;
    }

    .revenue-chart-visual {
        width: 100%;
        font-size: clamp(180px, 30cqi, 300px);
        height: 200px;
        background: linear-gradient(180deg, rgba(59, 130, 246, 0.1) 0%, transparent 100%);
        border-radius: 8px;
        display: flex;
        align-items: flex-end;
        padding: 1rem;
        gap: clamp(0.25rem, 1cqi, 0.75rem);
        gap: 0.5rem;
    }

    .revenue-bar {
        flex: 1;
        background: linear-gradient(180deg, #3b82f6 0%, #1e40af 100%);
        border-radius: 4px;
        min-height: 40px;
    }
}

@container (min-width: 450px) {
    .revenue-chart {
        .revenue-chart-header {
            align-items: center;
            justify-content: space-between;
            text-align: flex-end;
            flex-direction: row;
        }

        .revenue-chart-stats {
            flex-direction: row;
            gap: 2rem;
        }
    }
}

/* ============================================
   TOP PRODUCTS WIDGET
   Product list with images and stats
   ============================================ */

.top-products {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;

    .top-products-header {
        font-size: 1.125rem;
        font-weight: 600;
        color: #f1f5f9;
    }

    .product-list {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }

    .product-item {
        display: grid;
        grid-template-columns: 60px 1fr auto auto;
        gap: 0.75rem;
        align-items: center;
        padding: 1rem;
        background: #0f172a;
        border-radius: 8px;
        border: 1px solid #334155;
    }

    .product-image {
        width: 60px;
        height: 60px;
        border-radius: 8px;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.5rem;
    }

    .product-info {
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
        min-width: 0;
    }

    .product-name {
        font-weight: 600;
        color: #f1f5f9;
        font-size: clamp(0.75rem, 2cqi + 0.5rem, 1rem);
    }

    .product-category {
        color: #64748b;
        font-size: clamp(0.7rem, 1.5cqi + 0.4rem, 0.875rem);
    }

    .product-stat {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.25rem;
    }

    .product-stat-label {
        font-size: clamp(0.75rem, 2cqi + 0.5rem, 1rem);
        font-weight: 600;
        color: #f1f5f9;
    }

    .product-stat-value {
        font-size: clamp(0.7rem, 1.5cqi + 0.4rem, 0.875rem);
        color: #64748b;
    }
}

@container (max-width: 400px) {
    .product-item {
        grid-template-columns: 60px 1fr;
        grid-template-rows: auto auto;   
    }

    .product-info {
        grid-column: 2;
        grid-row: 1;
    }

    .product-stat:first-of-type {
        grid-column: 1;
        grid-row: 2;
    }

    .product-stat:last-of-type {
        grid-column: 2;
        grid-row: 2;
    }
}

@container (min-width: 500px) {
    .product-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
    }
}

@container (min-width: 800px) {
    .product-list {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ============================================
   USER ACTIVITY WIDGET
   Recent user actions with avatars
   ============================================ */

.user-activity {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;

    .user-activity-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .user-activity-title {
        font-size: 1.125rem;
        font-weight: 600;
        color: #f1f5f9;
    }

    .user-activity-filter {
        padding: 0.5rem 1rem;
        background: #0f172a;
        border: 1px solid #334155;
        border-radius: 6px;
        color: #94a3b8;
        font-size: 0.875rem;
        cursor: pointer;
    }

    .user-activity-list {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }

    .activity-item {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
        padding: 1rem;
        background: #0f172a;
        border-radius: 8px;
        border: 1px solid #334155;
    }

    .activity-item-row {
        display: flex;
        gap: 0.75rem;
        align-items: flex-start;
    }

    .activity-avatar {
        width: 40px;
        height: 40px;
        border-radius: 50%;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        color: white;
        font-weight: 600;
    }

    .activity-content {
        flex: 1;
        min-width: 0;
    }

    .activity-name {
        font-weight: 600;
        color: #f1f5f9;
        font-size: 0.875rem;
    }

    .activity-action {
        color: #94a3b8;
        font-size: 0.875rem;
    }

    .activity-time {
        color: #64748b;
        font-size: 0.75rem;
        margin-top: 0.25rem;
        display: block;
    }

    .activity-meta {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .activity-badge {
        padding: 0.25rem 0.75rem;
        background: rgba(59, 130, 246, 0.1);
        color: #3b82f6;
        border-radius: 12px;
        font-size: 0.75rem;
        font-weight: 500;
    }
}

@container (min-width: 400px) {
    .user-activity .activity-item {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .activity-item-row {
        flex: 1;
    }

    .activity-meta {
        flex-shrink: 0;
    }
}

/* ============================================
   PERFORMANCE METRICS WIDGET
   Grid of metric cards with progress bars
   ============================================ */

.performance-metrics {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;

    .performance-header {
        font-size: 1.125rem;
        font-weight: 600;
        color: #f1f5f9;
    }

    .metrics-grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .metric-card {
        padding: 1rem;
        background: #0f172a;
        border-radius: 8px;
        border: 1px solid #334155;
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .metric-label {
        font-size: clamp(0.75rem, 1.5cqi + 0.5rem, 0.95rem);
        color: #94a3b8;
    }

    .metric-value {
        font-size: clamp(1.25rem, 3cqi + 0.75rem, 2rem);
        font-weight: 700;
        color: #f1f5f9;
    }

    .metric-progress {
        width: 100%;
        height: 8px;
        background: rgba(59, 130, 246, 0.1);
        border-radius: 4px;
        overflow: hidden;
    }

    .metric-progress-bar {
        height: 100%;
        background: linear-gradient(90deg, #3b82f6 0%, #1e40af 100%);
        border-radius: 4px;
    }
}

@container (min-width: 350px) {
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@container (min-width: 550px) {
    .metrics-grid {
        grid-template-columns: repeat(3, 1fr)
    }
}

@container (min-width: 750px) {
    .metrics-grid {
        grid-template-columns: repeat(4, 1fr)
    }
}

@container (min-width: 950px) {
    .metrics-grid {
        grid-template-columns: repeat(5, 1fr)
    }
}
