/* ============================================
   DETAIL PAGE CONTROLS - v1.0.0
   Einheitliche Controls für alle Detail-Seiten
   ============================================ */

/* ========== AUTOCOMPLETE SELECTION CONTROL ========== */
.detail-autocomplete-control {
    position: relative;
    margin-bottom: 0;
    max-width: 100%;
    width: 100%;
}

.autocomplete-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.autocomplete-icon {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    pointer-events: none;
    display: flex;
    align-items: center;
    z-index: 1;
}

/* Green plus icon in a circle for add actions */
.autocomplete-icon-plus {
    background-color: var(--success-color);
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.autocomplete-icon-plus .mdi {
    font-size: 16px;
    width: 16px;
    height: 16px;
    line-height: 16px;
}

/* Blue info icon in a circle for selection/navigation */
.autocomplete-icon-info {
    background-color: var(--primary-color);
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.autocomplete-icon-info .mdi {
    font-size: 14px;
    width: 14px;
    height: 14px;
    line-height: 14px;
}

.autocomplete-input {
    width: 100%;
    padding: 0.4rem 3rem 0.4rem 2.75rem;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: all 0.2s;
    line-height: 1.3;
}

.autocomplete-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
    background: var(--bg-primary);
}

.autocomplete-input::placeholder {
    color: var(--text-muted);
}

.autocomplete-clear {
    position: absolute;
    right: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.autocomplete-clear:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.autocomplete-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 300px; /* Approx. 5 items at 60px each */
    overflow-y: auto;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
}

.autocomplete-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: all 0.15s;
    border-bottom: 1px solid var(--border-color);
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.highlighted {
    background: var(--primary-color);
    color: white;
}

.autocomplete-item:hover .autocomplete-item-name,
.autocomplete-item.highlighted .autocomplete-item-name {
    color: white;
}

.autocomplete-item:hover .autocomplete-item-subtitle,
.autocomplete-item.highlighted .autocomplete-item-subtitle {
    color: rgba(255, 255, 255, 0.8);
}

.autocomplete-item-name {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
}

.autocomplete-item-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.autocomplete-empty {
    color: var(--text-muted);
    font-style: italic;
    cursor: default;
}

.autocomplete-empty:hover {
    background: transparent;
    color: var(--text-muted);
}

.autocomplete-info {
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-align: center;
    border-bottom: 2px solid var(--border-color);
    font-weight: 500;
}

/* Scrollbar styling */
.autocomplete-dropdown::-webkit-scrollbar {
    width: 8px;
}

.autocomplete-dropdown::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 0 8px 8px 0;
}

.autocomplete-dropdown::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.autocomplete-dropdown::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ========== TAB NAVIGATION CONTROL ========== */
.detail-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-color);
    overflow-x: visible;
    overflow-y: hidden;
}

.detail-tab-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

.detail-tab-btn:hover {
    color: var(--primary-color);
    background: var(--bg-secondary);
}

.detail-tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background: var(--bg-secondary);
}

.detail-tab-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Tab Content Container */
.tab-content-container {
    width: 100%;
}

.detail-tab-content {
    display: none;
    /* animation: fadeIn 0.3s ease-in; */ /* Removed for instant loading */
}

.detail-tab-content.active {
    display: block;
}

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

/* ========== INFO GRID (for Overview Tab) ========== */
.info-grid-wide {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    transition: all 0.2s;
}

.info-item:hover {
    box-shadow: var(--shadow-sm);
}

.info-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.info-value {
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 500;
    word-break: break-word;
}

/* ========== BADGES LIST ========== */
.badges-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    min-height: 60px;
}

.badges-list:empty::after {
    content: 'Keine Einträge';
    color: var(--text-muted);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 60px;
}

/* ========== ACTION BUTTONS (Horizontal Layout) ========== */
.action-buttons-wide {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.action-buttons-wide button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 200px;
}

@media (max-width: 768px) {
    .action-buttons-wide {
        flex-direction: column;
    }
    
    .action-buttons-wide button {
        width: 100%;
    }
}

/* ========== EMPTY STATE ========== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 64px;
    opacity: 0.3;
    margin-bottom: 1rem;
}

.empty-state h3 {
    margin: 1rem 0 0.5rem;
    color: var(--text-secondary);
}

.empty-state p {
    margin: 0;
}

/* ========== PERMISSION STATS (for Device Groups) ========== */
.permissions-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.permission-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    transition: all 0.2s;
}

.permission-stat:hover {
    box-shadow: var(--shadow-sm);
}

.permission-stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.permission-stat-value {
    font-size: 2rem;
    font-weight: 600;
    color: var(--primary-color);
}

/* ========== MODAL PERMISSION TABS ========== */
.permission-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-color);
}

.permission-tab-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.permission-tab-btn:hover {
    color: var(--primary-color);
}

.permission-tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.permission-tab-content {
    display: none;
}

.permission-tab-content.active {
    display: block;
}

/* ========== PERMISSION DROPDOWN ========== */
.permission-dropdown {
    position: relative;
    display: inline-block;
    cursor: pointer;
}

.permission-display {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
}

.permission-arrow {
    color: var(--text-muted);
    font-size: 12px;
    transition: transform 0.2s ease;
}

.permission-dropdown:hover .permission-arrow {
    transform: translateY(-1px);
}

.permission-dropdown.open .permission-arrow {
    transform: rotate(180deg);
}

.permission-dropdown-menu {
    position: fixed;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 99999 !important;
    min-width: 120px;
    overflow: visible !important;
    margin-top: 4px;
    display: flex !important;
    flex-direction: column;
    align-items: center;
    padding: 4px;
}

.permission-option {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 4px;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
}

.permission-option:hover {
    transform: scale(1.05);
}

.permission-option.active {
    transform: scale(1.08);
    color: white;
}

.permission-option.active .badge {
    background: rgba(255, 255, 255, 0.2) !important;
    color: white !important;
}

.permission-option .badge {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
}

/* Dark mode adjustments */
[data-theme="dark"] .permission-dropdown-menu {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

[data-theme="dark"] .permission-option:hover {
    background: var(--bg-hover);
}

/* Animation for dropdown */
.permission-dropdown-menu {
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}

.permission-dropdown.open .permission-dropdown-menu {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

