/**
 * Functional Roles CSS
 * Styles for role badge, role selection modal, and dashboard navigation modal
 */

/* ============================================================================
   ROLE BADGE IN HEADER
   ============================================================================ */

#role-badge {
    display: none;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-right: 0.5rem;
    white-space: nowrap;
}

#role-badge.has-role {
    background: var(--badge-color, #6b7280);
    color: white;
}

#role-badge.no-role {
    background: #f59e0b;
    color: white;
    animation: pulse-badge 2s infinite;
}

#role-badge:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

#role-badge i {
    font-size: 0.9rem;
}

@keyframes pulse-badge {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ============================================================================
   ROLE BUTTON IN HEADER (header-action-btn)
   ============================================================================ */

#role-btn .role-emoji {
    font-style: normal;
    font-size: 1.1rem;
    line-height: 1;
}

#role-btn.has-role {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

#role-btn.has-role:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

/* ============================================================================
   DASHBOARD NAVIGATION BUTTON
   ============================================================================ */

.dashboard-nav-button {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.dashboard-nav-button:hover {
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.dashboard-nav-button #current-dashboard-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 6px;
}

.dashboard-nav-button #current-dashboard-icon i {
    font-size: 0.9rem;
}

.dashboard-nav-button #current-dashboard-name {
    font-weight: 600;
}

.dashboard-nav-button .fa-chevron-down {
    font-size: 0.7rem;
    opacity: 0.8;
    margin-left: 0.25rem;
}

/* ============================================================================
   TILE MODAL BASE STYLES
   ============================================================================ */

.tile-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 10000;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.tile-modal.active {
    display: flex;
    animation: fadeIn 0.2s ease;
}

.tile-modal-content {
    background: #1e293b;
    border-radius: 16px;
    max-width: 700px;
    width: 100%;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tile-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #334155;
    background: #0f172a;
}

.tile-modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: white;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.tile-modal-header h3 i {
    color: #3b82f6;
}

.tile-modal-close {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    line-height: 1;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.tile-modal-close:hover {
    background: #334155;
    color: white;
}

.tile-modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    max-height: calc(80vh - 80px);
}

/* Loading State */
.tile-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: #94a3b8;
    gap: 1rem;
}

.tile-loading i {
    font-size: 2rem;
    color: #3b82f6;
}

/* ============================================================================
   TILE SECTION
   ============================================================================ */

.tile-section {
    margin-bottom: 1.5rem;
}

.tile-section:last-child {
    margin-bottom: 0;
}

.tile-section h4 {
    margin: 0 0 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
}

/* ============================================================================
   DASHBOARD GRID - Uses same tile-grid as Functions modal
   ============================================================================ */

/* Emoji icon style for dashboard tiles */
.tile-icon-emoji {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin-bottom: 10px;
    border-radius: 12px;
    background: var(--bg-tertiary, #334155);
    transition: all 0.2s;
}

.tile:hover .tile-icon-emoji {
    transform: scale(1.05);
    background: var(--bg-tertiary, #475569);
}

/* Active dashboard indicator */
.tile.dashboard-active {
    border-color: var(--primary-color, #3b82f6);
    background: rgba(59, 130, 246, 0.1);
}

.tile.dashboard-active .tile-icon-emoji {
    background: rgba(59, 130, 246, 0.2);
}

/* Checkmark for active dashboard */
.dashboard-check {
    position: absolute;
    top: 8px;
    right: 8px;
    color: #10b981;
    font-weight: 700;
    font-size: 1.1rem;
}

/* Make tile position relative for absolute checkmark */
#dashboard-nav-grid .tile,
#role-select-grid .tile {
    position: relative;
}

/* ============================================================================
   ROLE TILES - Same style as dashboard tiles
   ============================================================================ */

/* Active role indicator */
.tile.role-active {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.1);
}

.tile.role-active .tile-icon-emoji {
    background: rgba(16, 185, 129, 0.2);
}

/* Checkmark for active role */
.role-check {
    position: absolute;
    top: 8px;
    right: 8px;
    color: #10b981;
    font-weight: 700;
    font-size: 1.1rem;
}

/* Lock icon for taken role */
.role-taken {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 0.9rem;
}

/* Exclusive badge (shows "1" for single-user roles) */
.role-exclusive-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #f59e0b;
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Audit-Log Tile für Einsatzleiter */
.tile.tile-audit {
    border-color: #6366f1;
    background: rgba(99, 102, 241, 0.05);
}

.tile.tile-audit:hover {
    border-color: #6366f1;
    background: rgba(99, 102, 241, 0.15);
}

.tile.tile-audit .tile-icon-emoji {
    background: rgba(99, 102, 241, 0.15);
}

/* ============================================================================
   CURRENT ROLE BOX WITH LOGOUT BUTTON
   ============================================================================ */

.current-role-section {
    margin-bottom: 1.5rem;
}

.current-role-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(16, 185, 129, 0.05) 100%);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 12px;
    gap: 1rem;
}

.current-role-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.current-role-emoji {
    font-size: 1.75rem;
    line-height: 1;
}

.current-role-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: #10b981;
}

.btn-logout-role {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-logout-role:hover {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-logout-role i {
    font-size: 0.9rem;
}

/* ============================================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================================ */

@media (max-width: 640px) {
    .tile-modal-content {
        max-height: 90vh;
        border-radius: 12px;
    }

    .tile-modal-body {
        padding: 1rem;
    }

    /* Current role box responsive */
    .current-role-box {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
        padding: 0.875rem 1rem;
    }

    .current-role-info {
        justify-content: center;
    }

    .btn-logout-role {
        justify-content: center;
        padding: 0.625rem 1rem;
    }
}

/* ============================================================================
   HEADER NAVIGATION ADJUSTMENTS
   ============================================================================ */

/* Hide old nav buttons when new system is active */
.header-center.dashboard-nav.hide-old-nav .nav-btn {
    display: none;
}

/* Show only the dashboard nav button in new mode */
.header-center.dashboard-nav.new-nav {
    gap: 0.5rem;
}
