/**
 * Global Badge System for Connect Portal
 * Zentrale Badge-Styles für einheitliches, harmonisches Design
 * Version: 2.0.0
 */

/* ============================================================================
   BASE BADGE STYLES
   ============================================================================ */

.badge-pair {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.55rem;
    border-radius: 6px;
    font-size: 0.725rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    text-align: center;
    min-width: 60px;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

/* ============================================================================
   SEMANTIC STATUS & PERMISSION BADGES
   ============================================================================ */

/* Rot / Danger: Admin, Inaktiv, Abgelehnt, Abgelaufen, DENY, Decommissioned, Fehler */
.badge-danger {
    background: rgba(239, 68, 68, 0.12);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Orange / Warning: Operator, Wartend / Pending, Wartung, Temporäre Session, Write (W) */
.badge-warning {
    background: rgba(245, 158, 11, 0.12);
    color: #d97706;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

/* Grün / Success: Aktiv, Online, Angenommen, Genehmigt, ALLOW, Ja */
.badge-success {
    background: rgba(16, 185, 129, 0.12);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

/* Blau / Info: Viewer, Mitglied / Member, Team, Keycloak/Custom User, Read (R), Subscribe (S) */
.badge-info {
    background: rgba(59, 130, 246, 0.12);
    color: #2563eb;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

/* Grau / Secondary: System, Standard, Neutral, Tags, Rollenchips */
.badge-secondary,
.badge-default {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

/* Muted: Leere Zähler (0), Deaktiviert */
.badge-muted {
    background: var(--bg-secondary);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    opacity: 0.75;
}

/* Primary: Dezenter Marken-Rotton (nur für gezielte UI-Highlights) */
.badge-primary {
    background: rgba(222, 12, 21, 0.1);
    color: var(--primary-color);
    border: 1px solid rgba(222, 12, 21, 0.2);
}

/* ============================================================================
   PERMISSION SOURCE BADGES (Direct vs. Inherited)
   ============================================================================ */

.badge-direct {
    background: rgba(16, 185, 129, 0.12);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.badge-inherit {
    background: rgba(245, 158, 11, 0.12);
    color: #d97706;
    border: 1px solid rgba(245, 158, 11, 0.25);
}

/* ============================================================================
   COUNT BADGES (Neutral & Aufgeräumt für Zähler aller Art)
   ============================================================================ */

.badge-count {
    min-width: unset;
    padding: 0.15rem 0.5rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    font-variant-numeric: tabular-nums;
}

/* ============================================================================
   INTERACTIVE BADGES (Buttons / Links / Filter)
   ============================================================================ */

.badge-clickable,
button.badge,
button.mqtt-count-btn {
    text-decoration: none;
    cursor: pointer;
}

.badge-clickable:hover,
button.badge:hover,
button.mqtt-count-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
    filter: brightness(1.05);
}

.badge-count.badge-clickable:hover,
button.mqtt-count-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--text-muted);
    color: var(--text-primary);
}

/* ============================================================================
   BADGE SIZES
   ============================================================================ */

.badge-sm {
    padding: 0.125rem 0.4rem;
    font-size: 0.6875rem;
    min-width: unset;
}

.badge-lg {
    padding: 0.35rem 0.85rem;
    font-size: 0.8125rem;
}

/* ============================================================================
   DARK MODE ADJUSTMENTS
   ============================================================================ */

[data-theme="dark"] .badge-danger {
    background: rgba(239, 68, 68, 0.18);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.3);
}

[data-theme="dark"] .badge-warning {
    background: rgba(245, 158, 11, 0.18);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.3);
}

[data-theme="dark"] .badge-info {
    background: rgba(59, 130, 246, 0.18);
    color: #60a5fa;
    border-color: rgba(59, 130, 246, 0.3);
}

[data-theme="dark"] .badge-success {
    background: rgba(16, 185, 129, 0.18);
    color: #34d399;
    border-color: rgba(16, 185, 129, 0.3);
}

[data-theme="dark"] .badge-direct {
    background: rgba(16, 185, 129, 0.18);
    color: #34d399;
    border-color: rgba(16, 185, 129, 0.3);
}

[data-theme="dark"] .badge-inherit {
    background: rgba(245, 158, 11, 0.18);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.3);
}

[data-theme="dark"] .badge-primary {
    background: rgba(222, 12, 21, 0.18);
    color: #f87171;
    border-color: rgba(222, 12, 21, 0.3);
}

[data-theme="dark"] .badge-secondary,
[data-theme="dark"] .badge-default {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-color: var(--border-color);
}

[data-theme="dark"] .badge-count {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

[data-theme="dark"] .badge-muted {
    background: var(--bg-secondary);
    color: var(--text-muted);
    border-color: var(--border-color);
}

/* ============================================================================
   HIGH CONTRAST MODE
   ============================================================================ */

@media (prefers-contrast: high) {
    .badge-danger {
        background: #dc2626;
        color: white;
        border-color: #991b1b;
    }
    
    .badge-warning {
        background: #d97706;
        color: white;
        border-color: #92400e;
    }
    
    .badge-info {
        background: #2563eb;
        color: white;
        border-color: #1e40af;
    }
    
    .badge-success,
    .badge-direct {
        background: #059669;
        color: white;
        border-color: #065f46;
    }
    
    .badge-inherit {
        background: #d97706;
        color: white;
        border-color: #92400e;
    }
    
    .badge-primary {
        background: var(--primary-color);
        color: white;
        border-color: #991b1b;
    }

    .badge-secondary,
    .badge-count {
        background: #334155;
        color: white;
        border-color: #1e293b;
    }
}

/* ============================================================================
   PRINT STYLES
   ============================================================================ */

@media print {
    .badge {
        background: transparent !important;
        color: #000 !important;
        border: 1px solid #000 !important;
    }
}
