<div class="notification-center-component">
    <!-- Header with Badge -->
    <div class="notification-header">
        <button
            class="notification-bell"
            data-live-action="togglePanel"
            aria-label="Toggle notification panel"
        >
            🔔
            <if condition="unread_count > 0">
                <span class="notification-badge">{{unread_count}}</span>
            </if>
        </button>
    </div>

    <!-- Notification Panel -->
    <if condition="show_panel">
        <div class="notification-panel">
            <!-- Panel Header -->
            <div class="panel-header">
                <h3>Benachrichtigungen</h3>
                <div class="panel-actions">
                    <button
                        class="btn btn-small"
                        data-live-action="markAllAsRead"
                        {{mark_all_read_disabled}}
                    >
                        Alle als gelesen markieren
                    </button>
                    <button
                        class="btn btn-small btn-danger"
                        data-live-action="deleteAllRead"
                    >
                        Gelesene löschen
                    </button>
                </div>
            </div>

            <!-- Filter Tabs -->
            <div class="notification-filters">
                <button
                    class="filter-tab {{filter_all_class}}"
                    data-live-action="filterByType"
                    data-param-type="all"
                >
                    Alle
                </button>
                <button
                    class="filter-tab {{filter_success_class}}"
                    data-live-action="filterByType"
                    data-param-type="success"
                >
                    ✅ Erfolg
                </button>
                <button
                    class="filter-tab {{filter_info_class}}"
                    data-live-action="filterByType"
                    data-param-type="info"
                >
                    ℹ️ Info
                </button>
                <button
                    class="filter-tab {{filter_warning_class}}"
                    data-live-action="filterByType"
                    data-param-type="warning"
                >
                    ⚠️ Warnung
                </button>
                <button
                    class="filter-tab {{filter_error_class}}"
                    data-live-action="filterByType"
                    data-param-type="error"
                >
                    ❌ Fehler
                </button>
            </div>

            <!-- Notifications List -->
            <div class="notifications-list">
                <for items="notifications" as="notification">
                    <div class="notification-item notification-{{notification.type}} {{notification.read_class}}">
                        <div class="notification-icon">
                            {{notification.icon}}
                        </div>

                        <div class="notification-content">
                            <div class="notification-title">{{notification.title}}</div>
                            <div class="notification-message">{{notification.message}}</div>
                            <div class="notification-time">
                                {{notification.formatted_time}}
                            </div>
                        </div>

                        <div class="notification-actions">
                            <if condition="!notification.read">
                                <button
                                    class="action-btn"
                                    data-live-action="markAsRead"
                                    data-param-notification-id="{{notification.id}}"
                                    title="Als gelesen markieren"
                                >
                                    👁️
                                </button>
                            </if>
                            <if condition="notification.read">
                                <button
                                    class="action-btn"
                                    data-live-action="markAsUnread"
                                    data-param-notification-id="{{notification.id}}"
                                    title="Als ungelesen markieren"
                                >
                                    👁️‍🗨️
                                </button>
                            </if>
                            <button
                                class="action-btn action-delete"
                                data-live-action="deleteNotification"
                                data-param-notification-id="{{notification.id}}"
                                title="Löschen"
                            >
                                🗑️
                            </button>
                        </div>
                    </div>
                </for>

                <if condition="empty(notifications)">
                    <div class="empty-state">
                        <div class="empty-icon">🔕</div>
                        <div class="empty-text">Keine Benachrichtigungen vorhanden</div>
                    </div>
                </if>
            </div>

            <!-- Panel Footer -->
            <div class="panel-footer">
                <span class="notification-count">
                    {{notifications_count_text}}
                </span>
                <span class="unread-count">
                    {{unread_count}} ungelesen
                </span>
            </div>
        </div>
    </if>
</div>

<style>
.notification-center-component {
    position: relative;
}

.notification-header {
    display: flex;
    justify-content: flex-end;
}

.notification-bell {
    position: relative;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notification-bell:hover {
    background: #f5f5f5;
    transform: scale(1.05);
}

.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #f44336;
    color: white;
    border-radius: 50%;
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
    padding: 0 6px;
}

.notification-panel {
    position: absolute;
    top: 60px;
    right: 0;
    width: 400px;
    max-height: 600px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.panel-header {
    padding: 1rem;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.panel-header h3 {
    margin: 0;
    font-size: 1.125rem;
}

.panel-actions {
    display: flex;
    gap: 0.5rem;
}

.btn {
    padding: 0.375rem 0.75rem;
    border: 1px solid #e0e0e0;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s;
}

.btn:hover:not(:disabled) {
    background: #f5f5f5;
}

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

.btn-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.btn-danger {
    background: #f44336;
    color: white;
    border-color: #f44336;
}

.btn-danger:hover {
    background: #d32f2f;
}

.notification-filters {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e0e0e0;
    overflow-x: auto;
}

.filter-tab {
    padding: 0.5rem 0.75rem;
    border: 1px solid #e0e0e0;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    white-space: nowrap;
    transition: all 0.2s;
}

.filter-tab:hover {
    background: #f5f5f5;
}

.filter-tab.active {
    background: #2196F3;
    color: white;
    border-color: #2196F3;
}

.notifications-list {
    flex: 1;
    overflow-y: auto;
    max-height: 400px;
}

.notification-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s;
}

.notification-item:hover {
    background: #f9f9f9;
}

.notification-item.unread {
    background: #e3f2fd;
}

.notification-item.unread:hover {
    background: #bbdefb;
}

.notification-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.notification-content {
    flex: 1;
    min-width: 0;
}

.notification-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
}

.notification-message {
    font-size: 0.875rem;
    color: #666;
    margin-bottom: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notification-time {
    font-size: 0.75rem;
    color: #999;
}

.notification-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    padding: 0.25rem;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.action-btn:hover {
    opacity: 1;
}

.action-delete:hover {
    opacity: 1;
    filter: hue-rotate(180deg);
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #999;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.empty-text {
    font-size: 0.875rem;
}

.panel-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: #666;
    background: #f9f9f9;
}

.unread-count {
    font-weight: 600;
    color: #2196F3;
}

/* Notification Type Styles */
.notification-success {
    border-left: 3px solid #4CAF50;
}

.notification-info {
    border-left: 3px solid #2196F3;
}

.notification-warning {
    border-left: 3px solid #FFC107;
}

.notification-error {
    border-left: 3px solid #f44336;
}

/* Responsive */
@media (max-width: 768px) {
    .notification-panel {
        width: 100vw;
        max-width: 400px;
        right: -10px;
    }
}
</style>
