/**
 * API Credits Display & Usage Modal Styles
 * ISSUE_3269: Styling for credits display in bottom toolbar and usage history modal
 * DESIGN_37: Uses unified system font stack and standardized font sizes
 */

/* ============================================
   Bottom Toolbar Credits Display
   ============================================ */

/* ISSUE_3330: Container for popover positioning */
.bottom-toolbar__credits-container {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.bottom-toolbar__credits {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
    transition: all 0.3s ease;
    font-family: var(--font-system);
}

.bottom-toolbar__credits:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

.api-credits-icon {
    font-size: var(--font-size-sm);
    color: rgba(255, 255, 255, 0.9); /* White icon to match toolbar */
}

.api-credits-label {
    font-size: var(--font-size-xs);
    color: rgba(255, 255, 255, 0.7);
    font-weight: var(--font-weight-medium);
}

.api-credits-value {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    transition: color 0.3s ease;
}

.api-credits-unit {
    font-size: var(--font-size-xs);
    color: rgba(255, 255, 255, 0.5);
}

/* Status Colors - All white to match toolbar style */
.api-credits-value.status-healthy {
    color: rgba(255, 255, 255, 0.9); /* White - consistent with toolbar */
}

.api-credits-value.status-warning {
    color: rgba(255, 255, 255, 0.9); /* White - consistent with toolbar */
}

.api-credits-value.status-critical {
    color: rgba(255, 255, 255, 0.9); /* White - consistent with toolbar */
    animation: pulse 2s infinite;
}

.api-credits-value.status-loading {
    color: rgba(255, 255, 255, 0.5);
    animation: loading 1.5s infinite;
}

.api-credits-value.status-error {
    color: rgba(255, 255, 255, 0.9); /* White - consistent with toolbar */
}

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

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

/* ============================================
   Usage History Modal - Light Theme
   ============================================ */

.api-usage-modal {
    display: none;
    position: fixed;
    z-index: 999999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
}

.api-usage-modal-content {
    background-color: #ffffff;
    color: #1e293b;
    margin: 2% auto;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 1200px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease-out;
    border: 1px solid #e2e8f0;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.api-usage-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 32px;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border-bottom: 2px solid #cbd5e1;
}

.api-usage-modal-header h2 {
    margin: 0;
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-semibold);
    color: #1e293b;
    font-family: var(--font-system);
}

.modal-close {
    background: none;
    border: none;
    color: #64748b;
    font-size: 32px;
    cursor: pointer;
    transition: color 0.3s ease;
    padding: 0;
    width: 32px;
    height: 32px;
    line-height: 32px;
    text-align: center;
}

.modal-close:hover {
    color: #dc2626;
}

.api-usage-modal-body {
    padding: 32px;
    overflow-y: auto;
    max-height: calc(90vh - 80px);
    background-color: #f8fafc;
}

/* Loading State */
.loading-state {
    text-align: center;
    padding: 60px 20px;
    color: #64748b;
    font-size: var(--font-size-base);
    font-family: var(--font-system);
}

/* No Data State */
.no-data {
    text-align: center;
    padding: 40px 20px;
    color: #94a3b8;
    font-style: italic;
    font-size: var(--font-size-base);
    font-family: var(--font-system);
}

/* ============================================
   Status & Summary Sections
   ============================================ */

.usage-status-section,
.usage-summary-section {
    margin-bottom: 30px;
}

.usage-status-section h3,
.usage-summary-section h3,
.usage-filters-section h3,
.usage-history-section h3 {
    margin: 0 0 16px 0;
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: #1e293b;
    border-bottom: 2px solid #cbd5e1;
    padding-bottom: 10px;
    font-family: var(--font-system);
}

.status-cards,
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.status-card,
.summary-card {
    background: #ffffff;
    border-radius: 8px;
    padding: 20px;
    border: 1px solid #cbd5e1;
    transition: all 0.3s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.status-card:hover,
.summary-card:hover {
    background: #f8fafc;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.status-label,
.summary-label {
    font-size: var(--font-size-xs);
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 8px;
    font-weight: var(--font-weight-semibold);
    font-family: var(--font-system);
}

.status-value,
.summary-value {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    color: #059669;
    font-family: var(--font-system);
}

/* ============================================
   Filters Section
   ============================================ */

.usage-filters-section {
    margin-bottom: 30px;
}

.filter-controls {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.filter-controls select,
.filter-controls button {
    padding: 10px 16px;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #1e293b;
    font-size: var(--font-size-sm);
    font-family: var(--font-system);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.filter-controls select:hover,
.filter-controls button:hover {
    background: #f8fafc;
    border-color: #94a3b8;
}

.filter-controls select:focus,
.filter-controls button:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    border-color: #3b82f6;
}

/* ============================================
   Usage History Table
   ============================================ */

.usage-history-section {
    margin-bottom: 30px;
}

.usage-history-table {
    width: 100%;
    border-collapse: collapse;
    background: #ffffff;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
}

.usage-history-table thead {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
}

.usage-history-table th {
    padding: 14px 16px;
    text-align: left;
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-size-xs);
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    border-bottom: 2px solid #cbd5e1;
    font-family: var(--font-system);
}

.usage-history-table td {
    padding: 12px 16px;
    font-size: var(--font-size-sm);
    border-bottom: 1px solid #e2e8f0;
    color: #1e293b;
    font-family: var(--font-system);
}

.usage-history-table tbody tr:hover {
    background: #f8fafc;
}

.model-cell {
    font-family: var(--font-monospace);
    font-size: var(--font-size-xs);
}

/* Badges */
.source-badge,
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 14px;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    font-family: var(--font-system);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.source-badge.source-user {
    background: rgba(5, 150, 105, 0.15);
    color: #059669;
    border: 1px solid rgba(5, 150, 105, 0.3);
}

.source-badge.source-website {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.status-badge.status-success {
    background: rgba(5, 150, 105, 0.15);
    color: #059669;
}

.status-badge.status-failed {
    background: rgba(220, 38, 38, 0.15);
    color: #dc2626;
}

/* ============================================
   Pagination
   ============================================ */

.usage-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin: 30px 0;
}

.usage-pagination button {
    padding: 10px 20px;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #1e293b;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    font-family: var(--font-system);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.usage-pagination button:not(:disabled):hover {
    background: #f8fafc;
    border-color: #3b82f6;
    color: #3b82f6;
}

.usage-pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: #f1f5f9;
}

.page-info {
    color: #64748b;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    font-family: var(--font-system);
}

/* ============================================
   Actions Section
   ============================================ */

.usage-actions-section {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 24px;
    border-top: 2px solid #e2e8f0;
}

.usage-actions-section button {
    padding: 12px 24px;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    color: #1e293b;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    font-family: var(--font-system);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.usage-actions-section button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 768px) {
    .api-usage-modal-content {
        width: 95%;
        margin: 5% auto;
    }

    .api-usage-modal-header {
        padding: 15px 20px;
    }

    .api-usage-modal-body {
        padding: 20px;
    }

    .status-cards,
    .summary-cards {
        grid-template-columns: 1fr;
    }

    .usage-history-table {
        font-size: 12px;
    }

    .usage-history-table th,
    .usage-history-table td {
        padding: 8px 10px;
    }

    .filter-controls {
        flex-direction: column;
    }

    .filter-controls select,
    .filter-controls button {
        width: 100%;
    }
}

/* ============================================
   ISSUE_3330: API Credits Lightweight Popover
   Style matches language selector dropdown
   ============================================ */

.api-credits-popover {
    position: absolute;
    bottom: 100%;
    right: 0;
    background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1022;
    min-width: 200px;
    max-width: 220px;
    visibility: hidden;
    opacity: 0;
    transform: translateY(8px);
    transition: all 0.2s ease;
    padding: 0;
    margin-bottom: 8px;
    font-family: var(--font-system);
}

.api-credits-popover.visible {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
}

/* Header */
.api-credits-popover__header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 12px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.9);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.api-credits-popover__header i {
    font-size: 12px;
    color: #60a5fa;
}

/* Progress Bar */
.api-credits-popover__progress {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
}

.api-credits-popover__progress-bar {
    flex: 1;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.api-credits-popover__progress-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s ease;
}

.api-credits-popover__progress-fill.healthy {
    background: linear-gradient(90deg, #10b981, #34d399);
}

.api-credits-popover__progress-fill.warning {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.api-credits-popover__progress-fill.critical {
    background: linear-gradient(90deg, #ef4444, #f87171);
}

.api-credits-popover__percentage {
    font-size: 11px;
    font-weight: 600;
    min-width: 32px;
    text-align: right;
}

.api-credits-popover__percentage.healthy {
    color: #34d399;
}

.api-credits-popover__percentage.warning {
    color: #fbbf24;
}

.api-credits-popover__percentage.critical {
    color: #f87171;
}

/* Balance Display */
.api-credits-popover__balance {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 4px;
    padding: 4px 12px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.api-credits-popover__balance-value {
    font-size: 16px;
    font-weight: 700;
    color: #ffffff;
    font-variant-numeric: tabular-nums;
}

.api-credits-popover__balance-separator {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.4);
    margin: 0 2px;
}

.api-credits-popover__balance-total {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    font-variant-numeric: tabular-nums;
}

.api-credits-popover__balance-unit {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.4);
    margin-left: 2px;
}

/* Details Section */
.api-credits-popover__details {
    padding: 8px 12px;
}

.api-credits-popover__detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 0;
}

.api-credits-popover__detail-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
}

.api-credits-popover__detail-value {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

/* Footer */
.api-credits-popover__footer {
    padding: 8px 12px 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.api-credits-popover__link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 11px;
    color: #60a5fa;
    text-decoration: none;
    transition: all 0.2s ease;
    padding: 4px 0;
}

.api-credits-popover__link:hover {
    color: #93c5fd;
}

.api-credits-popover__link i {
    font-size: 10px;
    transition: transform 0.2s ease;
}

.api-credits-popover__link:hover i {
    transform: translateX(2px);
}

/* Responsive - smaller screens */
@media (max-width: 768px) {
    .api-credits-popover {
        min-width: 180px;
        max-width: 200px;
    }

    .api-credits-popover__balance-value {
        font-size: 14px;
    }
}
