/* API Usage Dashboard - Consolidated View */

/* Page Header */
.page-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

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

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

.header-actions .form-select {
    width: 180px;
}

/* Summary Cards Grid */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.summary-card {
    background: white;
    border-radius: 16px;
    padding: 1.25rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.summary-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
}

.summary-card.highlight {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.08) 0%, rgba(59, 130, 246, 0.08) 100%);
    border: 1px solid rgba(139, 92, 246, 0.2);
}

.summary-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    flex-shrink: 0;
}

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

.summary-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    font-weight: 500;
}

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

.summary-sub {
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

.summary-sub.text-success {
    color: #10b981 !important;
}

.summary-sub.text-danger {
    color: #ef4444 !important;
}

/* Color variants */
.bg-primary-soft {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(59, 130, 246, 0.08) 100%);
}

.bg-success-soft {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(16, 185, 129, 0.08) 100%);
}

.bg-warning-soft {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, rgba(245, 158, 11, 0.08) 100%);
}

.bg-info-soft {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15) 0%, rgba(139, 92, 246, 0.08) 100%);
}

/* Charts Section */
.charts-section {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.chart-card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.chart-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.chart-legend {
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
}

.chart-body {
    padding: 1rem;
    height: 220px;
}

.chart-body-pie {
    height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Filters Section */
.filters-section {
    background: white;
    border-radius: 12px;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 140px;
}

.filter-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-group .form-select,
.filter-group .form-control {
    font-size: 0.875rem;
}

/* View Toggle */
.view-toggle-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding: 0 0.25rem;
}

.view-info {
    font-size: 0.85rem;
}

#viewModeToggle .btn {
    font-size: 0.8rem;
    padding: 0.35rem 0.75rem;
}

/* Data Table */
.data-table-card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.table {
    margin-bottom: 0;
}

.table thead th {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
    padding: 0.85rem 1rem;
    background: linear-gradient(180deg, #fafafa 0%, #f5f5f5 100%);
    position: sticky;
    top: 0;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.2s;
}

.table thead th:hover {
    background: linear-gradient(180deg, #f0f0f0 0%, #e8e8e8 100%);
}

.table thead th.sortable::after {
    content: '\f0dc';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    margin-left: 0.5rem;
    opacity: 0.3;
    font-size: 0.65rem;
}

.table thead th.sort-asc::after {
    content: '\f0de';
    opacity: 0.8;
}

.table thead th.sort-desc::after {
    content: '\f0dd';
    opacity: 0.8;
}

.table tbody td {
    padding: 0.85rem 1rem;
    vertical-align: middle;
    font-size: 0.875rem;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.table tbody tr {
    transition: background 0.15s;
}

.table tbody tr:hover {
    background: rgba(59, 130, 246, 0.04);
}

.table tbody tr.expandable {
    cursor: pointer;
}

.table tbody tr.expanded {
    background: rgba(59, 130, 246, 0.08);
}

.table tbody tr.expanded-detail {
    background: #f8fafc;
}

.table tbody tr.expanded-detail td {
    padding: 0;
}

/* Platform badges */
.platform-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

.platform-badge.line {
    background: rgba(0, 185, 0, 0.12);
    color: #00a000;
}

.platform-badge.facebook {
    background: rgba(24, 119, 242, 0.12);
    color: #1877f2;
}

/* Model badges */
.model-badge {
    display: inline-block;
    padding: 0.25rem 0.55rem;
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    font-family: 'SF Mono', 'Monaco', monospace;
    color: #475569;
}

.model-badge.gpt-4 {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15) 0%, rgba(139, 92, 246, 0.08) 100%);
    color: #7c3aed;
}

.model-badge.gpt-3 {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(16, 185, 129, 0.08) 100%);
    color: #059669;
}

/* Cost display */
.cost-display {
    font-weight: 600;
    color: var(--text-primary);
}

.cost-sub {
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Expanded Row Detail */
.expanded-row-content {
    padding: 1.25rem;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-left: 3px solid var(--primary);
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.detail-card {
    background: white;
    border-radius: 10px;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.detail-card-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.detail-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.detail-list li {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    border-bottom: 1px dashed rgba(0, 0, 0, 0.08);
    font-size: 0.85rem;
}

.detail-list li:last-child {
    border-bottom: none;
}

/* Info Note */
.info-note {
    margin-top: 1.5rem;
    padding: 0.85rem 1rem;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.08) 0%, rgba(139, 92, 246, 0.05) 100%);
    border-radius: 10px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    border: 1px solid rgba(59, 130, 246, 0.15);
}

/* Expanded Panel (Slide-in) */
.expanded-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 450px;
    height: 100vh;
    background: white;
    box-shadow: -4px 0 25px rgba(0, 0, 0, 0.15);
    z-index: 1050;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.expanded-header {
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
}

.expanded-header h5 {
    margin: 0;
    font-weight: 600;
}

.btn-close-panel {
    background: none;
    border: none;
    font-size: 1rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
}

.expanded-content {
    padding: 1.25rem;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 3rem;
    opacity: 0.3;
    margin-bottom: 1rem;
}

/* Progress bar for cost comparison */
.cost-bar {
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
    margin-top: 0.35rem;
}

.cost-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

.cost-bar-fill.primary {
    background: linear-gradient(90deg, #3b82f6 0%, #8b5cf6 100%);
}

.cost-bar-fill.success {
    background: linear-gradient(90deg, #10b981 0%, #34d399 100%);
}

.cost-bar-fill.warning {
    background: linear-gradient(90deg, #f59e0b 0%, #fbbf24 100%);
}

/* Row expand icon */
.expand-icon {
    font-size: 0.75rem;
    color: var(--text-secondary);
    transition: transform 0.2s;
}

.expanded .expand-icon {
    transform: rotate(90deg);
}

/* Loading skeleton */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

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

    100% {
        background-position: -200% 0;
    }
}

/* Responsive */
@media (max-width: 1200px) {
    .summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }

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

@media (max-width: 768px) {
    .summary-grid {
        grid-template-columns: 1fr;
    }

    .page-header-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-actions {
        width: 100%;
        justify-content: space-between;
    }

    .filters-section {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group {
        width: 100%;
    }

    .summary-value {
        font-size: 1.3rem;
    }

    .summary-icon {
        width: 44px;
        height: 44px;
        font-size: 1.1rem;
    }

    .expanded-panel {
        width: 100%;
    }
}

/* Animation for cards */
.summary-card {
    animation: fadeInUp 0.4s ease forwards;
    opacity: 0;
}

.summary-card:nth-child(1) {
    animation-delay: 0.05s;
}

.summary-card:nth-child(2) {
    animation-delay: 0.1s;
}

.summary-card:nth-child(3) {
    animation-delay: 0.15s;
}

.summary-card:nth-child(4) {
    animation-delay: 0.2s;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Table row animation */
.table tbody tr {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}