/* ============================================================================
   Credit & Billing Page Styles
   ============================================================================ */

.credit-page {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Metric Cards */
.credit-metrics {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.metric-card {
    background: #ffffff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 20px;
}

.metric-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
}

.metric-balance .metric-value {
    font-size: 2rem;
    color: var(--primary);
}

.metric-change {
    margin-top: 6px;
    font-size: 0.85rem;
    font-weight: 600;
}

.metric-change .change-up {
    color: var(--success);
}

.metric-change .change-down {
    color: var(--danger);
}

.metric-change i {
    margin-right: 4px;
}

/* Credit Utilization Bar */
.credit-utilization-card {
    background: #ffffff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 16px 20px;
}

.utilization-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.utilization-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.utilization-pct {
    font-size: 1.1rem;
    font-weight: 700;
}

.utilization-pct.util-low { color: var(--success); }
.utilization-pct.util-mid { color: var(--warning); }
.utilization-pct.util-high { color: var(--danger); }

.utilization-bar-track {
    width: 100%;
    height: 10px;
    background: #eee;
    border-radius: 5px;
    overflow: hidden;
}

.utilization-bar-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 0.6s ease, background 0.4s ease;
}

.utilization-bar-fill.util-low { background: var(--success); }
.utilization-bar-fill.util-mid { background: var(--warning); }
.utilization-bar-fill.util-high { background: var(--danger); }

.utilization-details {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 0.75rem;
    color: var(--text-light);
}

/* Actions Bar */
.credit-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ffffff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 12px 20px;
}

.credit-actions-left {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    color: var(--text);
    flex-wrap: wrap;
}

.range-buttons {
    display: flex;
    gap: 4px;
}

.range-btn {
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: #fff;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-light);
    cursor: pointer;
    transition: var(--transition);
}

.range-btn:hover {
    background: var(--content-bg);
    color: var(--text);
}

.range-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.custom-range {
    display: flex;
    align-items: center;
    gap: 6px;
}

.range-separator {
    font-size: 0.8rem;
    color: var(--text-light);
}

.credit-date-picker {
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    color: var(--text);
    background: var(--content-bg);
}

.credit-actions-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.last-updated {
    font-size: 0.8rem;
    color: var(--text-light);
}

.refresh-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--primary);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.refresh-btn:hover:not(:disabled) {
    background: var(--primary-dark, #0a2d5e);
    transform: translateY(-1px);
}

.refresh-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.refresh-btn.spinning i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.cooldown-text {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--warning);
    font-weight: 600;
}

/* Chart Card */
.credit-chart-card {
    background: #ffffff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.chart-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.chart-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.chart-container {
    padding: 20px;
    height: 300px;
    position: relative;
}

.chart-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-light);
}

.chart-empty i {
    font-size: 2.5rem;
    opacity: 0.3;
    display: block;
    margin-bottom: 12px;
}

/* Changes Table Card */
.credit-table-card {
    background: #ffffff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.table-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.table-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.table-container {
    overflow-x: auto;
}

.changes-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.changes-table th {
    padding: 10px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-light);
    background: var(--content-bg);
    border-bottom: 1px solid var(--border);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.changes-table td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.changes-table tbody tr:hover {
    background: rgba(15, 52, 96, 0.02);
}

.changes-table .change-positive {
    color: var(--success);
    font-weight: 600;
}

.changes-table .change-negative {
    color: var(--danger);
    font-weight: 600;
}

.changes-table .source-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
}

.source-badge.scheduled {
    background: rgba(9, 132, 227, 0.1);
    color: var(--info);
}

.source-badge.manual {
    background: rgba(108, 92, 231, 0.1);
    color: #6c5ce7;
}

.table-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-light);
}

.table-empty i {
    font-size: 2rem;
    opacity: 0.3;
    display: block;
    margin-bottom: 10px;
}

/* Empty State (first-time setup) */
.credit-empty-state {
    text-align: center;
    padding: 60px 20px;
    background: #ffffff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.credit-empty-state i {
    font-size: 3rem;
    color: var(--primary);
    opacity: 0.4;
    margin-bottom: 16px;
}

.credit-empty-state h2 {
    font-size: 1.2rem;
    color: var(--text);
    margin: 0 0 8px;
}

.credit-empty-state p {
    font-size: 0.9rem;
    color: var(--text-light);
    margin: 0 0 20px;
}

/* Responsive */
@media (max-width: 1024px) {
    .credit-metrics {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .credit-metrics {
        grid-template-columns: 1fr;
    }

    .credit-actions {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }

    .credit-actions-left {
        flex-direction: column;
        align-items: stretch;
    }

    .range-buttons {
        flex-wrap: wrap;
    }

    .credit-actions-right {
        justify-content: space-between;
    }

    .metric-balance .metric-value {
        font-size: 1.5rem;
    }
}

/* Large Screens */
@media (min-width: 1440px) {
    .chart-container {
        height: 350px;
    }
}
