/* Usage Management Dashboard Styles */

/* Time Period Selector */
.time-period-selector {
    display: flex;
    gap: 8px;
    background: #f8fafc;
    padding: 6px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.time-period-btn {
    padding: 10px 20px;
    border: none;
    background: transparent;
    color: #64748b;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.time-period-btn:hover {
    background: #e2e8f0;
    color: #334155;
}

.time-period-btn.active {
    background: linear-gradient(135deg, #0e1369, #1e40af);
    color: white;
    box-shadow: 0 2px 8px rgba(14, 19, 105, 0.3);
}

/* Usage Summary Cards */
.usage-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.usage-card {
    background: white;
    border-radius: 16px;
    padding: 24px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.usage-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.usage-card.total-cost {
    background: linear-gradient(135deg, #0e1369 0%, #1e40af 100%);
    color: white;
}

.usage-card.total-cost .usage-card-label {
    color: rgba(255, 255, 255, 0.8);
}

.usage-card.total-cost .usage-card-value {
    color: white;
}

.usage-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.usage-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.usage-card-icon.cost {
    background: rgba(6, 184, 160, 0.15);
    color: #06b8a0;
}

.usage-card-icon.tokens {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}

.usage-card-icon.api {
    background: rgba(168, 85, 247, 0.15);
    color: #a855f7;
}

.usage-card-icon.infra {
    background: rgba(249, 115, 22, 0.15);
    color: #f97316;
}

.usage-card.total-cost .usage-card-icon {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.usage-card-trend {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 6px;
}

.usage-card-trend.up {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.usage-card-trend.down {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.usage-card.total-cost .usage-card-trend {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.usage-card-label {
    font-size: 14px;
    color: #64748b;
    margin-bottom: 4px;
}

.usage-card-value {
    font-size: 32px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.2;
}

.usage-card-subtitle {
    font-size: 13px;
    color: #94a3b8;
    margin-top: 4px;
}

.usage-card.total-cost .usage-card-subtitle {
    color: rgba(255, 255, 255, 0.7);
}

/* Usage Breakdown Section */
.usage-breakdown-section {
    background: white;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    padding: 24px;
    margin-bottom: 24px;
}

.usage-breakdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e2e8f0;
}

.usage-breakdown-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.usage-breakdown-header h3 i {
    color: #0e1369;
}

/* Cost Breakdown Table */
.cost-breakdown-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.cost-breakdown-table thead th {
    background: linear-gradient(135deg, #0e1369 0%, #1e40af 100%);
    color: white;
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cost-breakdown-table thead th:first-child {
    border-radius: 10px 0 0 0;
}

.cost-breakdown-table thead th:last-child {
    border-radius: 0 10px 0 0;
    text-align: right;
}

.cost-breakdown-table tbody tr {
    transition: background-color 0.2s ease;
}

.cost-breakdown-table tbody tr:hover {
    background: #f8fafc;
}

.cost-breakdown-table tbody td {
    padding: 16px;
    border-bottom: 1px solid #e2e8f0;
    font-size: 14px;
    color: #334155;
}

.cost-breakdown-table tbody td:last-child {
    text-align: right;
    font-weight: 600;
    color: #0e1369;
}

.cost-breakdown-table tbody tr:last-child td:first-child {
    border-radius: 0 0 0 10px;
}

.cost-breakdown-table tbody tr:last-child td:last-child {
    border-radius: 0 0 10px 0;
}

.service-name {
    display: flex;
    align-items: center;
    gap: 12px;
}

.service-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.service-icon.bedrock {
    background: rgba(168, 85, 247, 0.15);
    color: #a855f7;
}

.service-icon.lambda {
    background: rgba(249, 115, 22, 0.15);
    color: #f97316;
}

.service-icon.dynamodb {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}

.service-icon.s3 {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.service-icon.secrets {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.service-icon.dataforseo {
    background: rgba(6, 184, 160, 0.15);
    color: #06b8a0;
}

.service-icon.cloudwatch {
    background: rgba(236, 72, 153, 0.15);
    color: #ec4899;
}

/* User Breakdown Table */
.user-breakdown-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.user-breakdown-table thead th {
    background: linear-gradient(135deg, #06b8a0 0%, #059669 100%);
    color: white;
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.user-breakdown-table thead th:first-child {
    border-radius: 10px 0 0 0;
}

.user-breakdown-table thead th:last-child {
    border-radius: 0 10px 0 0;
    text-align: right;
}

.user-breakdown-table tbody tr {
    transition: background-color 0.2s ease;
}

.user-breakdown-table tbody tr:hover {
    background: #f0fdf9;
}

.user-breakdown-table tbody td {
    padding: 16px;
    border-bottom: 1px solid #e2e8f0;
    font-size: 14px;
    color: #334155;
}

.user-breakdown-table tbody td:last-child {
    text-align: right;
    font-weight: 600;
    color: #059669;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #06b8a0, #059669);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    color: #1e293b;
}

.user-email {
    font-size: 12px;
    color: #64748b;
}

/* Agent/Function Breakdown */
.agent-breakdown-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.agent-card {
    background: #f8fafc;
    border-radius: 12px;
    padding: 20px;
    border: 1px solid #e2e8f0;
    transition: all 0.2s ease;
}

.agent-card:hover {
    border-color: #0e1369;
    box-shadow: 0 4px 12px rgba(14, 19, 105, 0.1);
}

.agent-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.agent-name {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: #1e293b;
}

.agent-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, #0e1369, #1e40af);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.agent-cost {
    font-weight: 700;
    color: #0e1369;
    font-size: 18px;
}

.agent-stats {
    display: flex;
    gap: 20px;
}

.agent-stat {
    display: flex;
    flex-direction: column;
}

.agent-stat-label {
    font-size: 11px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.agent-stat-value {
    font-size: 16px;
    font-weight: 600;
    color: #334155;
}

/* Usage Chart Container */
.usage-chart-container {
    height: 300px;
    margin-top: 20px;
    position: relative;
    overflow: hidden;
}

.usage-chart-container .apexcharts-canvas {
    max-width: 100%;
}

/* Ensure the chart section contains everything properly */
.usage-breakdown-section {
    overflow: hidden;
    position: relative;
}

/* Loading State */
.usage-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #64748b;
}

.usage-loading i {
    font-size: 48px;
    margin-bottom: 16px;
    color: #0e1369;
    animation: spin 1s linear infinite;
}

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

/* Empty State */
.usage-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #64748b;
    text-align: center;
}

.usage-empty i {
    font-size: 48px;
    margin-bottom: 16px;
    color: #cbd5e1;
}

.usage-empty h4 {
    margin: 0 0 8px;
    color: #334155;
}

.usage-empty p {
    margin: 0;
    font-size: 14px;
}

/* Refresh Button */
.refresh-usage-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    color: #64748b;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.refresh-usage-btn:hover {
    border-color: #0e1369;
    color: #0e1369;
}

.refresh-usage-btn.loading i {
    animation: spin 1s linear infinite;
}

/* Date Range Display */
.date-range-display {
    font-size: 14px;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 8px;
}

.date-range-display i {
    color: #0e1369;
}

/* Progress Bars for Usage */
.usage-progress-container {
    margin-top: 12px;
}

.usage-progress-bar {
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.usage-progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.usage-progress-fill.cost {
    background: linear-gradient(90deg, #06b8a0, #059669);
}

.usage-progress-fill.tokens {
    background: linear-gradient(90deg, #3b82f6, #1d4ed8);
}

.usage-progress-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 12px;
    color: #64748b;
}

/* API Usage Summary */
.api-summary-row {
    display: flex;
    gap: 24px;
    margin-bottom: 20px;
    padding: 16px;
    background: linear-gradient(135deg, #f0fdf4, #ecfdf5);
    border-radius: 12px;
    border: 1px solid #bbf7d0;
}

.api-summary-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.api-summary-label {
    font-size: 12px;
    color: #64748b;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.api-summary-value {
    font-size: 24px;
    font-weight: 700;
    color: #059669;
}

/* Service Icons */
.service-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    margin-right: 12px;
}

.service-icon.dataforseo {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    color: #d97706;
}

.service-icon.google {
    background: linear-gradient(135deg, #dbeafe, #bfdbfe);
    color: #2563eb;
}

.service-icon.wordpress {
    background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
    color: #4f46e5;
}

.service-icon.default {
    background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
    color: #64748b;
}

.service-name {
    display: flex;
    align-items: center;
}

/* Responsive Design */
@media (max-width: 768px) {
    .usage-summary-grid {
        grid-template-columns: 1fr;
    }
    
    .usage-breakdown-header {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }
    
    .time-period-selector {
        width: 100%;
        justify-content: center;
    }
    
    .usage-card-value {
        font-size: 24px;
    }
    
    .cost-breakdown-table,
    .user-breakdown-table {
        display: block;
        overflow-x: auto;
    }
    
    .agent-breakdown-grid {
        grid-template-columns: 1fr;
    }
}
