/* ============================================
   Dashboard Page - Claude Provider
   Story-telling Layout v4.0
   ============================================ */

/* === Layout === */
.dashboard-container {
    max-width: var(--content-lg);
    margin: 0 auto;
    padding: var(--space-6) var(--space-4);
    min-height: calc(100vh - 200px);
}

.page-header {
    margin-bottom: var(--space-6);
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: var(--space-1);
}

.page-description {
    color: var(--text-secondary);
    margin: 0;
    font-size: 0.9375rem;
}

/* === Section Titles === */
.section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: var(--space-4);
}

/* === Cards === */
.card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-4);
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.card-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.card-actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

/* ============================================
   SECTION 1: HERO STATS (Account at a glance)
   ============================================ */
.section-hero {
    margin-bottom: var(--space-8);
}

.hero-stats {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: var(--space-4);
}

.hero-stat-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-5) var(--space-6);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.hero-stat-card.hero-stat-primary {
    background: linear-gradient(135deg, var(--accent-light) 0%, var(--bg-primary) 100%);
    border-color: var(--accent);
}

.hero-stat-label {
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.hero-stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
}

.hero-stat-unit {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.hero-stat-subtitle {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.status-badge {
    display: inline-block;
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    font-weight: 500;
    text-transform: capitalize;
}

.status-active {
    background: var(--green-light);
    color: var(--green);
}

.status-suspended {
    background: var(--yellow-light);
    color: var(--yellow);
}

.status-disabled {
    background: var(--red-light);
    color: var(--red);
}

/* === Subscription Info === */
.subscription-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: var(--space-4);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.subscription-info.subscription-payg {
    justify-content: flex-start;
}

.subscription-badge {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--accent);
}

.subscription-badge svg {
    width: 18px;
    height: 18px;
}

.subscription-details {
    display: flex;
    gap: var(--space-6);
}

.subscription-item {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.subscription-label {
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.subscription-value {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ============================================
   SECTION 2: CHARTS (Spending Pattern)
   ============================================ */
.section-charts {
    margin-bottom: var(--space-8);
}

.charts-row {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: var(--space-4);
}

.card-chart {
    min-height: 280px;
}

.chart-container {
    width: 100%;
}

.chart-container.chart-line {
    height: 180px;
}

.chart-container.chart-donut {
    width: 140px;
    height: 140px;
    flex-shrink: 0;
}

.chart-donut-wrapper {
    display: flex;
    align-items: center;
    gap: var(--space-5);
}

.chart-legend {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    flex: 1;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 0.8125rem;
}

.legend-color {
    width: 10px;
    height: 10px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.legend-label {
    flex: 1;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.legend-value {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.75rem;
}

/* ============================================
   SECTION 3: INSIGHTS (Compact Stats)
   ============================================ */
.section-insights {
    margin-bottom: var(--space-8);
}

.insights-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.insight-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    transition: all var(--transition);
}

.insight-card:hover {
    border-color: var(--accent);
}

.insight-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    flex-shrink: 0;
}

.insight-icon svg {
    width: 20px;
    height: 20px;
    color: var(--accent);
}

.insight-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.insight-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.insight-label {
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* === Hourly Heatmap === */
.heatmap-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-4) var(--space-5);
}

.heatmap-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-3);
}

.heatmap-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.heatmap-subtitle {
    font-size: 0.6875rem;
    color: var(--text-muted);
}

.heatmap-container {
    display: flex;
    gap: 2px;
    align-items: flex-end;
    height: 48px;
}

.heatmap-bar {
    flex: 1;
    min-width: 8px;
    border-radius: 2px 2px 0 0;
    transition: all var(--transition-fast);
    cursor: pointer;
    position: relative;
}

.heatmap-bar:hover {
    opacity: 0.8;
    transform: scaleY(1.1);
    transform-origin: bottom;
}

.heatmap-bar[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    font-size: 0.625rem;
    white-space: nowrap;
    z-index: 10;
    box-shadow: var(--shadow-sm);
    margin-bottom: 4px;
}

.heatmap-labels {
    display: flex;
    justify-content: space-between;
    margin-top: var(--space-2);
    font-size: 0.5625rem;
    color: var(--text-muted);
}

.heatmap-legend {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-top: var(--space-2);
    font-size: 0.5625rem;
    color: var(--text-muted);
}

.heatmap-legend-gradient {
    width: 60px;
    height: 8px;
    border-radius: 2px;
    background: linear-gradient(to right, var(--bg-tertiary), #5B9A5D);
}

/* ============================================
   SECTION 4: ACTIVITY + ACTIONS
   ============================================ */
.section-activity {
    margin-bottom: var(--space-6);
}

.activity-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--space-4);
}

.card-activity {
    min-height: 320px;
}

.card-actions {
    display: flex;
    flex-direction: column;
}

/* === Usage Table === */
.table-container.scrollable {
    max-height: 260px;
    overflow-y: auto;
}

.table-container.scrollable thead {
    position: sticky;
    top: 0;
    background: var(--bg-primary);
    z-index: 1;
}

.usage-row.new-row {
    animation: highlightRow 2s ease-out;
}

@keyframes highlightRow {
    0% { background-color: var(--accent-light); }
    100% { background-color: transparent; }
}

/* === Actions List === */
.actions-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    flex: 1;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.action-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent);
}

.action-btn .icon {
    width: 18px;
    height: 18px;
    color: var(--accent);
    flex-shrink: 0;
}

/* === Live Indicator === */
.live-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 0.6875rem;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-full);
}

.live-indicator.connected {
    background: var(--green-light);
    color: var(--green);
}

.live-indicator.disconnected {
    background: var(--red-light);
    color: var(--red);
}

.live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.live-indicator.connected .live-dot {
    animation: pulse 2s infinite;
}

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

/* === Empty State === */
.empty-state-sm {
    text-align: center;
    padding: var(--space-8) var(--space-4);
    color: var(--text-muted);
}

.empty-description {
    font-size: 0.875rem;
    margin: 0;
}

/* === Alert === */
.alert {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius);
    font-size: 0.875rem;
}

.alert-error {
    background: var(--red-light);
    color: var(--red);
    border: 1px solid var(--red);
}

/* === Skeleton Loading === */
.skeleton {
    background: linear-gradient(90deg,
        var(--bg-tertiary) 25%,
        var(--bg-secondary) 50%,
        var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: var(--radius);
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-text { height: 1rem; display: block; }
.skeleton-text-sm { height: 0.75rem; display: block; }
.skeleton-stat-value { width: 100px; height: 2.5rem; display: block; }
.skeleton-chart { width: 100%; height: 180px; }

/* === Toast === */
.toast-container {
    position: fixed;
    bottom: var(--space-6);
    right: var(--space-6);
    z-index: 1000;
}

.toast {
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
}

.toast-success {
    background: var(--green);
    color: white;
}

.toast-error {
    background: var(--red);
    color: white;
}

.toast-info {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
    .hero-stats {
        grid-template-columns: 1fr 1fr;
    }

    .hero-stats .hero-stat-card:first-child {
        grid-column: span 2;
    }

    .charts-row {
        grid-template-columns: 1fr;
    }

    .insights-grid {
        grid-template-columns: repeat(3, 1fr);
    }

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

    .card-actions {
        order: -1;
    }
}

@media (max-width: 768px) {
    .dashboard-container {
        padding: var(--space-4) var(--space-3);
    }

    .page-title {
        font-size: 1.5rem;
    }

    .hero-stats {
        grid-template-columns: 1fr;
    }

    .hero-stats .hero-stat-card:first-child {
        grid-column: span 1;
    }

    .hero-stat-value {
        font-size: 1.75rem;
    }

    .insights-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .insight-card {
        padding: var(--space-3);
    }

    .insight-icon {
        width: 36px;
        height: 36px;
    }

    .insight-icon svg {
        width: 18px;
        height: 18px;
    }

    .insight-value {
        font-size: 1.125rem;
    }

    .chart-donut-wrapper {
        flex-direction: column;
        align-items: flex-start;
    }

    .chart-container.chart-donut {
        margin: 0 auto;
    }

    .subscription-info {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-3);
    }

    .subscription-details {
        width: 100%;
        justify-content: space-between;
    }

    .subscription-item {
        align-items: flex-start;
    }

    .card-actions {
        display: none;
    }
}

@media (max-width: 480px) {
    .insights-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .insight-card {
        padding: var(--space-2) var(--space-3);
        gap: var(--space-2);
    }

    .insight-icon {
        width: 32px;
        height: 32px;
    }

    .insight-icon svg {
        width: 16px;
        height: 16px;
    }

    .insight-value {
        font-size: 1rem;
    }

    .insight-label {
        font-size: 0.5625rem;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-2);
    }
}
