/* ==========================================
   SiteRooster Credit Bar
   Displays in the top header across all dashboard pages
   ========================================== */

.sr-credit-bar {
    display: flex;
    align-items: center;
    margin-left: auto;
    margin-right: 16px;
}

.sr-credit-bar-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 14px;
    background: var(--gray-50, #f9fafb);
    border: 1px solid var(--gray-200, #e5e7eb);
    border-radius: 8px;
    position: relative;
}

/* Credit text info */
.sr-credit-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.sr-credit-count {
    display: flex;
    align-items: baseline;
    gap: 2px;
    font-size: 13px;
    line-height: 1.2;
    white-space: nowrap;
}

.sr-credit-remaining {
    font-weight: 600;
    color: var(--siterooster-green, #059669);
}

.sr-credit-separator {
    color: var(--gray-400, #9ca3af);
    font-weight: 400;
}

.sr-credit-total {
    color: var(--gray-500, #6b7280);
    font-weight: 400;
}

.sr-credit-label {
    color: var(--gray-400, #9ca3af);
    font-size: 12px;
    margin-left: 3px;
}

.sr-credit-reset {
    font-size: 11px;
    color: var(--gray-400, #9ca3af);
    line-height: 1.2;
    white-space: nowrap;
}

/* Progress track */
.sr-credit-track {
    width: 80px;
    height: 6px;
    background: var(--gray-200, #e5e7eb);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
}

.sr-credit-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: var(--siterooster-green, #059669);
    border-radius: 3px;
    transition: width 0.4s ease;
}

/* Preview fill (shows upcoming deduction) */
.sr-credit-preview-fill {
    position: absolute;
    top: 0;
    height: 100%;
    background: #f59e0b;
    border-radius: 0 3px 3px 0;
    transition: width 0.3s ease, left 0.3s ease;
    opacity: 0.7;
}

/* Position the preview fill right after the used fill */
.sr-credit-track .sr-credit-preview-fill {
    left: var(--sr-credit-used-width, 0);
}

/* Warning states */
.sr-credit-bar.sr-credit-warning .sr-credit-remaining {
    color: #f59e0b;
}
.sr-credit-bar.sr-credit-warning .sr-credit-fill {
    background: #f59e0b;
}

.sr-credit-bar.sr-credit-danger .sr-credit-remaining {
    color: #ef4444;
}
.sr-credit-bar.sr-credit-danger .sr-credit-fill {
    background: #ef4444;
}

/* Preview text (shows below the bar when previewing a cost) */
.sr-credit-preview-text {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    font-size: 11px;
    color: #f59e0b;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 4px;
    padding: 3px 8px;
    z-index: 100;
}

.sr-credit-preview-text.sr-credit-preview-visible {
    opacity: 1;
}

.sr-credit-preview-text.sr-credit-preview-over {
    color: #ef4444;
    background: #fef2f2;
    border-color: #fecaca;
}

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

/* Tablets: hide renewal text, shrink bar */
@media (max-width: 1024px) {
    .sr-credit-reset {
        display: none;
    }
    .sr-credit-track {
        width: 60px;
    }
}

/* Mobile: compact mode */
@media (max-width: 768px) {
    .sr-credit-bar {
        margin-right: 8px;
    }
    .sr-credit-bar-inner {
        padding: 4px 10px;
        gap: 8px;
    }
    .sr-credit-label {
        display: none;
    }
    .sr-credit-track {
        width: 40px;
    }
}

/* Very small: hide track entirely, just show numbers */
@media (max-width: 480px) {
    .sr-credit-track {
        display: none;
    }
}